-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Open
Labels
OSS contribution wantedPR from open source contributors welcome to solve this issue.PR from open source contributors welcome to solve this issue.export-triagedThis tag is used to tag issues that have been looked by PT2 Export team and determined the next stepThis tag is used to tag issues that have been looked by PT2 Export team and determined the next stepmodule: onnxRelated to torch.onnxRelated to torch.onnxoncall: exportoncall: pt2
Description
🐛 Describe the bug
Moving this post from the pytorch forum since this seems to be a bug.
With the old dynamo_export in pytorch 2.3 , I can export a model. With pytorch 2.7 and onnx.export(dynamo=True), it throws an error
Excerpt from the model which fails in pytorch 2.7:
n_max = 1000 # fixed output size
class_out = torch.zeros(
n_max, dtype=class_all_.dtype, device=class_all_.device
)
indices = torch.arange(
0, class_all_.size(0), dtype=torch.long, device=class_all_.device
) # class_all_ is of a dynamic size
# Copy into fixed size array (bigger than dynamic array size)
class_out.index_copy_(0, indices, class_all_) # this line throws the error
Errors message:
<class 'TypeError'>: unsupported operand type(s) for *: 'int' and 'SymbolicDim'
⬆️
<class 'torch.onnx._internal.exporter._errors.GraphConstructionError'>: Error when calling function 'TracedOnnxFunction(<function aten_index_put at 0x7575b2cee830>)' with args '[SymbolicTensor(name='zeros', type=Tensor(FLOAT), shape=Shape([1000, 4]), producer='node_Expand_267', index=0), [SymbolicTensor(name='arange_2', type=Tensor(INT64), shape=Shape([SymbolicDim(u0)]), producer='node_Range_279', index=0)], SymbolicTensor(name='detach_2', type=Tensor(FLOAT), shape=Shape([SymbolicDim(u0), 4]), producer='node_Identity_254', index=0)]' and kwargs '{}'
⬆️
<class 'torch.onnx._internal.exporter._errors.ConversionError'>: Error when translating node %index_put : [num_users=1] = call_function[target=torch.ops.aten.index_put.default](args = (%zeros, [%arange_2], %detach_2), kwargs = {}). See the stack trace for more information.
Versions
PyTorch version: 2.7.1+cu118
Is debug build: False
CUDA used to build PyTorch: 11.8
ROCM used to build PyTorch: N/A
OS: Ubuntu 22.04.3 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: version 3.31.3
Libc version: glibc-2.35
cc @justinchuby @chauhang @penguinwu @avikchaudhuri @gmagogsfm @zhxchen17 @tugsbayasgalan @angelayi @suo @ydwu4
Metadata
Metadata
Assignees
Labels
OSS contribution wantedPR from open source contributors welcome to solve this issue.PR from open source contributors welcome to solve this issue.export-triagedThis tag is used to tag issues that have been looked by PT2 Export team and determined the next stepThis tag is used to tag issues that have been looked by PT2 Export team and determined the next stepmodule: onnxRelated to torch.onnxRelated to torch.onnxoncall: exportoncall: pt2