Repository navigation
perf(compile): opt FP8 into the static-cache compile and make the bar trace-clean + measured (#4739) - #4754
Merged
Conversation
…ster (#4739) TorchFP8Linear traces clean under fullgraph=True and its compiled static-cache decode is 2.3x faster than eager on sm_121, but #4727 left it opted out, so FP8 static-cache generation silently stayed eager. AwqTorchLinear was the only opt-in, yet tensor_cache_key() calls tensor.is_inference(), a hard dynamo graph break: fullgraph=True fails and compiling it is 20-30% slower. The declaration now requires both halves -- a zero-graph-break fullgraph trace and a measured win -- and each kernel is judged by that bar.
# Conflicts: # docs/generation-compile-policy.md # gptqmodel/nn_modules/qlinear/torch_awq.py
This was referenced Nov 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
#4727 gates transformers' static-cache auto-compile on every quantized linear declaring
SUPPORTS_COMPILE = True, but leftTorchFP8Linearout. FP8 is the format that gains the most from the compile, so an FP8generate(cache_implementation="static")silently ran eager — the exact 4x regression #4669 was supposed to remove.The issue's second half (AWQ graph breaks) has been fixed on
mainsince: #4737 added the decode-range guard, which checkstorch.compiler.is_compiling()beforetensor_cache_key(), sotensor.is_inference()is no longer reached during tracing. Re-measured on currentmain@ebe5558a:AwqTorchLineartraces with 0 graph breaks,fullgraph=Truesucceeds, and the compiled static-cache decode is 3.7x faster (0.174 s -> 0.047 s, 1 graph). Its opt-in is therefore correct and is kept.Fixes #4739.
Changes
TorchFP8Linear.SUPPORTS_COMPILE = True—fullgraph=Truetraces clean (host-visible constants only; the decoded-weight bound is a load-time cache) and the compiled static-cache decode is 2.3-3.4x faster.FP8MlxQuantLinear.SUPPORTS_COMPILE = False— the Metal holder dispatches to native MXFP8 kernels, which were never traced or timed; it must not inherit the Torch opt-in.BaseQuantLinear.SUPPORTS_COMPILEdocstring +docs/generation-compile-policy.md: the bar is now explicitly zero-breakfullgraph=Truetrace AND a measured win, with corrected per-kernel evidence.docs/kernel-compile-matrix.mdregenerated (FP8 compiled generation: no -> yes).tests/test_generation_compile_policy_4669.py: FP8 declaresTrue, AWQ staysTrue, MLX FP8 does not inherit.tests/kernels/test_compile_capability_4739.py: module-level trace-clean + timing for FP8 and AWQ, and a full FP8 model test that the static-cache compile is kept, is deterministic run to run, and beats eager.Evidence (GB10, sm_121, torch 2.15.0+cu132, transformers 5.22.1)
disable_compile=TrueFalse)True)AWQ_TORCHon current maintests/kernels/test_compile_capability_4739.py-> 3 passed (FP8 module: 0 breaks, 2.9x faster; AWQ module: 0 breaks, fullgraph succeeds; full FP8 model: compile kept, 2.3x faster, deterministic).tests/test_generation_compile_policy_4669.py+tests/kernels/test_kernel_compile_protocol.py-> 36 passed, 118 skipped.ruff check gptqmodel docs testsclean.Residual: compiling FP8 changes the reduction order, so a compiled greedy decode can pick a different token from eager on some weights (deterministic run to run;
disable_compile=Truereproduces the dynamic tokens exactly). This is documented in the policy doc and is the same behaviour AWQ already has.