Fix FLCE torch.compile failure from aten.addmm.dtype_out overload - #1328
Open
yashb98 wants to merge 1 commit into
Open
Fix FLCE torch.compile failure from aten.addmm.dtype_out overload#1328yashb98 wants to merge 1 commit into
yashb98 wants to merge 1 commit into
Conversation
yashb98
force-pushed
the
flce-compile-addmm-guard
branch
from
July 31, 2026 23:40
8d68fd4 to
4c78b9d
Compare
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 #1327.
FLCE's grad_weight fast path calls
torch.addmm(..., out_dtype=torch.float32, out=...), which dispatches toaten.addmm.dtype_out. TorchInductor cannot lower that overload yet (the Tier-2 fix, pytorch/pytorch#190936, is still open), so anytorch.compile'd FLCE backward with bf16/fp16 inputs andaccum_dtype=torch.float32dies at lowering time with:This PR gates the fast path on
not torch.compiler.is_compiling(). Undertorch.compilethe backward takes the existing generic matmul path, which Inductor lowers fine; eager mode is unchanged and keeps the fusedaddmmaccumulation. When the PyTorch-side fix lands this guard can be revisited.Details
fused_linear_cross_entropy_forward; no behavioural change outsidetorch.compile.test_torch_compile_fp32_accum_backward: compiles FLCE with bf16 operands +accum_dtype=torch.float32, runs backward, and checks loss / grad_x / grad_w against eager. It fails on current main with the exacttuned_addmm()signature from the issue and passes with this change.Testing Done
Reproduced the issue on current main (9ac26bb) with the script from #1327 before changing anything:
After the change:
Result: NOT REPRODUCED(compiled backward completes).test/transformers/test_fused_linear_cross_entropy.py: 142 passed (was 141 + the new regression test)New test, unpatched main: fails with the
tuned_addmm()error aboveNew test, with this change: passes
Full unit suite (
pytest --ignore=test/convergence test/), patched: 3916 passed, 2 failed — the 2 failures aretest_grpo_loss_vs_trl[...-luspo-sequence-1.5], and the identical 2 fail on unpatched main in the same full-suite run (3915 passed, 2 failed). They pass in isolation in both arms and live ingrpo_loss, which this change does not touch: a pre-existing, order-dependent flake.ruff checkandruff format --checkon both touched files: cleanHardware Type: NVIDIA GB10 (DGX Spark, sm_121, aarch64)
run
make testto ensure correctnessrun
make checkstyleto ensure code stylerun
make test-convergenceto ensure convergenceOne honest caveat: I did not run
make test-convergence(model-scale convergence runs); the change only reroutes an existing eager path under compilation, so convergence behaviour is unaffected in eager and the compiled path is checked against eager in the new test.Benchmarks
GB10 (DGX Spark, sm_121), torch 2.13.0+cu130, bf16 operands with fp32 accumulation (the affected configuration), forward + backward, median of 8 runs after 3 warmup. Branch is rebased on current main (91ae44a).
Two takeaways: eager is unchanged (parity within noise, as expected since the guard only fires under compilation), and the compiled path this PR unblocks is not merely working but about 1.5x faster than eager on both shapes. The unpatched compiled run still fails with the exact
tuned_addmm()LoweringException from the issue, re-confirmed on main at 91ae44a today.