Repository navigation
Studio diffusion: Ada FP8 unit-scale dispatcher installs only where it engages, chunked eager scaling - #14665
Conversation
…r fp32 buffer The sm_89 dispatcher installed on every Ada fp8 config and every prequant load (int8 and nvfp4 included), even under the default fast accumulate where it never engages, and installing tags the process-wide torch compile cache key, splitting later compiles' caches. It now installs only for precise or unknown accumulate (or force), reading the checkpoint metadata for prequant loads. The kill switch reads 'none' as off, like the compile-cache key. The eager epilogue formed a full fp32 [M, N] buffer plus a second bf16 output. It now writes back into the bf16 accumulator a row chunk at a time, with the same ops in the same order (bitwise the same output); compiled graphs keep the fused expression. B200 force mode, 4608x3072x18432: 648 -> 226 MiB peak above the inputs (row-wise 162). The stated error bound was 2^-9; bf16 unit roundoff is 2^-8, and it bounds the absolute error only.
|
@codex review |
Codex Review SummaryThis 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: Didn't find any major issues. Keep it up! 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". |
… guard alongside the metadata/fast_accum install gate [skip ci]
|
@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". |
[skip ci]
Summary
Follow-up to #13793 (sm_89 precise-accumulate fp8 via a unit-scale
_scaled_mmand an fp32 scale epilogue). It fixes four problems.install()ran from_make_quant_configfor every fp8 config, and from_load_prequant_checkpointfor every prequant checkpoint, int8 and nvfp4 included. On any Ada host it installed in auto mode even under Studio's default fast accumulate, where the dispatcher never engages. Installing sets the process-widetorch.compiler.config.cache_key_tag, whichenvironment_fingerprintalso adds to the Studio bundle key. So after one fp8 or prequant load, every later compile in the process got a second cache key, a bf16 or GGUF model included. The cost was one extra cold compile per model and load order. It never caused a wrong hit.UNSLOTH_DIFFUSION_FP8_UNIT_SCALE=noneas off, but_mode()read it as auto and installed anyway.acc * a_scale.float()materialized a full fp32[M, N]buffer and then a second bf16 output. That is four times the output size, with no memory admission check.|acc * a_scale * b_scale|. A bias that cancels the product leaves the output's relative error unbounded: an exact dot product of 257 with scale 1/257 and bias -1 gives -0.0039 instead of 0. The PR Studio: run Ada FP8 precise accumulate through a unit-scale GEMM plus a fused scale epilogue #13793 description repeats the 2^-9 figure.Fix
install(fast_accum=...)and a newcan_engage(): in auto mode it no longer installs for a load running fast accumulate. Precise and unknown accumulate still install, and so doesforce._make_quant_config(fp8)passes the resolved accumulate._load_prequant_checkpointreads the checkpoint metadata. int8 checkpoints never install. fp8 baked at fast accumulate (the builder's default) does not install. Precise fp8, nvfp4 (a policy over fp8) and checkpoints with no recorded accumulate install, as before._mode()uses the same off and on words as the compile-cache switch key, sononeis off in both.torch.compilethe fused expression is kept as is.Residual, by design: once a precise-accumulate fp8 model has installed the dispatcher, the tag stays for the rest of the process. That is required for the cache to stay consistent with the patched torchao entry point.
Measured
B200, force mode (
UNSLOTH_DIFFUSION_FP8_UNIT_SCALE=1, so the dispatcher runs off sm_89), eager, precise accumulate, bias on. Values are peak allocation above the inputs.The output checksum is identical between main and this branch on both shapes.
Tests
tests/test_diffusion_fp8_unit_scale.py. Each new test fails on main and passes here:test_auto_never_installs_for_fast_accumulatetest_fp8_quant_config_installs_only_for_precise_accumulatetest_prequant_checkpoint_installs_only_when_its_fp8_layers_can_engage(the int8 and fp8-fast cases; the precise, nvfp4 and unrecorded cases pass on both)test_every_off_word_of_the_compile_cache_key_turns_the_dispatcher_offtest_eager_epilogue_writes_into_the_accumulator_bitwise_as_before(with and without bias): the output aliases the accumulator and is bitwise equal to the old fused expression.The whole file passes, including the GPU test
test_compiled_graph_after_a_cached_rowwise_one_uses_the_dispatcher, so the compiled graph still takes the dispatcher.