Fix FLCE torch.compile failure from aten.addmm.dtype_out overload - #1328
Fix FLCE torch.compile failure from aten.addmm.dtype_out overload#1328yashb98 wants to merge 1 commit into
Conversation
8d68fd4 to
4c78b9d
Compare
|
CI has never run on this PR, all four workflows have been sitting at In the meantime, here is a before/after against current Unpatched Same tree plus the one line from this PR: Whole file: One thing that may be worth recording in the issue: on torch 2.11.0+cu130 the same test fails earlier and differently, in Dynamo rather than in Inductor lowering, with The branch shows as behind by 3 commits, but neither file it touches is among the files those commits changed, and the runs above are on |
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.