Skip to content

Conversation

titaiwangms
Copy link
Collaborator

@titaiwangms titaiwangms commented Mar 24, 2023

Stack from ghstack (oldest at bottom):

Fixes #97728
Fixes #98622
Fixes microsoft/onnxscript#393

Provide op_level_debug in exporter which creates randomnied torch.Tensor based on FakeTensorProp real shape as inputs of both torch ops and ONNX symbolic function. The PR leverages on Transformer class to create a new fx.Graph, but shares the same Module with the original one to save memory.

The test is different from op_correctness_test.py as op_level_debug generating real tensors based on the fake tensors in the model.

Limitation:

  1. Some of the trace_only function is not supported due to lack of param_schema which leads to arg/kwargs wronly split and ndarray wrapping. (WARNINGS in SARIF)
  2. The ops with dim/indices (INT64) is not supported that they need the information(shape) from other input args. (WARNINGS in SARIF)
  3. sym_size and built-in ops are not supported.
  4. op_level_debug only labels results in SARIF. It doesn't stop exporter.
  5. Introduce ONNX owning FakeTensorProp supports int/float/bool
  6. parametrized op_level_debug and dynamic_shapes into FX tests

@pytorch-bot
Copy link

pytorch-bot bot commented Mar 24, 2023

🔗 Helpful Links

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

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

✅ No Failures

As of commit 8867c75:
💚 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 the release notes: onnx torch.onnx related changes that should show up in the release notes label Mar 24, 2023
titaiwangms added a commit that referenced this pull request Mar 24, 2023
ghstack-source-id: 6828e7b
Pull Request resolved: #97494
@titaiwangms titaiwangms marked this pull request as draft March 24, 2023 01:34
titaiwangms added a commit that referenced this pull request Mar 24, 2023
ghstack-source-id: 8563ade
Pull Request resolved: #97494
@titaiwangms titaiwangms added module: onnx Related to torch.onnx topic: bug fixes topic category labels Mar 24, 2023
titaiwangms added a commit that referenced this pull request Mar 27, 2023
ghstack-source-id: fcd3f8b
Pull Request resolved: #97494
titaiwangms added a commit that referenced this pull request Mar 28, 2023
ghstack-source-id: d839262
Pull Request resolved: #97494
@titaiwangms titaiwangms marked this pull request as ready for review March 28, 2023 20:44
Fixes #97728 
Fixes microsoft/onnxscript#393

Provide op_level_debug in exporter which creates randomnied torch.Tensor based on FakeTensorProp real shape as inputs of both torch ops and ONNX symbolic function. 

The test is different from [op_correctness_test.py](https://github.com/microsoft/onnx-script/blob/main/onnxscript/tests/function_libs/torch_aten/ops_correctness_test.py) as op_level_debug generating real tensors based on the fake tensors in the model.

Limitation:
1. trace_only onnxscript function is not supported due to lack of param_schema.
2. The ops with dim/indices (INT64) is not supported that they need the information(shape) from other input args.

[ghstack-poisoned]
titaiwangms added a commit that referenced this pull request Mar 28, 2023
ghstack-source-id: 1474e27
Pull Request resolved: #97494
@titaiwangms titaiwangms marked this pull request as draft March 28, 2023 23:05
Fixes #97728 
Fixes microsoft/onnxscript#393

Provide op_level_debug in exporter which creates randomnied torch.Tensor based on FakeTensorProp real shape as inputs of both torch ops and ONNX symbolic function. 

The test is different from [op_correctness_test.py](https://github.com/microsoft/onnx-script/blob/main/onnxscript/tests/function_libs/torch_aten/ops_correctness_test.py) as op_level_debug generating real tensors based on the fake tensors in the model.

Limitation:
1. trace_only onnxscript function is not supported due to lack of param_schema.
2. The ops with dim/indices (INT64) is not supported that they need the information(shape) from other input args.

[ghstack-poisoned]
@titaiwangms titaiwangms marked this pull request as ready for review March 29, 2023 17:32
Fixes #97728 
Fixes microsoft/onnxscript#393

Provide op_level_debug in exporter which creates randomnied torch.Tensor based on FakeTensorProp real shape as inputs of both torch ops and ONNX symbolic function. 

The test is different from [op_correctness_test.py](https://github.com/microsoft/onnx-script/blob/main/onnxscript/tests/function_libs/torch_aten/ops_correctness_test.py) as op_level_debug generating real tensors based on the fake tensors in the model.

Limitation:
1. trace_only onnxscript function is not supported due to lack of param_schema.
2. The ops with dim/indices (INT64) is not supported that they need the information(shape) from other input args.

[ghstack-poisoned]
titaiwangms added a commit that referenced this pull request Mar 29, 2023
ghstack-source-id: f0cd543
Pull Request resolved: #97494
@titaiwangms titaiwangms requested a review from justinchuby March 29, 2023 19:01
@titaiwangms
Copy link
Collaborator Author

Had CI fail on:
worker 'gw1' crashed while running 'test/onnx/test_fx_to_onnx_with_onnxruntime.py::TestFxToOnnxWithOnnxRuntime_op_level_debug_False_dynamic_shapes_True::test_flatten_dynamic_axes'

Not sure it's on the machine or the test...

Fixes #97728 
Fixes microsoft/onnxscript#393

Provide op_level_debug in exporter which creates randomnied torch.Tensor based on FakeTensorProp real shape as inputs of both torch ops and ONNX symbolic function. The PR leverages on Transformer class to create a new fx.Graph, but shares the same Module with the original one to save memory.

The test is different from [op_correctness_test.py](https://github.com/microsoft/onnx-script/blob/main/onnxscript/tests/function_libs/torch_aten/ops_correctness_test.py) as op_level_debug generating real tensors based on the fake tensors in the model.

Limitation:
1. Some of the trace_only function is not supported due to lack of param_schema which leads to arg/kwargs wronly split and ndarray wrapping. (WARNINGS in SARIF)
2. The ops with dim/indices (INT64) is not supported that they need the information(shape) from other input args.  (WARNINGS in SARIF)
3. sym_size and built-in ops are not supported. 
4. op_level_debug only labels results in SARIF. It doesn't stop exporter.
5. Introduce ONNX owning FakeTensorProp supports int/float/bool
6. parametrized op_level_debug and dynamic_shapes into FX tests

[ghstack-poisoned]
@justinchuby
Copy link
Collaborator

Most likely because of ORT. This may be useful: microsoft/onnxscript#602

@titaiwangms titaiwangms added the ciflow/trunk Trigger trunk jobs on your pull request label Apr 7, 2023
DynamicSliceExportMod(),
(x,),
additional_test_inputs=[(y,)],
)

def test_mutation(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please do me a favor and skip this one for dynamic too #98622 🤣

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmmm The one reported is actually not dynamic. I will skip the whole test in this PR, and put skip_ORT_version on it in the next PR.

Fixes #97728 
Fixes #98622 
Fixes microsoft/onnxscript#393

Provide op_level_debug in exporter which creates randomnied torch.Tensor based on FakeTensorProp real shape as inputs of both torch ops and ONNX symbolic function. The PR leverages on Transformer class to create a new fx.Graph, but shares the same Module with the original one to save memory.

The test is different from [op_correctness_test.py](https://github.com/microsoft/onnx-script/blob/main/onnxscript/tests/function_libs/torch_aten/ops_correctness_test.py) as op_level_debug generating real tensors based on the fake tensors in the model.

Limitation:
1. Some of the trace_only function is not supported due to lack of param_schema which leads to arg/kwargs wronly split and ndarray wrapping. (WARNINGS in SARIF)
2. The ops with dim/indices (INT64) is not supported that they need the information(shape) from other input args.  (WARNINGS in SARIF)
3. sym_size and built-in ops are not supported. 
4. op_level_debug only labels results in SARIF. It doesn't stop exporter.
5. Introduce ONNX owning FakeTensorProp supports int/float/bool
6. parametrized op_level_debug and dynamic_shapes into FX tests

[ghstack-poisoned]
Fixes #97728 
Fixes #98622 
Fixes microsoft/onnxscript#393

Provide op_level_debug in exporter which creates randomnied torch.Tensor based on FakeTensorProp real shape as inputs of both torch ops and ONNX symbolic function. The PR leverages on Transformer class to create a new fx.Graph, but shares the same Module with the original one to save memory.

The test is different from [op_correctness_test.py](https://github.com/microsoft/onnx-script/blob/main/onnxscript/tests/function_libs/torch_aten/ops_correctness_test.py) as op_level_debug generating real tensors based on the fake tensors in the model.

Limitation:
1. Some of the trace_only function is not supported due to lack of param_schema which leads to arg/kwargs wronly split and ndarray wrapping. (WARNINGS in SARIF)
2. The ops with dim/indices (INT64) is not supported that they need the information(shape) from other input args.  (WARNINGS in SARIF)
3. sym_size and built-in ops are not supported. 
4. op_level_debug only labels results in SARIF. It doesn't stop exporter.
5. Introduce ONNX owning FakeTensorProp supports int/float/bool
6. parametrized op_level_debug and dynamic_shapes into FX tests

[ghstack-poisoned]
@titaiwangms
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

pytorchmergebot pushed a commit to crcrpar/pytorch that referenced this pull request Apr 8, 2023
Fixes pytorch#97728
Fixes pytorch#98622
Fixes microsoft/onnxscript#393

Provide op_level_debug in exporter which creates randomnied torch.Tensor based on FakeTensorProp real shape as inputs of both torch ops and ONNX symbolic function. The PR leverages on Transformer class to create a new fx.Graph, but shares the same Module with the original one to save memory.

The test is different from [op_correctness_test.py](https://github.com/microsoft/onnx-script/blob/main/onnxscript/tests/function_libs/torch_aten/ops_correctness_test.py) as op_level_debug generating real tensors based on the fake tensors in the model.

Limitation:
1. Some of the trace_only function is not supported due to lack of param_schema which leads to arg/kwargs wronly split and ndarray wrapping. (WARNINGS in SARIF)
2. The ops with dim/indices (INT64) is not supported that they need the information(shape) from other input args.  (WARNINGS in SARIF)
3. sym_size and built-in ops are not supported.
4. op_level_debug only labels results in SARIF. It doesn't stop exporter.
5. Introduce ONNX owning FakeTensorProp supports int/float/bool
6. parametrized op_level_debug and dynamic_shapes into FX tests
Pull Request resolved: pytorch#97494
Approved by: https://github.com/justinchuby, https://github.com/BowenBao
skotapati pushed a commit to kulinseth/pytorch that referenced this pull request Apr 10, 2023
Fixes pytorch#97728
Fixes pytorch#98622
Fixes microsoft/onnxscript#393

Provide op_level_debug in exporter which creates randomnied torch.Tensor based on FakeTensorProp real shape as inputs of both torch ops and ONNX symbolic function. The PR leverages on Transformer class to create a new fx.Graph, but shares the same Module with the original one to save memory.

The test is different from [op_correctness_test.py](https://github.com/microsoft/onnx-script/blob/main/onnxscript/tests/function_libs/torch_aten/ops_correctness_test.py) as op_level_debug generating real tensors based on the fake tensors in the model.

Limitation:
1. Some of the trace_only function is not supported due to lack of param_schema which leads to arg/kwargs wronly split and ndarray wrapping. (WARNINGS in SARIF)
2. The ops with dim/indices (INT64) is not supported that they need the information(shape) from other input args.  (WARNINGS in SARIF)
3. sym_size and built-in ops are not supported.
4. op_level_debug only labels results in SARIF. It doesn't stop exporter.
5. Introduce ONNX owning FakeTensorProp supports int/float/bool
6. parametrized op_level_debug and dynamic_shapes into FX tests
Pull Request resolved: pytorch#97494
Approved by: https://github.com/justinchuby, https://github.com/BowenBao
" typing.Sequence[int], torch.Tensor], as [None, None]:"
)
def test_shufflenet_v2_dynamic_axes(self):
model = torchvision.models.shufflenet_v2_x0_5(pretrained=False)
Copy link
Collaborator

Choose a reason for hiding this comment

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

How does this pass CI ... Seems torchvision is not imported from anywhere?

Copy link
Collaborator Author

@titaiwangms titaiwangms Apr 10, 2023

Choose a reason for hiding this comment

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

Isn't this skipped?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

🫢

Copy link
Collaborator

Choose a reason for hiding this comment

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

no worries, I'm adding a skip decorator for torchvision if uninstalled in the other PR

@@ -40,6 +40,22 @@ def export_fx_to_onnx(
# Remove them since ONNX inference does not need them.
module = passes.RemoveInputMutation(module).run(*fx_module_args)

# ONNX does not support views and mutations.
Copy link
Collaborator

Choose a reason for hiding this comment

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

🤣

titaiwangms added a commit that referenced this pull request Apr 10, 2023
…alue into the original gm"


From #97494 (comment), the passes should modify gm inplace, but before this PR, `ShapeInferenceWithFakeTensor` utilizes Transform.transform() to make a copy of the gm, and rely on the assumption that the topological order of two graphs should be the same. This PR addresses the issue by saving another metavalue `static_shape` into gm for op_level_debug, instead of overwriting `val`.

cc BowenBao 

[ghstack-poisoned]
titaiwangms added a commit that referenced this pull request Apr 10, 2023
…alue into the original gm"


From #97494 (comment), the passes should modify gm inplace, but before this PR, `ShapeInferenceWithFakeTensor` utilizes Transform.transform() to make a copy of the gm, and rely on the assumption that the topological order of two graphs should be the same. This PR addresses the issue by saving another metavalue `static_shape` into gm for op_level_debug, instead of overwriting `val`.

cc BowenBao 

[ghstack-poisoned]
titaiwangms added a commit that referenced this pull request Apr 13, 2023
…or to fill metavalue into the original gm"


From #97494 (comment), the passes should modify gm inplace, but before this PR, `ShapeInferenceWithFakeTensor` utilizes Transform.transform() to make a copy of the gm, and rely on the assumption that the topological order of two graphs should be the same. This PR addresses the issue by saving another metavalue `static_shape` into gm for op_level_debug, instead of overwriting `val`.

cc BowenBao 

[ghstack-poisoned]
titaiwangms added a commit that referenced this pull request Apr 13, 2023
…alue into the original gm"


From #97494 (comment), the passes should modify gm inplace, but before this PR, `ShapeInferenceWithFakeTensor` utilizes Transform.transform() to make a copy of the gm, and rely on the assumption that the topological order of two graphs should be the same. This PR addresses the issue by saving another metavalue `static_shape` into gm for op_level_debug, instead of overwriting `val`.

cc BowenBao 

[ghstack-poisoned]
pytorchmergebot pushed a commit that referenced this pull request Apr 13, 2023
…he original gm (#98760)

From #97494 (comment), the passes should modify gm inplace, but before this PR, `ShapeInferenceWithFakeTensor` utilizes Transform.transform() to make a copy of the gm, and rely on the assumption that the topological order of two graphs should be the same. This PR addresses the issue by saving another metavalue `static_shape` into gm for op_level_debug, instead of overwriting `val`.

Pull Request resolved: #98760
Approved by: https://github.com/BowenBao
airen3339 pushed a commit to airen3339/pytorch that referenced this pull request Apr 19, 2023
ghstack-source-id: 350aa06
Pull Request resolved: pytorch/pytorch#97494
@facebook-github-bot facebook-github-bot deleted the gh/AllenTiTaiWang/49/head branch June 8, 2023 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk Trigger trunk jobs on your pull request Merged merging module: onnx Related to torch.onnx open source release notes: onnx torch.onnx related changes that should show up in the release notes topic: bug fixes topic category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants