KEMBAR78
[ONNX] Create deprecation warning on dynamo_export by justinchuby · Pull Request #146425 · pytorch/pytorch · GitHub
Skip to content

Conversation

justinchuby
Copy link
Collaborator

@justinchuby justinchuby commented Feb 4, 2025

Reland #146003

Deprecation of torch.onnx.dynamo_export:

  • [torch/onnx/_internal/_exporter_legacy.py]: Added deprecation warnings to the OnnxRegistry, ExportOptions, ONNXRuntimeOptions, and dynamo_export functions, indicating that torch.onnx.dynamo_export is deprecated since version 2.6.0 and should be replaced with torch.onnx.export(..., dynamo=True).

@pytorch-bot
Copy link

pytorch-bot bot commented Feb 4, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/146425

Note: Links to docs will display an error until the docs builds have been completed.

⏳ No Failures, 1 Pending

As of commit c2c2692 with merge base 23fffb5 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot bot added ci-no-td Do not run TD on this PR release notes: onnx torch.onnx related changes that should show up in the release notes labels Feb 4, 2025
@justinchuby justinchuby added module: onnx Related to torch.onnx topic: deprecation topic category ciflow/trunk Trigger trunk jobs on your pull request labels Feb 4, 2025
@justinchuby
Copy link
Collaborator Author

@atalman could you import this PR? Thanks!

@facebook-github-bot
Copy link
Contributor

@atalman has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@atalman
Copy link
Contributor

atalman commented Feb 4, 2025

hi @justinchuby reimported the PR internally will followup with internal team on relanding

@justinchuby
Copy link
Collaborator Author

@atalman does it look good? Thanks

@justinchuby
Copy link
Collaborator Author

I am going to remove the deprecation warnings and instead only annotate the methods for now so that we can land this PR. @atalman feel free to let me know when internal usages are updated

@justinchuby justinchuby changed the title [ONNX][reland] Create deprecation warning on dynamo_export [ONNX] Create deprecation warning on dynamo_export; remove unused Feb 6, 2025
@justinchuby
Copy link
Collaborator Author

@atalman could you re-import?

@facebook-github-bot
Copy link
Contributor

@atalman has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@justinchuby
Copy link
Collaborator Author

@pytorchbot merge -i

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged while ignoring the following 1 checks: trunk / linux-focal-rocm6.3-py3.10 / test (distributed, 1, 1, linux.rocm.gpu.4)

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot
Copy link
Collaborator

The merge job was canceled or timed out. This most often happen if two merge requests were issued for the same PR, or if merge job was waiting for more than 6 hours for tests to finish. In later case, please do not hesitate to reissue the merge command
For more information see pytorch-bot wiki.

@justinchuby justinchuby force-pushed the justinchu/deprecation2 branch from 4bd5dbc to c2c2692 Compare February 6, 2025 21:27
@justinchuby justinchuby changed the title [ONNX] Create deprecation warning on dynamo_export; remove unused [ONNX] Create deprecation warning on dynamo_export Feb 6, 2025
@justinchuby
Copy link
Collaborator Author

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

@temikgo
Copy link

temikgo commented Feb 10, 2025

I use torch.onnx.dynamo_export with FakeTensors, like this:

with torch.onnx.enable_fake_mode() as fake_context:
        x = torch.empty((2, 128, 1), dtype=torch.float16)
        model = Transformer(args)
export_options = torch.onnx.ExportOptions(
        fake_context=fake_context
)
export_output = torch.onnx.dynamo_export(
        torch_model, input_data, export_options=export_options
)

how can I use torch.onnx.export(... dynamo=true ...) with FakeTensors inside?

@atalman
Copy link
Contributor

atalman commented Feb 10, 2025

@pytorchmergebot revert -c ghfirst -m "Broke internal tests"

@pytorchmergebot
Copy link
Collaborator

@pytorchbot successfully started a revert job. Check the current status here.
Questions? Feedback? Please reach out to the PyTorch DevX Team

@pytorchmergebot
Copy link
Collaborator

Reverting PR 146425 failed

Reason: Command git -C /home/runner/work/pytorch/pytorch revert --no-edit 41e6d189a39a40b237ab9b9ab195cec1194b331b returned non-zero exit code 1

Auto-merging torch/onnx/__init__.py
CONFLICT (modify/delete): torch/onnx/_deprecation.py deleted in HEAD and modified in parent of 41e6d189a39 ([ONNX] Create deprecation warning on dynamo_export (#146425)).  Version parent of 41e6d189a39 ([ONNX] Create deprecation warning on dynamo_export (#146425)) of torch/onnx/_deprecation.py left in tree.
Auto-merging torch/onnx/_internal/_exporter_legacy.py
CONFLICT (content): Merge conflict in torch/onnx/_internal/_exporter_legacy.py
Auto-merging torch/onnx/utils.py
Auto-merging torch/onnx/verification.py
CONFLICT (content): Merge conflict in torch/onnx/verification.py
error: could not revert 41e6d189a39... [ONNX] Create deprecation warning on dynamo_export (#146425)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git revert --continue".
hint: You can instead skip this commit with "git revert --skip".
hint: To abort and get back to the state before "git revert",
hint: run "git revert --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Details for Dev Infra team Raised by workflow job

pytorchmergebot added a commit that referenced this pull request Feb 10, 2025
This reverts commit 63c2909.

Reverted #146639 on behalf of https://github.com/atalman due to Sorry Need to revert #146425 ([comment](#146639 (comment)))
pytorchmergebot referenced this pull request Feb 10, 2025
Adjust and add deprecation messages to torch.onnx utilities and verification methods because they are only related to torch script and are obsolete.

Removed unused `_exporter_states.py` and removed the internal deprecation module in favor of the typing_extensions deprecated decorator.
Pull Request resolved: #146639
Approved by: https://github.com/titaiwangms
@atalman
Copy link
Contributor

atalman commented Feb 10, 2025

@pytorchmergebot revert -c ghfirst -m "Broke internal tests"

@pytorchmergebot
Copy link
Collaborator

@pytorchbot successfully started a revert job. Check the current status here.
Questions? Feedback? Please reach out to the PyTorch DevX Team

pytorchmergebot added a commit that referenced this pull request Feb 10, 2025
This reverts commit 41e6d18.

Reverted #146425 on behalf of https://github.com/atalman due to Broke internal tests ([comment](#146425 (comment)))
@pytorchmergebot
Copy link
Collaborator

@justinchuby your PR has been successfully reverted.

@justinchuby
Copy link
Collaborator Author

I use torch.onnx.dynamo_export with FakeTensors, like this:

with torch.onnx.enable_fake_mode() as fake_context:
        x = torch.empty((2, 128, 1), dtype=torch.float16)
        model = Transformer(args)
export_options = torch.onnx.ExportOptions(
        fake_context=fake_context
)
export_output = torch.onnx.dynamo_export(
        torch_model, input_data, export_options=export_options
)

how can I use torch.onnx.export(... dynamo=true ...) with FakeTensors inside?

There is no need. torch.export uses faketensors by default. You may also pass in fake tensors as example inputs

justinchuby added a commit to justinchuby/pytorch that referenced this pull request Feb 11, 2025
Reland pytorch#146003

Deprecation of `torch.onnx.dynamo_export`:

* [`torch/onnx/_internal/_exporter_legacy.py`]: Added deprecation warnings to the `OnnxRegistry`, `ExportOptions`, `ONNXRuntimeOptions`, and `dynamo_export` functions, indicating that `torch.onnx.dynamo_export` is deprecated since version 2.6.0 and should be replaced with `torch.onnx.export(..., dynamo=True)`.

Pull Request resolved: pytorch#146425
Approved by: https://github.com/titaiwangms, https://github.com/atalman
@justinchuby
Copy link
Collaborator Author

Replaced by #146923

pytorchmergebot pushed a commit that referenced this pull request Feb 12, 2025
Reland two PRs
- #146425
- #146639

Fixed by removing the deprecation warning on a base class `ExportOptions`.
Pull Request resolved: #146923
Approved by: https://github.com/titaiwangms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-no-td Do not run TD on this PR ciflow/trunk Trigger trunk jobs on your pull request Merged module: onnx Related to torch.onnx open source release notes: onnx torch.onnx related changes that should show up in the release notes Reverted topic: deprecation topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants