Skip to content

Studio diffusion training: give int8 bases the budgeted dequant cache (exact, +7.4% with spare memory) - #18451

Merged
danielhanchen merged 3 commits into
mainfrom
studio-train-int8-dequant-cache-pr
Nov 20, 2026
Merged

danielhanchen merged 3 commits into
mainfrom
studio-train-int8-dequant-cache-pr

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

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:

Results

cell card change
FLUX.3 klein base, int8, 512 px, memory to spare Colab L4 +7.4%
FLUX.3 klein base, int8, in Auto's tight int8 band (16 GB simulated) Colab L4 +0.3 to 0.6%, inside the noise; peak memory +0.1 to 0.17 GB
FLUX.3 klein base, int8, 1024 px Colab L4 under 1%

Tests

  • tests/test_diffusion_int8_dequant_cache.py is 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.
  • With the checkpointing-budget and trainer suites on current main: 146 passed.

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.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T10:06:59.979452Z b7776e5 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: 🔄 Running

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-11-19T10:04:43.872532Z b7776e5 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: b7776e5579

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@danielhanchen
danielhanchen merged commit 2818609 into main Nov 20, 2026
@danielhanchen
danielhanchen deleted the studio-train-int8-dequant-cache-pr branch November 20, 2026 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant