-
Notifications
You must be signed in to change notification settings - Fork 25.6k
[quant][graphmode] Test JIT tracing for dynamic quant cases #40040
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
Summary: Test Plan: python test/test_quantization.py TestQuantizeDynamicScriptJitPasses Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
if tracing_mode: | ||
x = torch.randn(5, 5) | ||
model = torch.jit.trace(eager_model, x) | ||
else: | ||
model = torch.jit.script(eager_model) |
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.
we have a utility function for this: get_script_module
. please take a look at other tests in the file.
.check("quantized::linear_dynamic") \ | ||
.run(model.graph) | ||
eager_model = M().eval() | ||
for tracing_mode in [True, False]: |
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.
nit: suggest to use tracing
for the name to align with other tests in the file
Summary: Test Plan: python test/test_quantization.py TestQuantizeDynamicScriptJitPasses Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
💊 CI failures summary and remediationsAs of commit 873131a (more details on the Dr. CI page):
🕵️ 1 new failure recognized by patternsThe following CI failures do not appear to be due to upstream breakages:
|
qconfig_dict = {'' : default_dynamic_qconfig} | ||
model = quantize_dynamic_script(model, qconfig_dict) | ||
# add op is not dynamically quantized. | ||
FileCheck().check("aten::add") \ |
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.
can you use _test_op_impl
? It is in TestQuantizeScriptPTSQOps, but you can move it to QuantizationTestCase
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.
Sure. That currently only tests quantize_script
API. I'll make it generic.
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.
or maybe define a _test_op_impl
locally for this test
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.
@jerryzh168 refactored it a bit to make it usable by both.
Summary: Test Plan: python test/test_quantization.py TestQuantizeDynamicScriptJitPasses Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
FileCheck().check("aten::add") \ | ||
.check("quantized::linear_dynamic") \ | ||
.run(model.graph) | ||
eager_model = M().eval() |
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.
btw, eval_mode
is an argument of checkGraphModeOp
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.
LG, thanks!
Summary: Test Plan: python test/test_quantization.py TestQuantizeDynamicScriptJitPasses Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
Summary: Test Plan: python test/test_quantization.py TestQuantizeDynamicScriptJitPasses Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D22071277](https://our.internmc.facebook.com/intern/diff/D22071277) [ghstack-poisoned]
This pull request has been merged in fa4244d. |
…40040) Summary: Pull Request resolved: pytorch#40040 Test Plan: python test/test_quantization.py TestQuantizeDynamicScriptJitPasses Imported from OSS Differential Revision: D22071277 fbshipit-source-id: e8aa8637e6364092b6ff1c3a48dfc4551eb645ec
Stack from ghstack:
Summary:
Test Plan:
python test/test_quantization.py TestQuantizeDynamicScriptJitPasses
Reviewers:
Subscribers:
Tasks:
Tags:
Differential Revision: D22071277