-
Notifications
You must be signed in to change notification settings - Fork 390
[mxfp8 training] use triton kernel for dim0 scaling with RCEIL rounding #3568
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
a2504fe to
89e73d2
Compare
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/3568
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: ❌ 4 New FailuresAs of commit cf0acd8 with merge base 8d47813 ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
stack-info: PR: #3568, branch: danielvegamyhre/stack/101
|
what do benchmarks look like |
stack-info: PR: #3568, branch: danielvegamyhre/stack/101
89e73d2 to
cf0acd8
Compare
Updated PR description with benchmarks, they are better |
that looks good for no-fusion, do we have metrics on what this looks like with layer fusion? The script has a flag to enable it, or you could use LLaMa 3 8B in torchtitan. |
| input_hp_r = input_hp.reshape(-1, input_orig_shape[-1]) | ||
|
|
||
| input_mx_r_dim0 = MXTensor.to_mx( | ||
| input_mx_r_dim0 = _to_mxfp8_dim0( |
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.
IMO we should ensure the codebase stays consistent with how the various config flags are used. Before this PR, mxfp8_cast_kernel_choice controls the dim1 cast. I think good options are:
- make
mxfp8_cast_kernel_choicecontrol dim1 and dim0 casts (update names/docs as needed) - or, make a separate
mxfp8_cast_kernel_choicething for dim0, update names as needed - or, just delete all the configs and make the logic use custom kernels
The current PR is a bit confusing given the rest of the feature because it leaves the dim1 config as is but defaults the dim0 logic to a custom kernel.
I don't really like Option 3 because we should be able to quickly test compile, so Option 1 or Option 2 would sound good to me.
| Uses Triton kernel for RCEIL scaling mode for better performance, otherwise | ||
| falls back to MXTensor.to_mx(). | ||
| """ | ||
| if scale_calculation_mode == ScaleCalculationMode.RCEIL: |
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 isn't how the dim1 config works, let's make sure all of these flags operate in a consistent way. You can change the dim1 logic if needed (everything is prototype).
Stacked PRs:
Summary
Tests
pytest test/prototype/mx_formats/test_mx_linear.pyBenchmarks (e2e linear sigmoid fwd + bwd)
Command:
python benchmarks/float8/float8_roofline.py --mx_recipe_name="mxfp8_cublas_rceil" --outfile "outfile.csv"Before:
After:
Kernel microbenchmarks
See: https://github.com/pytorch/ao/tree/main/torchao/prototype/mx_formats#quantization-kernel-microbenchmarks