Open suo opened 1 year ago
@bdhirsh I thought we fixed this for some variation of tensor creation ops already? Is this a regression or a different thing?
ah it was just for *_like
factories: https://github.com/pytorch/pytorch/pull/97564. Could a similar strategy be applied to these tensor creation functions?
Direct tensor creation cannot easily be done this way, because there is no "tensor" to copy the device off of. So you need symbolic device or post facto fixup.
But conceptually if I call torch.empty((2, 3))
, I would not expect the graph to have device="cpu"
, since I am declaring my intent only to create a tensor on the default device, which only happens to be the cpu right now.
I would expect the graph to just have torch.ops.aten.empty((2, 3))
without device specified, which when invoked will do the same default device lookup (which may be return a different result depending on the runtime state).
Oh, this is the thing where we apply default device in torch layer, so you go from device=None to device="cpu" when you get to dispatcher. Hmmm yeah this should be fixable.
@suo I think in practice this issue will go away when we enable pre-dispatch ir, but we will also add a post export check to detect device burn-in.
produces:
Note the following line burns in
device=cpu
.These kwargs are optional; I'd like for them to not show up in the graph if the user didn't specify them.
cc @ezyang @msaroufim @bdhirsh @anijain2305 @zou3519 @chauhang @avikchaudhuri @gmagogsfm @zhxchen17 @tugsbayasgalan @angelayi @ydwu4 @wconstab