-
Notifications
You must be signed in to change notification settings - Fork 25.7k
[quant][pt2] Preserve source_fn_stack after QAT fusion #110899
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
Test Plan: python test/test_quantization.py TestQuantizePT2EQAT.test_qat_preserve_source_fn_stack Reviewers: jerryzh168, kimishpatel Subscribers: jerryzh168, kimishpatel, supriyar [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/110899
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 3341aef with merge base 201d02e ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Test Plan: python test/test_quantization.py TestQuantizePT2EQAT.test_qat_preserve_source_fn_stack Reviewers: jerryzh168, kimishpatel Subscribers: jerryzh168, kimishpatel, supriyar [ghstack-poisoned]
Test Plan: python test/test_quantization.py TestQuantizePT2EQAT.test_qat_preserve_source_fn_stack Reviewers: jerryzh168, kimishpatel Subscribers: jerryzh168, kimishpatel, supriyar [ghstack-poisoned]
Test Plan: python test/test_quantization.py TestQuantizePT2EQAT.test_qat_preserve_source_fn_stack Reviewers: jerryzh168, kimishpatel Subscribers: jerryzh168, kimishpatel, supriyar [ghstack-poisoned]
|
@andrewor14 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
| ( | ||
| replacement_conv_node, | ||
| replacement_bn_node, | ||
| replacement_getitem_node, | ||
| replacement_relu_node, | ||
| ) = _get_conv_bn_getitem_nodes(r.replacements) |
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 guess this is for identifying the nodes, I feel #110743 should help
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.
Ok, let's do that in the future
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.
maybe we can extend #110743 to work with subgraph rewriter and query node by name
Test Plan: python test/test_quantization.py TestQuantizePT2EQAT.test_qat_preserve_source_fn_stack Reviewers: jerryzh168, kimishpatel Subscribers: jerryzh168, kimishpatel, supriyar Differential Revision: [D50101253](https://our.internmc.facebook.com/intern/diff/D50101253) [ghstack-poisoned]
Test Plan: python test/test_quantization.py TestQuantizePT2EQAT.test_qat_preserve_source_fn_stack Reviewers: jerryzh168, kimishpatel Subscribers: jerryzh168, kimishpatel, supriyar Differential Revision: [D50101253](https://our.internmc.facebook.com/intern/diff/D50101253) [ghstack-poisoned]
|
@andrewor14 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Test Plan: python test/test_quantization.py TestQuantizePT2EQAT.test_qat_preserve_source_fn_stack Reviewers: jerryzh168, kimishpatel Subscribers: jerryzh168, kimishpatel, supriyar Differential Revision: [D50101253](https://our.internmc.facebook.com/intern/diff/D50101253) [ghstack-poisoned]
|
@andrewor14 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Test Plan: python test/test_quantization.py TestQuantizePT2EQAT.test_qat_preserve_source_fn_stack Reviewers: jerryzh168, kimishpatel Subscribers: jerryzh168, kimishpatel, supriyar Differential Revision: [D50101253](https://our.internmc.facebook.com/intern/diff/D50101253) [ghstack-poisoned]
|
@andrewor14 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
@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 |
| return (q_node, dq_node) | ||
|
|
||
| def _get_conv_bn_getitem_nodes(nodes: List[Node]) -> Tuple[Node, Node, Node]: | ||
| def _get_conv_bn_getitem_nodes(nodes: List[Node]) -> Tuple[Node, Node, Node, Optional[Node]]: |
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.
should also be renamed to _get_conv_bn_getitem_relu_nodes
| replacement_relu_node, | ||
| ) = _get_conv_bn_getitem_nodes(r.replacements) | ||
|
|
||
| for original_node in _filter_nodes_map(r.nodes_map).values(): |
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.
Andrew, why do you need to copy the metadata?
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.
This is for lowering models trained by QAT. We found that the source_fn was not preserved and all convs in the model ended up being in the same partition conv2d, but they should be in different partitions
Stack from ghstack (oldest at bottom):
Test Plan:
python test/test_quantization.py TestQuantizePT2EQAT.test_qat_preserve_source_fn_stack
Reviewers: jerryzh168, kimishpatel
Subscribers: jerryzh168, kimishpatel, supriyar
Differential Revision: D50101253