-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Add optional torch.export.ExportGraphSignature to ONNXProgram #113477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add optional torch.export.ExportGraphSignature to ONNXProgram #113477
Conversation
When the ONNX model is exported from a torch.export.ExportedProgram, a torch.export.ExportedGraphSignature is available with the specification of the model inputs and outputs. ExportedGraphSignature includes information such as the mapping between the exported input name to the original input/buffer/output name. It also specifies the kind of the input, such as user_input, parameter, buffer or constant_tensor. Outputs kind can be user_output, loss_output, buffer_mutation, etc Such information can be useful to understand what the ONNX model expects as inputs and how the output will look like when the ONNX input/output differs from the original PyTorch input/output schema. When the ONNX model is exported from a Callable or regular torch.nn.MOdule, such information is not available and ONNXProgram.model_signature will yield NOne [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/113477
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 2c97ecc with merge base 28228e1 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
…ram" When the ONNX model is exported from a torch.export.ExportedProgram, a torch.export.ExportedGraphSignature is available with the specification of the model inputs and outputs. ExportedGraphSignature includes information such as the mapping between the exported input/buffer/output ONNX name to the original pytorch input/buffer/output name. It also specifies the kind of the input, such as user_input, parameter, buffer or constant_tensor. Outputs kind can be user_output, loss_output, buffer_mutation, etc Such information can be useful to understand what the ONNX model expects as inputs and how the output will look like when the ONNX input/output differs from the original PyTorch input/output schema. When the ONNX model is exported from a Callable or regular torch.nn.MOdule, such information is not available and ONNXProgram.model_signature will yield NOne [ghstack-poisoned]
…ram" When the ONNX model is exported from a torch.export.ExportedProgram, a torch.export.ExportedGraphSignature is available with the specification of the model inputs and outputs. ExportedGraphSignature includes information such as the mapping between the exported input/buffer/output ONNX name to the original pytorch input/buffer/output name. It also specifies the kind of the input, such as user_input, parameter, buffer or constant_tensor. Outputs kind can be user_output, loss_output, buffer_mutation, etc Such information can be useful to understand what the ONNX model expects as inputs and how the output will look like when the ONNX input/output differs from the original PyTorch input/output schema. When the ONNX model is exported from a Callable or regular torch.nn.MOdule, such information is not available and ONNXProgram.model_signature will yield NOne [ghstack-poisoned]
…ram" When the ONNX model is exported from a torch.export.ExportedProgram, a torch.export.ExportedGraphSignature is available with the specification of the model inputs and outputs. ExportedGraphSignature includes information such as the mapping between the exported input/buffer/output ONNX name to the original pytorch input/buffer/output name. It also specifies the kind of the input, such as user_input, parameter, buffer or constant_tensor. Outputs kind can be user_output, loss_output, buffer_mutation, etc Such information can be useful to understand what the ONNX model expects as inputs and how the output will look like when the ONNX input/output differs from the original PyTorch input/output schema. When the ONNX model is exported from a Callable or regular torch.nn.MOdule, such information is not available and ONNXProgram.model_signature will yield NOne [ghstack-poisoned]
…ram" When the ONNX model is exported from a torch.export.ExportedProgram, a torch.export.ExportedGraphSignature is available with the specification of the model inputs and outputs. ExportedGraphSignature includes information such as the mapping between the exported input/buffer/output ONNX name to the original pytorch input/buffer/output name. It also specifies the kind of the input, such as user_input, parameter, buffer or constant_tensor. Outputs kind can be user_output, loss_output, buffer_mutation, etc Such information can be useful to understand what the ONNX model expects as inputs and how the output will look like when the ONNX input/output differs from the original PyTorch input/output schema. When the ONNX model is exported from a Callable or regular torch.nn.MOdule, such information is not available and ONNXProgram.model_signature will yield NOne [ghstack-poisoned]
…ram" When the ONNX model is exported from a torch.export.ExportedProgram, a torch.export.ExportedGraphSignature is available with the specification of the model inputs and outputs. ExportedGraphSignature includes information such as the mapping between the exported input/buffer/output ONNX name to the original pytorch input/buffer/output name. It also specifies the kind of the input, such as user_input, parameter, buffer or constant_tensor. Outputs kind can be user_output, loss_output, buffer_mutation, etc Such information can be useful to understand what the ONNX model expects as inputs and how the output will look like when the ONNX input/output differs from the original PyTorch input/output schema. When the ONNX model is exported from a Callable or regular torch.nn.MOdule, such information is not available and ONNXProgram.model_signature will yield NOne [ghstack-poisoned]
|
@BowenBao PTAL |
| ) | ||
| """ | ||
|
|
||
| return self._model_signature |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel this is only accurate up till the point for fx-graph in ExportedProgram. Further process inside our exporter that modifies the signature will make this outdated. Unless we apply similar io adapting to this too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when user model is torch.export.ExportedProgram, we don't have any pass that changes the signature.
The only pass applied to the resulting graph module is fx_module = passes.InsertTypePromotion(diagnostic_context, fx_module).run().
The model signature is only available for this scenario
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, this makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will update the model_signature/io_adapter docstrings to make this scenario explicit
If a pass alters input/output then the module_signature has to be updated by a input/output adapter. That is a good point for a future pass (hopefully never happens)
…ram" When the ONNX model is exported from a torch.export.ExportedProgram, a torch.export.ExportedGraphSignature is available with the specification of the model inputs and outputs. ExportedGraphSignature includes information such as the mapping between the exported input/buffer/output ONNX name to the original pytorch input/buffer/output name. It also specifies the kind of the input, such as user_input, parameter, buffer or constant_tensor. Outputs kind can be user_output, loss_output, buffer_mutation, etc Such information can be useful to understand what the ONNX model expects as inputs and how the output will look like when the ONNX input/output differs from the original PyTorch input/output schema. When the ONNX model is exported from a Callable or regular torch.nn.MOdule, such information is not available and ONNXProgram.model_signature will yield NOne [ghstack-poisoned]
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Stack from ghstack (oldest at bottom):
When the ONNX model is exported from a torch.export.ExportedProgram, a
torch.export.ExportedGraphSignature is available with the specification
of the model inputs and outputs.
ExportedGraphSignature includes information such as the mapping between
the exported input/buffer/output ONNX name to the original pytorch input/buffer/output name.
It also specifies the kind of the input, such as user_input, parameter,
buffer or constant_tensor. Outputs kind can be user_output, loss_output,
buffer_mutation, etc
Such information can be useful to understand what the ONNX model expects
as inputs and how the output will look like when the ONNX input/output
differs from the original PyTorch input/output schema.
When the ONNX model is exported from a Callable or regular
torch.nn.MOdule, such information is not available and
ONNXProgram.model_signature will yield NOne