-
Notifications
You must be signed in to change notification settings - Fork 293
[Inductor] Support scaled mm on inductor #2411
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
base: main
Are you sure you want to change the base?
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/2411
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 0c7f8ea with merge base 8b57afe ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
test/float8/test_compile.py
Outdated
@@ -392,5 +392,59 @@ def test_dynamic_scale_numeric_parity( | |||
assert torch.equal(float8_eager._data, float8_compile._data) | |||
|
|||
|
|||
@pytest.mark.parametrize( |
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 believe this is the training float8 test file, float8 inference is using https://github.com/pytorch/ao/blob/main/test/dtypes/test_affine_quantized_float.py
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 believe this is the training float8 test file, float8 inference is using https://github.com/pytorch/ao/blob/main/test/dtypes/test_affine_quantized_float.py
Ok. I change the ut path on last pr #2379
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.
LGTM. nit: This PR adds a fusion pass for fp8 q-dq-linear, not scaled_mm. scaled_mm is the fusion result. Please update the PR title.
@parametrize("dtype", [torch.float32, torch.bfloat16]) | ||
@parametrize("input_dim_exceeds_two", [True, False]) | ||
@parametrize("check_reuse_input", [True, False]) | ||
def test_scaled_mm(self, has_bias, dtype, input_dim_exceeds_two, check_reuse_input): |
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.
It would be better to call it test_fp8_qlinear
return dequant_fp8_linear_bias_pattern, dequant_fp8_linear_no_bias_pattern | ||
|
||
|
||
def _is_valid_scaled_mm_pattern(dtype, input_dim_exceeds_two): |
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.
The pattern is fp8 qlinear, not scaled_mm
. scaled_mm
is the fusion result. So, better we call it fp8_qlinear_pattern
return _inner | ||
|
||
|
||
def _register_scaled_mm_pass(pattern, dtype, input_dim_exceeds_two): |
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.
Same here. scaled_mm -> fp8_qlinear.
counters["inductor"]["scaled_mm_matcher_nodes"] += len(match.nodes) | ||
|
||
|
||
def _register_scaled_mm(): |
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.
Same here. scaled_mm -> fp8_qlinear.
Add fp8 dequant promotion
Fuse following pattern to scaled_mm