Repository navigation
[FlyDSL] MegaMoE: fix the large-input launch cache on weight rebinding and the MegaMoEV2 op test import - #8547
Conversation
… 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]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
NOT 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 |
…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]>
9061207 to
2bd792b
Compare
2bd792b to
8f8406a
Compare
PR Self-Review
Reviewed revision
8f8406a
Behavior and intent
Two fixes for regressions from #7788: 8f8406a and d5a663d. (1)
LargeMRuntimecached 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.pyimportstorch_streamfromtensor_shiminstead of themega_moe_large_m._torch_streamalias that #7788 removed; without it the size suite raisedImportErrorat the large-input edge check.Validation and unverified scope
tests//op_tests/import and module attribute intoaiter/ops/flydsl/kernels/mega_moe*plus the privateMegaMoEV2attributes the tests touch; no other stale reference found.ruff check(0.16.0) andblack --checkon both changed Python files.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.op_tests/multigpu_tests/test_mega_moe_v2.py: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=PASSon both networks. The same test on main + the import fix only (d5a663d) fails withlayer 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.--bs-list 1,64,512,1024,4096 --max-tok-per-rank 8192and route suites--suite routes(v4_pro) /--suite routes --network v41_flash --check-time-acc: all pass.aiter_test.shskips are not run by CI; running them all is left to a separate change.PR-specific question
Before this PR
test_mega_moe_v2.pyfailed in two ways: the size suite raisedImportErroronmega_moe_large_m._torch_streamas 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.pychecks route planning on CPU without launching kernels or rebinding weights, andbench_mega_moe_v2.pypins 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.pystill imported the removedmega_moe_large_m._torch_stream. CI did not catch either because.github/scripts/aiter_test.shliststest_mega_moe_v2.py(and the other multi-GPU MegaMoE files) inskip_tests.Changes
fix(mega_moe): keyLargeMRuntime._launch_cacheon (config, layer slot, W1 / W1 scale / W2 / W2 scale pointers) and bound it.test(mega_moe): importtorch_streamfromaiter.ops.flydsl.kernels.tensor_shim.Test Plan
See "Validation and unverified scope".
🤖 Generated with Claude Code