Repository navigation
Studio diffusion training: give int8 bases the budgeted dequant cache (exact, +7.4% with spare memory) - #18451
Conversation
The cache now also holds the cast int8 weight torchao rebuilds on every int8 weight-only call (q.t().to(dtype), not q * scale), so the GEMM, the per-row scale and the bias add run exactly as torchao runs them and the loss is bit-identical. The first int8 entry is checked against torchao's own forward and any mismatch turns int8 caching off for the run. Entries share the nf4 budget, lend_vram release and rebalancing. UNSLOTH_DIFFUSION_INT8_DEQUANT_CACHE=0 turns the int8 part off.
… to the checkpointing reserve
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Codex Review Summary: 🔄 RunningThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Problem
When Auto (or the user) picks an int8 base for diffusion LoRA training, the frozen int8 layers run eager, because int8 never compiles in training. torchao then rebuilds the bf16 weight on every forward and backward call. nf4 bases already have a budgeted dequant cache for this; int8 bases had none.
Change
The budgeted dequant cache now covers int8 bases too:
lend_vram, the same as nf4.UNSLOTH_DIFFUSION_INT8_DEQUANT_CACHE=0.Results
Tests
tests/test_diffusion_int8_dequant_cache.pyis new, with 13 CPU tests. They pass on torch 2.14 / torchao 0.18 / transformers 5.17, and on torch 2.6 / torchao 0.15 / transformers 4.57.6 / peft 0.18.