Skip to content

fix(paro): trace the biased CPU int4pack path after an eager warmup (#5332) - #5350

Merged
Qubitium merged 1 commit into
mainfrom
fix/paro-cpu-aten-bias-compile-5332
Nov 19, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/paro-cpu-aten-bias-compile-5332

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Summary

ParoLinear declares COMPILE_LEVEL.INDUCTOR for CPU and the repo's own
compile-level probe checks that declaration with fullgraph=True. The
declaration only held when the layer was compiled before its first eager
forward.

An eager forward materializes the ATen int4pack layout (_live_cpu_layout() == "aten"). Under torch.compile, _forward_cpu_aten then returned None for
every biased FP16/BF16 layer, so the forward fell through to
_forward_dense, whose layout restore cannot be traced, and raised:

RuntimeError: ParoLinear: a CPU runtime layout is live and no traceable fused
path was selected (a biased FP16/BF16 layer needs the #4068 FP32 cast)...

Fixes #5332.

What Changed

No API or behavior change for eager calls: the same _cpu_int4pack_mm call
with the same out_dtype runs, and the compiled output is bit-identical to
eager (max abs diff 0.0).

Tests

Environment: aarch64 GB10, torch 2.11.0+cu130, transformers 5.17.0; the
host has no AVX512-BF16, so the ATen int4pack layout is the live CPU layout.

PYTHONPATH=$PWD GPTQ_BYPASS_SAFETY_CHECKS=1 S=1 python -m pytest -q \
  tests/kernels/test_kernel_compile_levels_cpu.py
# 43 passed, 5 skipped

PYTHONPATH=$PWD GPTQ_BYPASS_SAFETY_CHECKS=1 S=1 python -m pytest -q \
  tests/kernels/test_kernel_compile_levels_cpu.py -k "eager_warmup or paro"
# 6 passed, 42 deselected

PYTHONPATH=$PWD GPTQ_BYPASS_SAFETY_CHECKS=1 S=1 python -m pytest -q \
  tests/test_paro_rotation_inference_cache_5317.py
# 3 passed

bash format/check.sh
# ruff 0.14.2 / All checks passed!

Negative control (same test with only paro.py reverted):

FAILED tests/kernels/test_kernel_compile_levels_cpu.py::test_paro_biased_layer_compiles_after_an_eager_warmup[bf16]
FAILED tests/kernels/test_kernel_compile_levels_cpu.py::test_paro_biased_layer_compiles_after_an_eager_warmup[fp16]
2 failed

Issue reproduction script (eager → torch._dynamo.reset() → fullgraph=True),
before/after:

torch.float16 eager ok; live layout: aten
torch.float16 COMPILE FAILED: Unsupported ...
torch.bfloat16 COMPILE FAILED: Unsupported ...
---
torch.float16 compiled ok, max diff 0.0
torch.bfloat16 compiled ok, max diff 0.0

tests/test_paro.py -m "not gpu" reports 23 failed, 221 passed on this host
both here and on pristine main @ 5470d9d40: the fused-kernel selections
need a CUDA toolkit (CUDA_HOME is unset) and fail identically on the base, so
they are unrelated to this change.

  • Unit tests have been executed and passed, or the reason they are not applicable is documented.
  • I added a new simple/fast unit test for this change, or documented why that is not applicable.

Model Support / Module Plan

Not applicable: no model definitions, MODEL_MAP entries, or module plans
change.

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:#2e7d32
Loading

Before: a warmup-built aten layout sent every biased layer to G. After:
it takes C/E/F. No docs/ page change: the class-level comment in
paro.py is the reference for this guard, and no other mechanism is replaced.

Review Requirements

  • Reviewed this PR.
  • Checked that the code matches existing project structure, APIs, and conventions.
  • Avoided unnecessary monkeypatching and used the project's normal extension points where possible.
  • Minimized and compacted the impacted code surface (one condition removed).
  • Considered and eliminated potential regressions (eager math unchanged; output identical).

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 the
bias in FP32; the new test asserts the compiled output matches eager
(atol=2e-2, rtol=1e-2, measured 0.0). No CUDA path is touched.

Notes

  • The fullgraph=False default already worked (dynamo graph-broke and ran the
    layer eagerly), so the visible impact is limited to fullgraph=True callers
    and to the declared level; those layers also lose a graph break per
    projection.
  • Host limitation: the AVX512-BF16 kernel cannot be exercised here, so the
    new test skips on such hosts instead of silently passing.

…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.
@Qubitium
Qubitium marked this pull request as ready for review November 19, 2026 04:11
@Qubitium
Qubitium merged commit a7037f9 into main Nov 19, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/paro-cpu-aten-bias-compile-5332 branch November 19, 2026 04:11
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.

[BUG] Paro CPU declares INDUCTOR, but fullgraph compile after an eager warmup raises for biased FP16/BF16 layers on the ATen int4pack path (#5075)

1 participant