Repository navigation
fix(paro): trace the biased CPU int4pack path after an eager warmup (#5332) - #5350
Merged
Merged
Conversation
…5332) `ParoLinear` declares `INDUCTOR` for CPU, and the repo's own probe checks it with `fullgraph=True`. That held only when the layer was compiled before its first eager forward: the warmup materializes the ATen int4pack layout, and `_forward_cpu_aten` then returned `None` for any biased FP16/BF16 layer, so `_forward_dense` raised instead of tracing. The guard predates #5110, which turned the #4068 operand cast into a registered custom op (`gptqmodel::int4pack_mm_cast`). A biased layer already asks for the FP32 product (`out_dtype=torch.float32`) and adds the bias afterwards, so the only blocker was the stale `self.bias is not None` check. Remove it; the layout and runtime-dtype checks still gate the traced path. Measured on aarch64, torch 2.11 (no AVX512-BF16, so the ATen layout is live): eager warmup -> `torch.compile(fullgraph=True)` compiles for FP16 and BF16 with max abs diff 0.0 against eager; before the change both raised `Unsupported` / the dense-restore `RuntimeError`. Also update the two stale comments that documented the biased ATen case as an eager-only break.
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.
Summary
ParoLineardeclaresCOMPILE_LEVEL.INDUCTORfor CPU and the repo's owncompile-level probe checks that declaration with
fullgraph=True. Thedeclaration only held when the layer was compiled before its first eager
forward.
An eager forward materializes the ATen int4pack layout (
_live_cpu_layout() == "aten"). Undertorch.compile,_forward_cpu_atenthen returnedNoneforevery biased FP16/BF16 layer, so the forward fell through to
_forward_dense, whose layout restore cannot be traced, and raised:Fixes #5332.
What Changed
gptqmodel/nn_modules/qlinear/paro.py: drop theor self.bias is not Noneclause from the compile-time guard in
_forward_cpu_aten. The clausepredates [TEST] #5070 declares base INDUCTOR for TorchFused/TorchAten (GPTQ+AWQ) and GGUFTorchLinear: 3 compile-level tests red on every GPU host; bf16 (CPU AUTO dtype) and biased layers never reach inductor #5110, which turned the [BUG] Follow-up on #4060/#4062: model.optimize() TypeError on all CPU AUTO kernels, torch.compile int4pack LoweringException for fp16+bias (regression) and bf16, max_memory still ignored with device="cuda:0" #4068 operand cast into the registered
custom op
gptqmodel::int4pack_mm_cast; a biased layer already requestsout_dtype=torch.float32and adds the bias afterwards(
(out.float() + bias.float()).to(x.dtype)), so the whole branch traces.The layout and runtime-dtype checks still gate the traced path.
eager-only break now describe the traced behavior; the remaining
_forward_densecompile error message no longer blames bias.tests/kernels/test_kernel_compile_levels_cpu.py: newtest_paro_biased_layer_compiles_after_an_eager_warmup[bf16|fp16](eager warmup →
torch.compile(fullgraph=True)→ compare with eager). Itskips if the AVX512-BF16 kernel takes the layer, which is the only host
where the ATen layout is not built.
No API or behavior change for eager calls: the same
_cpu_int4pack_mmcallwith the same
out_dtyperuns, and the compiled output is bit-identical toeager (max abs diff
0.0).Tests
Environment: aarch64 GB10,
torch 2.11.0+cu130,transformers 5.17.0; thehost has no AVX512-BF16, so the ATen int4pack layout is the live CPU layout.
Negative control (same test with only
paro.pyreverted):Issue reproduction script (eager →
torch._dynamo.reset()→fullgraph=True),before/after:
tests/test_paro.py -m "not gpu"reports23 failed, 221 passedon this hostboth here and on pristine
main@5470d9d40: the fused-kernel selectionsneed a CUDA toolkit (
CUDA_HOMEis unset) and fail identically on the base, sothey are unrelated to this change.
Model Support / Module Plan
Not applicable: no model definitions,
MODEL_MAPentries, or module planschange.
Logic Flow Documentation
The change removes one condition from the CPU dispatch guard; the documented
flow is unchanged otherwise.
flowchart TD A["ParoLinear.forward (CPU, FP16/BF16)"] --> B{"_forward_cpu_aten<br/>compiling?"} B -- "layout != aten" --> D["_forward_dense"] B -- "runtime dtype mismatch" --> D B -- "bias is not None (removed, #5332)" --> D B -- "layout == aten and dtype matches" --> C["_cpu_int4pack_mm<br/>out_dtype=FP32 when biased"] C --> E["(out.float() + bias.float()).to(dtype)"] E --> F["traced inductor graph"] D --> G["RuntimeError: no traceable fused path"] style G fill:#f8d7da,stroke:#b02a37 style F fill:#d9f2d9,stroke:#2e7d32Before: a warmup-built
atenlayout sent every biased layer toG. After:it takes
C/E/F. Nodocs/page change: the class-level comment inparo.pyis the reference for this guard, and no other mechanism is replaced.Review Requirements
Kernel Accuracy Requirements
No kernel math changes. The compiled path runs the same
_cpu_int4pack_mm(..., out_dtype=torch.float32)call as eager and adds thebias in FP32; the new test asserts the compiled output matches eager
(
atol=2e-2, rtol=1e-2, measured0.0). No CUDA path is touched.Notes
fullgraph=Falsedefault already worked (dynamo graph-broke and ran thelayer eagerly), so the visible impact is limited to
fullgraph=Truecallersand to the declared level; those layers also lose a graph break per
projection.
new test skips on such hosts instead of silently passing.