Repository navigation
[FlyDSL] [AOT] Fix the Nightly's FlyDSL AOT replay on torch 2.9.1 (#7805 + #7561) - #7892
Conversation
On a torch whose meta_mm takes out_dtype, as CI's 2.10 does, the backport returns before patching anything, so no test entered it and a regression inside it would stay green until a torch 2.9.1 AOT build hit it. The new test replaces meta_mm with torch 2.9.1's two-argument signature and makes the fake rules of mm.dtype and mm.dtype_out fail as they do there, then checks that the dry run answers an FP32 output, with and without out=, and that the failure is back once the dry run exits.
…torch 2.9.1 On torch 2.9.1, Tensor.__setitem__ (like __getitem__, contiguous and copy_) takes a device guard in its own Python binding, before the call reaches the dispatcher and FakeTensorMode. With the GPUs hidden, as replay_env hides them, that guard initializes HIP and raises hipErrorNoDevice. The weights the MoE replay prepares as callers do are assigned through an index: e8m0_shuffle pads every MXFP4 scale with `padded[:m, :n] = src`, shuffle_scale_a16w4 pads a scale whose K/32 is not a multiple of 8 with `padded[:, :k] = src`, and the int4 packing writes `out[:, 0] = ...`. MegaMoEV2 fills its peer pointer table with `table[peer] = ptr`. So the Nightly wheel builds, whose images ship torch 2.9.1, failed 8.7k MoE and all 192 MegaMoE replay jobs. torch 2.10 takes no guard there, which is why CI passes. dry_run now stands in for __setitem__ on FakeTensors under basic indexing: a copy (or fill) into the view getitem answers, through the aten op, since the Tensor.copy_ binding takes the guard too. The test that pads a scale in a process with the GPUs hidden fails only on torch 2.9.1, so a second one simulates the guarded binding and runs the stand-in on CI's torch as well. Co-authored-by: Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]> # Conflicts: # tests/test_flydsl_aot_replay.py
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the host-side PyTorch 2.9.1 dry-run compatibility changes and accompanying regression tests.
No open issues 🎉
What changed in this PR
Combines #7805 and #7561 to address both PyTorch 2.9.1 compatibility failures in FlyDSL’s nightly ahead-of-time replay. The changes are confined to host-side dry-run tooling and its regression tests.
Changes:
- Handles basic-index assignment on CUDA FakeTensors without entering PyTorch bindings that initialize HIP.
- Temporarily supplies missing
torch.mmoutput-dtype metadata support on affected PyTorch versions, restoring the original rules afterward. - Adds regression tests for GPU-hidden assignment, FP32 GEMM outputs, validation errors, and rule restoration.
| File | Description |
|---|---|
tests/test_flydsl_aot_replay.py |
Adds assignment and GEMM compatibility tests, including simulated legacy behavior. |
aiter/aot/flydsl/dry_run.py |
Adds scoped FakeTensor assignment handling and a conditional mm metadata backport. |
Review effort: Balanced
READY FOR HUMAN REVIEWPR Self-ReviewRevision Author self-review accepted. Readiness report: Author answers
Show the author's self-review answersBehavior and intentValidation and unverified scopePR-specific questionChanged op testsPR state
Copilot findings
Code and op-test hygiene
Required CI
Shadow mode reports what would block but keeps the status successful. Set |
+ #7561) (#7892) * [FlyDSL] [AOT] Fix mm out_dtype replay on torch 2.9.1 * Test the mm out_dtype backport against a simulated torch 2.9.1 meta On a torch whose meta_mm takes out_dtype, as CI's 2.10 does, the backport returns before patching anything, so no test entered it and a regression inside it would stay green until a torch 2.9.1 AOT build hit it. The new test replaces meta_mm with torch 2.9.1's two-argument signature and makes the fake rules of mm.dtype and mm.dtype_out fail as they do there, then checks that the dry run answers an FP32 output, with and without out=, and that the failure is back once the dry run exits. * [FlyDSL] [AOT] Assign into FakeTensor slices without reaching HIP on torch 2.9.1 On torch 2.9.1, Tensor.__setitem__ (like __getitem__, contiguous and copy_) takes a device guard in its own Python binding, before the call reaches the dispatcher and FakeTensorMode. With the GPUs hidden, as replay_env hides them, that guard initializes HIP and raises hipErrorNoDevice. The weights the MoE replay prepares as callers do are assigned through an index: e8m0_shuffle pads every MXFP4 scale with `padded[:m, :n] = src`, shuffle_scale_a16w4 pads a scale whose K/32 is not a multiple of 8 with `padded[:, :k] = src`, and the int4 packing writes `out[:, 0] = ...`. MegaMoEV2 fills its peer pointer table with `table[peer] = ptr`. So the Nightly wheel builds, whose images ship torch 2.9.1, failed 8.7k MoE and all 192 MegaMoE replay jobs. torch 2.10 takes no guard there, which is why CI passes. dry_run now stands in for __setitem__ on FakeTensors under basic indexing: a copy (or fill) into the view getitem answers, through the aten op, since the Tensor.copy_ binding takes the guard too. The test that pads a scale in a process with the GPUs hidden fails only on torch 2.9.1, so a second one simulates the guarded binding and runs the stand-in on CI's torch as well. Co-authored-by: Cursor <[email protected]> --------- Co-authored-by: Cursor <[email protected]>
Summary
The Nightly wheel build has failed in
setup.py's FlyDSL AOT step on every run since 2026-10-30. It fails in two different ways, both only on torch 2.9.1: #7805 fixes one and #7561 the other, and either one alone leaves the Nightly red. This PR carries both unchanged on top of current main, so a single squash merge restores the AOT step.Supersedes #7805 and #7561: their commits are included as they are, and both can be closed once this merges.
Motivation
Nightly runs 42950352070 (
02a757f) and 43145799317 (6a80ddd) end with:AcceleratorError: HIP error: no ROCm-capable device is detected. On the Nightly's torch (2.9.1+rocm7.2.0.lw.git7e1940d4),tensor[index] = valueon a CUDA FakeTensor callshipGetDevicein its Python binding before the call reaches the dispatcher, and with the GPUs hidden that call fails. [FlyDSL] [AOT] Assign into FakeTensor slices without reaching HIP on torch 2.9.1 #7805 fixes this.TypeError: meta_mm() takes 2 positional arguments but 3 were given. torch 2.9.1's meta foraten.mm.dtypetakes noout_dtype. [FlyDSL] [AOT] Fix mm out_dtype replay on torch 2.9.1 #7561 fixes this.PR CI builds its wheels with torch 2.10 (
rocm7.2.4 … pytorch_release_2.10.0), where neither failure occurs, so both show up only in the Nightly.Changes
aiter/aot/flydsl/dry_run.py:Tensor.__setitem__stand-in for CUDA FakeTensors under basic indexing, which copies or fills into the view thegetitemstand-in answers throughaten.copy_/aten.fill_;_mm_dtype_meta(), which supplies torch 2.10's fake rule foraten.mm.dtype/aten.mm.dtype_outduring the dry run when torch'smeta_mmtakes noout_dtype, and restores the original rules on exit.tests/test_flydsl_aot_replay.py: the tests of both PRs.No other file changes. The diff against main is exactly the union of the two PRs; the branch holds their commits plus conflict-free merges.
Testing
This is a host-only change to the replay, validated without a GPU the way the Nightly runs it (see below).
Documentation
Internal AOT build tooling; both stand-ins carry their own docstrings.
Dependencies
Breaking Changes
None.
PR Self-Review
Reviewed revision
3b2c798
Behavior and intent
Only inside
dry_run:tensor[index] = valueon a CUDA FakeTensor with basic indexing (ints, slices,None,...) no longer goes through torch's binding, whose device guard reaches HIP on torch 2.9.1. Andtorch.mm(..., out_dtype=)on FakeTensors gets a correct meta rule on torches whosemeta_mmlacksout_dtype. Outsidedry_run, and for real or non-CUDA tensors, nothing changes. On torch 2.10 themmbackport is a no-op.Validation and unverified scope
The environment matches how the Nightly runs the AOT step, without docker: torch
2.9.1+rocm7.2.0.lw.git7e1940d4(the Nightly image's wheel, from repo.radeon.com), triton 3.8.0 (whatinstall_triton.shinstalls), flydsl 0.5.0, a clean environment, and the GPUs hidden asreplay_envhides them, on a gfx1250 host.d6bda77fealone, the full MoE and MegaMoE replays reproduce the Nightly's counts exactly: gfx942 348 ok / 870 failed, gfx950 2890 ok / 7944 failed, MegaMoE 0 ok / 192 failed.d6bda77feplus both PRs:run_aotassetup.pycalls it (GPU_ARCHS="gfx942;gfx950" AITER_AOT_IMPORT=1) exits 0 in 19.5 min with 0 failed in every module:3b2c798= maind817aeb46plus both PRs): targeted replays covering one row per failure site all pass: MoE 26/26, MegaMoE 8/8, GEMM bisect 0 failed. The rows are MXFP4 a4w4, a16w4 withinter_dim=384, int4, MXFP8, a MegaMoE profile with mtpr 8192 and epr 48 (8 ranks), and the kimik3 BF16 to FP32 GEMM row. On main the same set fails 26/26, 8/8 and 1.pytest tests/test_flydsl_aot_replay.pygives 22 passed on torch 2.9.1, and 20 passed with 2 skipped on torch 2.10. Against main'sdry_run.py, the new tests fail: 11 on torch 2.9.1, and on torch 2.10 the 3 that simulate torch 2.9.1's binding and meta.build-only-aiter): aiter-release.yaml run 43252572709 on this branch withrelease_type=none. It was still queued when this was written.Unverified here: the Nightly's
testjob (five op tests on MI300X and MI355, which has not run since 2026-06-22) andpromote. Some other torch 2.9.1 bindings with a device guard still reach HIP insidedry_run:Tensor.copy_,~, and advanced or boolean-mask__setitem__. No current replay reaches them (the full run above has 0 failures), so they are left for a follow-up.PR-specific question
The boundary is which calls the stand-ins take over.
__setitem__is taken over only for basic-index assignment on CUDA FakeTensors; themmbackport covers only the two dtype overloads, and only on torches whosemeta_mmlacksout_dtype; both apply only insidedry_run. The failure mode to guard against is a replay that silently compiles a different kernel set because a stand-in changed semantics. Three pieces of evidence cover it:run_aoton torch 2.9.1 replays the same job sets as the Nightly (MoE 1754 rows / 12052 jobs, GEMM 24024 jobs) with 0 failures.test_mm_fallback_still_checks_shape_and_output_dtypeshows the backport still rejects invalid shapes and dtypes.test_legacy_mm_meta_is_restored_after_dry_runshows torch's own rules are back after the dry run, including after an exception.Any call outside the boundary still goes to torch's binding and fails loudly as a replay
[FAIL], rather than being silently mis-replayed.Changed op tests
None. The new tests are in
tests/test_flydsl_aot_replay.py, not underop_tests/.