-
Notifications
You must be signed in to change notification settings - Fork 25.5k
[ONNX] Update 'Functionalize' pass to support pre-decomp graph; Drop 'aten_graph' arg for 'DynamoExporter' #99667
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
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/99667
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ✅ No FailuresAs of commit 3fc55a6: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Summary - Previously this was required by `tracing_mode=symbolic` for `dynamic` tracing. That argument will be dropped by #99555. - Later decomposition pass will do graph lowering, so this step is duplicated. - Functionalization currently cannot work properly on aten level graph. So it must happen before lowering & decompositions. [ghstack-poisoned]
Summary - Previously this was required by `tracing_mode=symbolic` for `dynamic` tracing. That argument will be dropped by #99555. - Later decomposition pass will do graph lowering, so this step is duplicated. - Functionalization currently cannot work properly on aten level graph. So it must happen before lowering & decompositions. - Introduce `ReplaceInplacePostFunctionalization` pass to replace inplace variant ops with outplace version. These ops are created by aten graph lowering and decomposition post functionalization. They won't be doing any real mutation as it is expected to have been handled by functionalization. Workaround to unblock #99662. [ghstack-poisoned]
Summary - Previously this was required by `tracing_mode=symbolic` for `dynamic` tracing. That argument will be dropped by #99555. - Later decomposition pass will do graph lowering, so this step is duplicated. - Functionalization currently cannot work properly on aten level graph. So it must happen before lowering & decompositions. - Introduce `ReplaceInplacePostFunctionalization` pass to replace inplace variant ops with outplace version. These ops are created by aten graph lowering and decomposition post functionalization. They won't be doing any real mutation as it is expected to have been handled by functionalization. Workaround to unblock #99662. [ghstack-poisoned]
…] Drop 'aten_graph' arg for 'DynamoExporter'" Summary - Previously this was required by `tracing_mode=symbolic` for `dynamic` tracing. That argument will be dropped by #99555. - Later decomposition pass will do graph lowering, so this step is duplicated. - Functionalization currently cannot work properly on aten level graph. So it must happen before lowering & decompositions. - Introduce `ReplaceInplacePostFunctionalization` pass to replace inplace variant ops with outplace version. These ops are created by aten graph lowering and decomposition post functionalization. They won't be doing any real mutation as it is expected to have been handled by functionalization. Workaround to unblock #99662. [ghstack-poisoned]
…h' arg for 'DynamoExporter'" Summary - Previously this was required by `tracing_mode=symbolic` for `dynamic` tracing. That argument will be dropped by #99555. - Later decomposition pass will do graph lowering, so this step is duplicated. - Functionalization currently cannot work properly on aten level graph. So it must happen before lowering & decompositions. - Introduce `ReplaceInplacePostFunctionalization` pass to replace inplace variant ops with outplace version. These ops are created by aten graph lowering and decomposition post functionalization. They won't be doing any real mutation as it is expected to have been handled by functionalization. Workaround to unblock #99662. [ghstack-poisoned]
…orkaround in 'Functionalize' pass" Summary - Previously this was required by and entangled with `tracing_mode=symbolic` for `dynamic` tracing. That is resolved by #99555 and its follow ups. - Later decomposition pass will do graph lowering, so this step is duplicated. - Updated `Functionalization` to workaround #99774 (comment) Todo - Training vs eval in dynamo_export So we are effectively exporting all models in traning mode by default. But for the sake of this export we are only interested in eval mode. The question is, should we call `model.eval()` in `dynamo_export`? Tests with model containing batch norm fails 'functionalization' in training mode. We are explicitly calling `model.eval()` for these model for now. - Merge decomp and functionalize pass. Both calls into `make_fx`. Merging potentially increases performance. However it is unclear if it will result in different behavior. Workaround to unblock #99662. [ghstack-poisoned]
…orkaround in 'Functionalize' pass" Summary - Previously this was required by and entangled with `tracing_mode=symbolic` for `dynamic` tracing. That is resolved by #99555 and its follow ups. - Later decomposition pass will do graph lowering, so this step is duplicated. - Updated `Functionalization` to workaround #99774 (comment) Todo - Training vs eval in dynamo_export So we are effectively exporting all models in traning mode by default. But for the sake of this export we are only interested in eval mode. The question is, should we call `model.eval()` in `dynamo_export`? Tests with model containing batch norm fails 'functionalization' in training mode. We are explicitly calling `model.eval()` for these model for now. - Merge decomp and functionalize pass. Both calls into `make_fx`. Merging potentially increases performance. However it is unclear if it will result in different behavior. Workaround to unblock #99662. [ghstack-poisoned]
…orkaround in 'Functionalize' pass" Summary - Previously this was required by and entangled with `tracing_mode=symbolic` for `dynamic` tracing. That is resolved by #99555 and its follow ups. - Later decomposition pass will do graph lowering, so this step is duplicated. - Updated `Functionalization` to workaround #99774 (comment) Todo - Training vs eval in dynamo_export So we are effectively exporting all models in traning mode by default. But for the sake of this export we are only interested in eval mode. The question is, should we call `model.eval()` in `dynamo_export`? Tests with model containing batch norm fails 'functionalization' in training mode. We are explicitly calling `model.eval()` for these model for now. - Merge decomp and functionalize pass. Both calls into `make_fx`. Merging potentially increases performance. However it is unclear if it will result in different behavior. Workaround to unblock #99662. [ghstack-poisoned]
Seems getting complicated. You might consider move Functionalization ahead of dropping aten_graph in the title. |
@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 |
for inpt, input_functional in zip(flat_inputs, flat_inputs_functional): | ||
if isinstance(input_functional, torch.Tensor): | ||
torch._sync(input_functional) | ||
inpt_new = torch._from_functional_tensor(input_functional) |
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.
Why is this inpt_new assigned?
Stack from ghstack (oldest at bottom):
Summary
tracing_mode=symbolic
fordynamic
tracing.That is resolved by Delete tracing_mode argument to export #99555 and its follow ups.
Functionalization
to workaround RuntimeError: Cannot call sizes() on tensor with symbolic sizes/strides w/dynamo.export
,make_fx
andfunctionalize
#99774 (comment)Todo
So we are effectively exporting all models in traning mode by
default. But for the sake of this export we are only interested in eval mode.
The question is, should we call
model.eval()
indynamo_export
?Tests with model containing batch norm fails 'functionalization' in training mode.
We are explicitly calling
model.eval()
for these model for now.make_fx
.Merging potentially increases performance. However it is unclear
if it will result in different behavior.
Fixes #99662. (For the functionalization issue. Still need missing op support.)