Repository navigation
fix(paro): keep the CPU rotation forward graph-safe (#5115) - #5167
Merged
Merged
Conversation
`ParoLinear` declares `SUPPORTS_COMPILE_LEVEL_BY_DEVICE = {"cpu": INDUCTOR}`,
but only a layer whose rotation is the identity reached it. Every projection of
a real Paro checkpoint broke the graph twice on CPU:
- `_ensure_rotation_runtime_dtype` keyed its cache with `tensor_cache_key`
(`is_inference()`/`_version`/`data_ptr()`) inside the traced region. Under
`torch.compiler.is_compiling()` it now reads the eager-built runtime tensors
(or converts without publishing on a cold trace), so no host key is read.
- `apply_paro_rotation_vectorized` read the padding mask with
`bool(valid.any())`. A fully padded row is a no-op for the code below, so the
early skip stays an eager-only speedup; the traced graph runs the row.
- `_forward_cpu_avx512` resolved the AVX512 JIT handle (importlib + `setattr`)
inside the graph when the eager warmup had not published one, which happens
on hosts without AVX512-BF16. It now falls through to the ATen/dense paths
while compiling, as the eager path already did.
Tests: `test_kernel_compile_levels_cpu.py` gains a non-identity rotation case
for bf16 and fp16 (`_pack_paro_rotated`), which is red on `main` and asserts
the fullgraph trace, the declared level and inductor output parity.
Verified on one NVIDIA GB10 (sm_121, aarch64, torch 2.11.0+cu130):
- a real 2-layer Paro checkpoint (14 rotated `ParoLinear` layers) compiles
every layer with `fullgraph=True, backend="inductor"`; on unmodified `main`
14/14 fail with `is_inference() during tracing`.
- `pytest tests/kernels/test_kernel_compile_levels_cpu.py -k paro` -> 4 passed.
- `tests/test_paro.py` keeps its 23 pre-existing host failures (identical on
baseline); the Paro rotation/rounding/lifecycle suites pass (29 passed).
Qubitium
marked this pull request as ready for review
November 18, 2026 07:18
This was referenced Nov 18, 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.
Summary
Fixes #5115.
ParoLineardeclares CPUINDUCTOR, but only a layer whose rotation is the identity reached it: every projection of a real Paro checkpoint broke the graph twice on CPU.What Changed
_ensure_rotation_runtime_dtypeno longer keys its cache withtensor_cache_key(is_inference()/_version/data_ptr()) inside the traced region. Undertorch.compiler.is_compiling()it reads the eager-built runtime tensors, or converts them without publishing on a cold trace — the same shape as the existing_ensure_cpu_layoutguard.apply_paro_rotation_vectorizedread its padding mask withbool(valid.any()). A fully padded rotation row is a no-op for the code below (every slot keeps its value), so the skip stays an eager-only speedup and the traced graph runs the row._forward_cpu_avx512resolved the AVX512 JIT handle (importlib+setattr) inside the graph whenever the eager warmup had not published one — which is the case on hosts without AVX512-BF16. It now falls through to the ATen/dense paths while compiling, exactly as the eager path already does when the validator fails.No declaration, output or eager-path change.
Tests