-
Notifications
You must be signed in to change notification settings - Fork 169
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
Add module-swap UX for INT8 mixed-precision training #1179
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/1179
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New FailureAs of commit ca8c85a with merge base f99b667 (): NEW FAILURE - The following job has failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
You can still use tensor subclass inside of your module swap to interact with FSDP and TP/SP and get low precision all_gather. See |
The way I see it is that, whatever can be done with module swap, can be done with tensor subclass. (maybe it's better to hold persistent states with modules? like for delayed scaling. But at least for my use cases, I don't need persistent states). So using both module swap + tensor subclass feels redundant to me. |
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
* add module swap UX * update * fix typing. add small notes * try NF4 support * fix * fix unpacking * fix * update nf4 integration * update backward pass
Background
The current INT8 mixed-precision training recipe conceptually is an op-modifier -
torch.matmul
is replaced withdynamic_int8_mm
. It is implemented with tensor subclass, though it doesn't use any tensor subclass-specific features, such as quantized storage and quantized FSDP all-gather. Having an alternative module-swap UX would have the following benefits:Usage
Benchmarks
Pre-train Llama2-1B on 4070Ti SUPER. torch==2.6.0.dev20241029. No regression. Module swap has the same perf as tensor subclass
Pre-train Llama3-8B with torchtitan, 2x A100, torch==2.6.0.dev20241104+cu124. No regression. Module swap has the same perf as tensor subclass
Fine-tune Llama3-1B QLoRA with torchtune (using pytorch/torchtune@main...gau-nernst:qlora)