Skip to content

[FlyDSL] MegaMoE: fix the large-input launch cache on weight rebinding and the MegaMoEV2 op test import - #8547

Merged
coderfeli merged 2 commits into
mainfrom
ghu/mega_op_test_fix_20261124
Nov 25, 2026
Merged

coderfeli merged 2 commits into
mainfrom
ghu/mega_op_test_fix_20261124

Conversation

@GwilliamHu

@GwilliamHu GwilliamHu commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

PR Self-Review

Reviewed revision

8f8406a

Behavior and intent

Two fixes for regressions from #7788: 8f8406a and d5a663d. (1) LargeMRuntime cached its bound persistent-kernel launch per (config, layer slot), capturing the W1 / W1 scale / W2 / W2 scale pointers of the first call. MegaMoEV2 rebinds weights by assigning attributes, which never cleared that cache, so a layer slot rebound to different weights kept running the old ones (large-input layer-slot stress: relL2 0.5 vs the main path after a W2 rescale). The cache key now includes the four weight pointers (as the small-input W2 dispatch table already does) and the cache is bounded at 1024 entries. (2) op_tests/multigpu_tests/test_mega_moe_v2.py imports torch_stream from tensor_shim instead of the mega_moe_large_m._torch_stream alias that #7788 removed; without it the size suite raised ImportError at the large-input edge check.

Validation and unverified scope

  • Static: AST check of every tests//op_tests/ import and module attribute into aiter/ops/flydsl/kernels/mega_moe* plus the private MegaMoEV2 attributes the tests touch; no other stale reference found.
  • Lint: ruff check (0.16.0) and black --check on both changed Python files.
  • Before the fix, the 8-GPU large-input layer-slot stress (torchrun --nproc-per-node 8 op_tests/multigpu_tests/test_mega_moe_v2.py --expect-large-m --smoke-only --large-m-state-slots 61 --layer-stress-cycles 9 --route-switch-rounds 8) failed with relL2 0.5 against the main path.
  • Local GPU run on 8x MI355X (gfx950), FlyDSL 0.5.3, op_tests/multigpu_tests/test_mega_moe_v2.py:
    • Large-input layer-slot stress, torchrun --nproc-per-node 8 test_mega_moe_v2.py --network {v41_flash,v4_pro} --max-tok-per-rank 16384 --expect-large-m --bs-list 16384 --accuracy-max-bs 16384 --smoke-only --large-m-state-slots 61 --layer-stress-cycles 9 --route-switch-rounds 8: this revision prints [LARGE-M-LAYERS] slots=61 cycles=9 calls=549 main_checks=27 route_mutation=PASS weight_rebind=PASS on both networks. The same test on main + the import fix only (d5a663d) fails with layer cycle=1 slot=0: relL2=0.500203 > 0.1 against the main path on the same binding (v41_flash, a8w4); on main alone it fails earlier on the import.
    • Size suite --bs-list 1,64,512,1024,4096 --max-tok-per-rank 8192 and route suites --suite routes (v4_pro) / --suite routes --network v41_flash --check-time-acc: all pass.
    • Timing, route suite v41_flash vs main: every point within 1% (small-input 123.6 vs 123.4 us at 7 rows a rank, 304.3 vs 304.2 us at 448).
  • Not covered: the multi-GPU files that aiter_test.sh skips are not run by CI; running them all is left to a separate change.

PR-specific question

Before this PR test_mega_moe_v2.py failed in two ways: the size suite raised ImportError on mega_moe_large_m._torch_stream as soon as it reached the large-input edge check, and the large-input layer-slot stress (--expect-large-m --layer-stress-cycles) failed accuracy (relL2 0.5) because a rebound layer slot reused the cached launch with the previous weights. No canonical test covers this elsewhere: tests/test_mega_moe_gfx950_route_plan.py checks route planning on CPU without launching kernels or rebinding weights, and bench_mega_moe_v2.py pins the staged route, so only this multi-GPU test exercises large-input launches across rebound layer slots.

Changed op tests

  • op_tests/multigpu_tests/test_mega_moe_v2.py: the MegaMoEV2 (gfx950) multi-GPU accuracy/route test, including the large-input layer-slot stress that exposes the launch-cache bug. Only the broken import changes; it is the sole test of MegaMoEV2's small/large-input routes, stream handling and layer-slot weight rebinding, so it is not redundant and must import correctly to run at all.

Motivation

#7788 (MegaMoEV2 route plan + FlyDSL API cleanup) left two regressions: the large-input launch cache ignored weight rebinding (wrong results when a layer slot is rebound to other weights), and test_mega_moe_v2.py still imported the removed mega_moe_large_m._torch_stream. CI did not catch either because .github/scripts/aiter_test.sh lists test_mega_moe_v2.py (and the other multi-GPU MegaMoE files) in skip_tests.

Changes

  • fix(mega_moe): key LargeMRuntime._launch_cache on (config, layer slot, W1 / W1 scale / W2 / W2 scale pointers) and bound it.
  • test(mega_moe): import torch_stream from aiter.ops.flydsl.kernels.tensor_shim.

Test Plan

See "Validation and unverified scope".

🤖 Generated with Claude Code

… op test

#7788 dropped mega_moe_large_m's _torch_stream alias; the large-input
stream check in test_mega_moe_v2.py still imported it, so every size-suite
run that reaches the large-input edge checks raised ImportError. CI skips
this file, so it went unnoticed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@GwilliamHu GwilliamHu added the ci:multi-gpu Trigger multi-GPU op tests on PR label Nov 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter standard tests on MI35X
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the Radeon R9700 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 8547 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

Reviews:
A reviewer is usually assigned within one working day after the PR is ready for review (see Code Review Process). If nobody has responded for about a week, mention the area contact listed in CONTACTS.md. Want to help review? See REVIEWERS.md.

@GwilliamHu
GwilliamHu marked this pull request as ready for review November 24, 2026 07:40
@GwilliamHu
GwilliamHu requested a review from a team November 24, 2026 07:40
@github-actions github-actions Bot changed the title [FlyDSL] MegaMoE: fix the MegaMoEV2 op test import (+ temporary full multi-GPU CI run) [CI] MegaMoE: fix the MegaMoEV2 op test import (+ temporary full multi-GPU CI run) Nov 24, 2026
@github-actions github-actions Bot added the CI label Nov 24, 2026
@aiter-bot

aiter-bot commented Nov 24, 2026 •

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision 8f8406a8d7a0 · mode shadow

Author self-review accepted. Readiness report:

Author answers

  • PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers

Behavior and intent

Two fixes for regressions from #7788: 8f8406a8d7 and d5a663dddb. (1) `LargeMRuntime` cached its bound persistent-kernel launch per (config, layer slot), capturing the W1 / W1 scale / W2 / W2 scale pointers of the first call. MegaMoEV2 rebinds weights by assigning attributes, which never cleared that cache, so a layer slot rebound to different weights kept running the old ones (large-input layer-slot stress: relL2 0.5 vs the main path after a W2 rescale). The cache key now includes the four weight pointers (as the small-input W2 dispatch table already does) and the cache is bounded at 1024 entries. (2) `op_tests/multigpu_tests/test_mega_moe_v2.py` imports `torch_stream` from `tensor_shim` instead of the `mega_moe_large_m._torch_stream` alias that #7788 removed; without it the size suite raised `ImportError` at the large-input edge check.

Validation and unverified scope

- Static: AST check of every `tests/`/`op_tests/` import and module attribute into `aiter/ops/flydsl/kernels/mega_moe*` plus the private `MegaMoEV2` attributes the tests touch; no other stale reference found.
- Lint: `ruff check` (0.16.0) and `black --check` on both changed Python files.
- Before the fix, the 8-GPU large-input layer-slot stress (`torchrun --nproc-per-node 8 op_tests/multigpu_tests/test_mega_moe_v2.py --expect-large-m --smoke-only --large-m-state-slots 61 --layer-stress-cycles 9 --route-switch-rounds 8`) failed with relL2 0.5 against the main path.
- Local GPU run on 8x MI355X (gfx950), FlyDSL 0.5.3, `op_tests/multigpu_tests/test_mega_moe_v2.py`:
  - Large-input layer-slot stress, `torchrun --nproc-per-node 8 test_mega_moe_v2.py --network {v41_flash,v4_pro} --max-tok-per-rank 16384 --expect-large-m --bs-list 16384 --accuracy-max-bs 16384 --smoke-only --large-m-state-slots 61 --layer-stress-cycles 9 --route-switch-rounds 8`: this revision prints `[LARGE-M-LAYERS] slots=61 cycles=9 calls=549 main_checks=27 route_mutation=PASS weight_rebind=PASS` on both networks. The same test on main + the import fix only (d5a663dddb) fails with `layer cycle=1 slot=0: relL2=0.500203 > 0.1 against the main path on the same binding` (v41_flash, a8w4); on main alone it fails earlier on the import.
  - Size suite `--bs-list 1,64,512,1024,4096 --max-tok-per-rank 8192` and route suites `--suite routes` (v4_pro) / `--suite routes --network v41_flash --check-time-acc`: all pass.
  - Timing, route suite v41_flash vs main: every point within 1% (small-input 123.6 vs 123.4 us at 7 rows a rank, 304.3 vs 304.2 us at 448).
- Not covered: the multi-GPU files that `aiter_test.sh` skips are not run by CI; running them all is left to a separate change.

PR-specific question

Before this PR `test_mega_moe_v2.py` failed in two ways: the size suite raised `ImportError` on `mega_moe_large_m._torch_stream` as soon as it reached the large-input edge check, and the large-input layer-slot stress (`--expect-large-m --layer-stress-cycles`) failed accuracy (relL2 0.5) because a rebound layer slot reused the cached launch with the previous weights. No canonical test covers this elsewhere: `tests/test_mega_moe_gfx950_route_plan.py` checks route planning on CPU without launching kernels or rebinding weights, and `bench_mega_moe_v2.py` pins the staged route, so only this multi-GPU test exercises large-input launches across rebound layer slots.

Changed op tests

- `op_tests/multigpu_tests/test_mega_moe_v2.py`: the MegaMoEV2 (gfx950) multi-GPU accuracy/route test, including the large-input layer-slot stress that exposes the launch-cache bug. Only the broken import changes; it is the sole test of MegaMoEV2's small/large-input routes, stream handling and layer-slot weight rebinding, so it is not redundant and must import correctly to run at all.

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply
  • ADVISORY — Copilot did not review the current head SHA

Code and op-test hygiene

  • PASS — no committed artifact or conflict marker detected

Required CI

  • PASS — Black: passed
  • PASS — Ruff: passed
  • PASS — Repository dependency: passed
  • FAIL — Aiter Test Gate: failed
  • Required CI failed; fix it before requesting human review.

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

…ointers

The launch fast path cached a bound persistent-kernel launch per
(config, layer slot), capturing the W1 / W1 scale / W2 / W2 scale
pointers of its first call. MegaMoEV2 rebinds weights by assigning the
runtime's weight attributes, which never cleared that cache, so a layer
slot rebound to other weights kept running the old ones (the large-input
layer-slot stress test: relL2 0.5 against the main path after a W2
rescale). Key the cache on the weight pointers as the small-input W2
dispatch table does, and bound its size.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@GwilliamHu
GwilliamHu force-pushed the ghu/mega_op_test_fix_20261124 branch from 9061207 to 2bd792b Compare November 24, 2026 09:54
@github-actions github-actions Bot changed the title [CI] MegaMoE: fix the MegaMoEV2 op test import (+ temporary full multi-GPU CI run) [FlyDSL] [CI] MegaMoE: fix the MegaMoEV2 op test import (+ temporary full multi-GPU CI run) Nov 24, 2026
@GwilliamHu GwilliamHu changed the title [FlyDSL] [CI] MegaMoE: fix the MegaMoEV2 op test import (+ temporary full multi-GPU CI run) [FlyDSL] MegaMoE: fix the large-input launch cache on weight rebinding and the MegaMoEV2 op test import Nov 24, 2026
@GwilliamHu
GwilliamHu force-pushed the ghu/mega_op_test_fix_20261124 branch from 2bd792b to 8f8406a Compare November 24, 2026 11:43
@github-actions github-actions Bot removed the CI label Nov 24, 2026
@GwilliamHu GwilliamHu added ci:multi-gpu Trigger multi-GPU op tests on PR and removed ci:multi-gpu Trigger multi-GPU op tests on PR labels Nov 24, 2026
@coderfeli
coderfeli merged commit 54ee06c into main Nov 25, 2026
125 of 130 checks passed
@coderfeli
coderfeli deleted the ghu/mega_op_test_fix_20261124 branch November 25, 2026 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:multi-gpu Trigger multi-GPU op tests on PR FlyDSL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants