Skip to content
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

[ONNX] Deprecated the example_outputs param from torch.onnx.export() function. (#62815) #64380

Closed
wants to merge 6 commits into from

Conversation

BowenBao
Copy link
Collaborator

@BowenBao BowenBao commented Sep 1, 2021

Stack from ghstack:

Co-authored-by: hwangdeyu dejack953@outlook.com

Differential Revision: D30905266

…function. (#62815)

* `example_outputs` used to determine the type and shape of the outputs without tracing the execution of the model. And it must be provided when exporting a ScriptModule or ScriptFunction when using export() function.

* Since we can work out `example_outputs` in internal function instead of being provided by user, so we deprecated this argument in the export() function to increase user experience of calling this function.

Co-authored-by: hwangdeyu <dejack953@outlook.com>

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Sep 1, 2021

🔗 Helpful links

💊 CI failures summary and remediations

As of commit fbda947 (more details on the Dr. CI page):


  • 3/4 failures introduced in this PR
  • 1/4 broken upstream at merge base d354df4 on Sep 01 from 10:31am to 10:53am

🕵️ 3 new failures recognized by patterns

The following CI failures do not appear to be due to upstream breakages:

See GitHub Actions build linux-xenial-cuda11.3-py3.6-gcc7 / test (default, 1, 2, linux.8xlarge.nvidia.gpu) (1/3)

Step: "Unknown" (full log | diagnosis details | 🔁 rerun)

2021-09-22T21:11:04.8746795Z RuntimeError: CUDA error: device-side assert triggered
2021-09-22T21:11:01.7135742Z   File "/opt/conda/lib/python3.6/site-packages/torch/cuda/__init__.py", line 493, in synchronize
2021-09-22T21:11:01.7137041Z     return torch._C._cuda_synchronize()
2021-09-22T21:11:01.7138172Z RuntimeError: CUDA error: device-side assert triggered
2021-09-22T21:11:01.7139228Z CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
2021-09-22T21:11:01.7140242Z For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
2021-09-22T21:11:04.8738146Z /var/lib/jenkins/workspace/aten/src/ATen/native/cuda/TensorCompare.cu:161: _assert_async_cuda_kernel: block: [0,0,0], thread: [0,0,0] Assertion `input[0] != c10::complex<float>(0, 0)` failed.
2021-09-22T21:11:04.8742403Z Traceback (most recent call last):
2021-09-22T21:11:04.8743011Z   File "<string>", line 4, in <module>
2021-09-22T21:11:04.8744367Z   File "/opt/conda/lib/python3.6/site-packages/torch/cuda/__init__.py", line 493, in synchronize
2021-09-22T21:11:04.8745616Z     return torch._C._cuda_synchronize()
2021-09-22T21:11:04.8746795Z RuntimeError: CUDA error: device-side assert triggered
2021-09-22T21:11:04.8747843Z CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
2021-09-22T21:11:04.8748815Z For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
2021-09-22T21:11:05.0763605Z ok (12.786s)
2021-09-22T21:11:05.0830403Z   test_gather_bool (__main__.TestCuda) ... ok (0.007s)
2021-09-22T21:11:05.0873743Z   test_get_device_index (__main__.TestCuda) ... ok (0.004s)
2021-09-22T21:11:05.0935928Z   test_get_set_rng_state_all (__main__.TestCuda) ... ok (0.006s)
2021-09-22T21:11:05.1145119Z   test_grad_scaling_accumulation (__main__.TestCuda) ... ok (0.021s)
2021-09-22T21:11:05.1577160Z   test_grad_scaling_autocast (__main__.TestCuda) ... ok (0.043s)
2021-09-22T21:11:05.1847825Z   test_grad_scaling_clipping (__main__.TestCuda) ... ok (0.027s)
2021-09-22T21:11:05.2109832Z   test_grad_scaling_clipping_separate_unscale (__main__.TestCuda) ... ok (0.026s)

See GitHub Actions build linux-bionic-py3.6-clang9 / test (default, 1, 2, linux.2xlarge) (2/3)

Step: "Unknown" (full log | diagnosis details | 🔁 rerun)

2021-09-22T20:08:38.9340547Z CONTINUE_THROUGH_ERROR: false
  "open source",
  "cla signed"
]
2021-09-22T20:08:38.9336270Z   GITHUB_TOKEN: ***
2021-09-22T20:08:38.9337455Z   DOCKER_IMAGE: 308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/pytorch-linux-bionic-py3.6-clang9:fbf6abc1df97cac5878c07d7fef5441b3ecfb6b8
2021-09-22T20:08:38.9338711Z   JOB_BASE_NAME: linux-bionic-py3.6-clang9-test
2021-09-22T20:08:38.9339202Z   TEST_CONFIG: default
2021-09-22T20:08:38.9339518Z   SHARD_NUMBER: 1
2021-09-22T20:08:38.9339806Z   NUM_TEST_SHARDS: 2
2021-09-22T20:08:38.9340165Z   PYTORCH_IGNORE_DISABLED_ISSUES: 
2021-09-22T20:08:38.9340547Z   CONTINUE_THROUGH_ERROR: false
2021-09-22T20:08:38.9340874Z   SHM_SIZE: 1g
2021-09-22T20:08:38.9341139Z   PR_NUMBER: 64380
2021-09-22T20:08:38.9341408Z   IS_GHA: 1
2021-09-22T20:08:38.9341701Z   CIRCLE_BRANCH: pull/64380
2021-09-22T20:08:38.9342083Z   CIRCLE_PR_NUMBER: 64380
2021-09-22T20:08:38.9342610Z   CIRCLE_SHA1: fbda9476f1dc03d226bee5a11a7f55807bcc4ce7
2021-09-22T20:08:38.9343143Z   AWS_DEFAULT_REGION: us-east-1
2021-09-22T20:08:38.9343484Z ##[endgroup]
2021-09-22T20:08:51.2056108Z Processing ./dist/torch-1.11.0a0+gita5a9c34-cp36-cp36m-linux_x86_64.whl
2021-09-22T20:08:51.2338986Z Requirement already satisfied: typing-extensions in /opt/conda/lib/python3.6/site-packages (from torch==1.11.0a0+gita5a9c34) (3.10.0.2)

See GitHub Actions build win-vs2019-cpu-py3 / test (default, 2, 2, windows.4xlarge) (3/3)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

2021-09-22T20:21:45.6925991Z RuntimeError: test_cpp_extensions_jit failed!
2021-09-22T20:21:45.5946807Z 
2021-09-22T20:21:45.5947104Z FAILED (errors=1, skipped=7)
2021-09-22T20:21:45.5947338Z 
2021-09-22T20:21:45.5947629Z Generating XML reports...
2021-09-22T20:21:45.5948504Z Generated XML report: test-reports\dist-gloo\test_cpp_extensions_jit\TEST-TestCppExtensionJIT-20210922201916.xml
2021-09-22T20:21:45.6923460Z Traceback (most recent call last):
2021-09-22T20:21:45.6924227Z   File "run_test.py", line 1030, in <module>
2021-09-22T20:21:45.6924582Z     main()
2021-09-22T20:21:45.6925091Z   File "run_test.py", line 1008, in main
2021-09-22T20:21:45.6925517Z     raise RuntimeError(err_message)
2021-09-22T20:21:45.6925991Z RuntimeError: test_cpp_extensions_jit failed!
2021-09-22T20:21:45.8981030Z 
2021-09-22T20:21:45.8981666Z (base) C:\actions-runner\_work\pytorch\pytorch\pytorch-1262833280\test>popd
2021-09-22T20:21:45.8986519Z 
2021-09-22T20:21:45.8987070Z (base) C:\actions-runner\_work\pytorch\pytorch\pytorch-1262833280>if ERRORLEVEL 1 exit /b 1 
2021-09-22T20:21:45.9010823Z + cleanup
2021-09-22T20:21:45.9011148Z + retcode=1
2021-09-22T20:21:45.9011419Z + set +x
2021-09-22T20:21:45.9044681Z ##[error]Process completed with exit code 1.
2021-09-22T20:21:45.9197065Z ##[group]Run # -ir => recursive include all files in pattern
2021-09-22T20:21:45.9197747Z �[36;1m# -ir => recursive include all files in pattern�[0m

🚧 1 fixed upstream failure:

These were probably caused by upstream breakages that were already fixed.

Please rebase on the viable/strict branch (expand for instructions)

If your commit is older than viable/strict, run these commands:

git fetch https://github.com/pytorch/pytorch viable/strict
git rebase FETCH_HEAD

This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

…x.export() function. (#62815)"

* `example_outputs` used to determine the type and shape of the outputs without tracing the execution of the model. And it must be provided when exporting a ScriptModule or ScriptFunction when using export() function.

* Since we can work out `example_outputs` in internal function instead of being provided by user, so we deprecated this argument in the export() function to increase user experience of calling this function.

Co-authored-by: hwangdeyu <dejack953@outlook.com>

[ghstack-poisoned]
…x.export() function. (#62815)"

* `example_outputs` used to determine the type and shape of the outputs without tracing the execution of the model. And it must be provided when exporting a ScriptModule or ScriptFunction when using export() function.

* Since we can work out `example_outputs` in internal function instead of being provided by user, so we deprecated this argument in the export() function to increase user experience of calling this function.

Co-authored-by: hwangdeyu <dejack953@outlook.com>

[ghstack-poisoned]
…x.export() function. (#62815)"

* `example_outputs` used to determine the type and shape of the outputs without tracing the execution of the model. And it must be provided when exporting a ScriptModule or ScriptFunction when using export() function.

* Since we can work out `example_outputs` in internal function instead of being provided by user, so we deprecated this argument in the export() function to increase user experience of calling this function.

Co-authored-by: hwangdeyu <dejack953@outlook.com>

[ghstack-poisoned]
@msaroufim
Copy link
Member

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

…x.export() function. (#62815)"

* `example_outputs` used to determine the type and shape of the outputs without tracing the execution of the model. And it must be provided when exporting a ScriptModule or ScriptFunction when using export() function.

* Since we can work out `example_outputs` in internal function instead of being provided by user, so we deprecated this argument in the export() function to increase user experience of calling this function.

Co-authored-by: hwangdeyu <dejack953@outlook.com>

Differential Revision: [D30905266](https://our.internmc.facebook.com/intern/diff/D30905266)

[ghstack-poisoned]
if example_outputs is None:
example_outputs = _get_example_outputs(model, args)
else:
# example_outpus specified
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hwangdeyu updated code to replicate previous results.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me!

@malfet
Copy link
Contributor

malfet commented Sep 22, 2021

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

…x.export() function. (#62815)"

* `example_outputs` used to determine the type and shape of the outputs without tracing the execution of the model. And it must be provided when exporting a ScriptModule or ScriptFunction when using export() function.

* Since we can work out `example_outputs` in internal function instead of being provided by user, so we deprecated this argument in the export() function to increase user experience of calling this function.

Co-authored-by: hwangdeyu <dejack953@outlook.com>

Differential Revision: [D30905266](https://our.internmc.facebook.com/intern/diff/D30905266)

[ghstack-poisoned]
@malfet
Copy link
Contributor

malfet commented Sep 22, 2021

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

@facebook-github-bot
Copy link
Contributor

@malfet merged this pull request in 478d4cf.

@facebook-github-bot facebook-github-bot deleted the gh/BowenBao/122/head branch September 27, 2021 14:18
garymm pushed a commit to garymm/pytorch that referenced this pull request Oct 1, 2021
…function. (pytorch#62815) (pytorch#64380)

Summary:
Pull Request resolved: pytorch#64380

* `example_outputs` used to determine the type and shape of the outputs without tracing the execution of the model. And it must be provided when exporting a ScriptModule or ScriptFunction when using export() function.

* Since we can work out `example_outputs` in internal function instead of being provided by user, so we deprecated this argument in the export() function to increase user experience of calling this function.

Test Plan: Imported from OSS

Reviewed By: ezyang

Differential Revision: D30905266

Pulled By: malfet

fbshipit-source-id: d00b00d7d02b365d165028288ad915678caa51f2

Co-authored-by: hwangdeyu <dejack953@outlook.com>
malfet pushed a commit that referenced this pull request Oct 8, 2021
* [ONNX] Remove argument _retain_param_name from torch.onnx.export() function. (#61702) (#64370)

Summary:
Pull Request resolved: #64370

As of now, the "_retain_param_name" parameter has no description in PyTorch docs website. According to code, this argument determines if we keep the original parameter names of PyTorch model in the final ONNX graph. If this is False, those original parameter names will be replaced with a series of integers starting from 1.

Since setting numbers as parameter names make no sense to users, we remove this argument from the torch.onnx.export() function to increase user experience of calling this function.

This PR will still keep it in torch.onnx.export() function for backward support while all backend logic has been changed to work as _retain_param_name is set to True.

Test Plan: Imported from OSS

Reviewed By: ezyang

Differential Revision: D30905270

Pulled By: malfet

fbshipit-source-id: ca60757ca17daaff937e9f08da42596086795f4a

Co-authored-by: fatcat-z <zhang-ji@outlook.com>

* [ONNX] Remove strip_doc_string param from torch.onnx.export() function. (#61712) (#64371)

Summary:
Pull Request resolved: #64371

As of now, the "strip_doc_string" parameter was described as below:

strip_doc_string (bool, default True): do not include the field
doc_string``` from the exported model. Otherwise the field will mention the source code locations for model``.

This is usually useless to users who want to transform a PyTorch model to ONNX one. Only when the user wants to debug the export process, these source code locations could provide benefits.

To make the export() function more friendly by providing less parameters, we combined "strip_doc_string" into "verbose" parameter. If a user set verbose to True, it means the users need some log information for debugging the export process and this is similar with the purpose of strip_doc_string parameter.

But the usage of these 2 arguments are opposite: setting verbose to True means we want to print log information to help debug, which means strip_doc_string should be False. And this is how we replace strip_doc_string with verbose argument in this PR.

This PR will still keep it in torch.onnx.export() function for backward support while the usage of it has been combined with verbose argument.

Test Plan: Imported from OSS

Reviewed By: ezyang

Differential Revision: D30905268

Pulled By: malfet

fbshipit-source-id: 2f06eb805c01fe15ff7a1b4f6595c937ba716d60

Co-authored-by: fatcat-z <zhang-ji@outlook.com>

* [ONNX] minor doc improvements and cleanup (#62514) (#64373)

Summary:
Pull Request resolved: #64373

* Fix some bad formatting and clarify things in onnx.rst.
* In `export_to_pretty_string`:
    * Add documentation for previously undocumented args.
    * Document that `f` arg is ignored and mark it deprecated.
    * Update tests to stop setting `f`.
    * Warn if `_retain_param_name` is set.
* Use double quotes for string literals in test_operators.py.

Test Plan: Imported from OSS

Reviewed By: ezyang

Differential Revision: D30905271

Pulled By: malfet

fbshipit-source-id: 3627eeabf40b9516c4a83cfab424ce537b36e4b3

* [ONNX] Deprecated the example_outputs param from torch.onnx.export() function. (#62815) (#64380)

Summary:
Pull Request resolved: #64380

* `example_outputs` used to determine the type and shape of the outputs without tracing the execution of the model. And it must be provided when exporting a ScriptModule or ScriptFunction when using export() function.

* Since we can work out `example_outputs` in internal function instead of being provided by user, so we deprecated this argument in the export() function to increase user experience of calling this function.

Test Plan: Imported from OSS

Reviewed By: ezyang

Differential Revision: D30905266

Pulled By: malfet

fbshipit-source-id: d00b00d7d02b365d165028288ad915678caa51f2

Co-authored-by: hwangdeyu <dejack953@outlook.com>

* [ONNX] Deprecate use_external_data_format param from torch.onnx.export() function. (#62257) (#64382)

Summary:
Pull Request resolved: #64382

* This `use_external_data_format` parameter is used for large models cannot be exported because of the 2GB protobuf limit.

* When `use_external_data_format` set to True, the model is exported in ONNX external data format, in which case some of the model parameters are stored in external binary files and not in the ONNX model file itself.

* This PR will set this paramter to DEPRECATED and check the model proto sizes by code instead of by user, if the sizes lager than 2GB, then `use_external_data_format = True` automatically.

Test Plan: Imported from OSS

Reviewed By: ezyang

Differential Revision: D30905265

Pulled By: malfet

fbshipit-source-id: 82b4e17bfa6a8de2bfd700a5282c12f6835603cb

Co-authored-by: hwangdeyu <dejack953@outlook.com>

* fix clang-tidy error introduced by #64382 (#65977)

Summary: Pull Request resolved: #65977

Reviewed By: ngimel

Differential Revision: D31423174

Pulled By: malfet

fbshipit-source-id: 0ea560b9a6ddd6431f70bd3ac10ace68e26ab352

Co-authored-by: BowenBao <bowbao@microsoft.com>
Co-authored-by: fatcat-z <zhang-ji@outlook.com>
Co-authored-by: hwangdeyu <dejack953@outlook.com>
@Ark-kun
Copy link

Ark-kun commented Mar 14, 2022

The documentation still mentions the parameter. https://github.com/pytorch/pytorch/blob/9257de7/docs/source/onnx.rst#id30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed Merged oncall: jit Add this issue/PR to JIT oncall triage queue open source
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants