Repository navigation
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
DRAFT — evaluation pausedPR Self-ReviewRevision This pull request is a draft, so readiness evaluation is paused and no verdict applies. Evaluation resumes when it is marked ready for review and the required CI completes. |
|
@aiter-bot review |
|
aiter-bot — queued behind 6 review(s); expect to start in about 2.2 h. The box reviews one PR at a time. |
aiter-bot
left a comment
There was a problem hiding this comment.
[ROCm/aiter] PR #8496 — [FlyDSL] refactor(flydsl): share the token-multidest quant context
Review (advisory):
Validation (deterministic): NOT RUN — the PR changes runtime code but ships no test target (auto-validation disabled); the changed path is run-time-executed (gfx1250 MoE stage1 quant), and this review closed the gap by hand: a base-vs-head compile-only recompile against the merge target (flydsl 0.5.0, dry_run, 49 builds covering every builder family in the file) is byte-identical on all 49 final ISA files with identical kernel-name sets
Perf (advisory): NOT RUN — no perf target (the PR changes runtime code but ships no test target); base and head compile to byte-identical gfx1250 ISA on all 49 builds recompiled here, so the shipped kernel binary — and with it its latency — is unchanged by construction
Size: 225 lines / 1 file
Design (advisory): the sharing seam for #7543 — the quant context becomes a builder-level _quant_ctx closure whose **staging catch-all carries how the hidden row arrives, and the pk8 hidden-row load becomes the module-level _hidden_pk8_load
Human: recommend yadaish review whether the **staging catch-all in _quant_ctx (moe_fused_route_quant_scatter.py:2237) is the right contract for #7543, given _emit_quant_block_loop reads those fields via getattr with silent defaults
📝 [verified] aiter/ops/flydsl/kernels/moe_fused_route_quant_scatter.py changes run-time-executed code (the gfx1250 MoE stage1 quant builders) but the PR ships no test target and ran no GPU test on any arch — the no-behavior-change claim rested only on the author's own ISA diff, which this review independently reproduced (49/49 builds byte-identical against the merge target, covering token-multidest fp4/fp8 × wmma_rep 1/2 × K 1024/6144 × ksplit 1/2/4/12 × tdm 0/4, routeks, compact, row-indexed and all three route+quant+scatter builders), so the residual gap is only that no automated check exercises the refactored builder end-to-end. Reviewer should ask for one gfx1250 run of the existing test_grouped_skips_pad_rows_routed_to_minus_one (op_tests/flydsl_tests/test_flydsl_grouped_gemm.py:970) before merge, or a note that the GPUs are still unavailable.
1 finding(s) posted inline, on the lines they are about:
aiter/ops/flydsl/kernels/moe_fused_route_quant_scatter.py:2237—_quant_ctxreceives its staging fields (how the hidden row arrives) through a**stagingcatch-all…
| valid, | ||
| lane, | ||
| raw_rows, | ||
| **staging, |
There was a problem hiding this comment.
📝 [verified] _quant_ctx receives its staging fields (how the hidden row arrives) through a **staging catch-all (moe_fused_route_quant_scatter.py:2237), and _emit_quant_block_loop reads them back with silent getattr defaults (hidden_chunks at :438, chunk_prefetch/hidden_lds_load at :441-442, mx_group_base at :372) — this PR's one call site passes all seven names correctly, but a mistyped staging kwarg in #7543's future call would silently take the default and, with hidden_lds_load set but hidden_chunks typo'd, read every chunk from LDS slot 0, silently producing wrong quantized values. Reviewer should ask #7543 to pass the staging fields as explicit parameters (or assert them at build time) so a typo fails loudly.
There was a problem hiding this comment.
Fixed in 517e25b6, and carried through #7543 and #7547.
_quant_ctxnow takes the seven staging fields as required keyword-only parameters, and the**stagingcatch-all is gone. A missing or misspelled name is aTypeErrorwhen the kernel is built, before anything launches.- [FlyDSL] perf(flydsl): fold the gfx1250 TP MoE route into the activation quant #7543's route entry passes one more field,
hidden_preloaded. There it is the eighth required parameter, and the default entry passeshidden_preloaded=None. No field has a default, so leaving one out fails as well. - Checked with the typo from this comment, compile-only on CPU. With
hidden_chunksmisspelled at the call site, all 30 token-multidest builds stop withTypeError: build_moe_token_multidest_quant_module.<locals>._quant_ctx() got an unexpected keyword argument 'hidden_chunk'. Did you mean 'hidden_chunks'?. Atf41bda5fthe same typo built 96/96 without an error and changed the ISA of the six TDM-staged kernels. - No kernel changes: the same 96 builds give 81/81 kernels byte-identical to
f41bda5fand to main, and the traced IR is identical tof41bda5f, so no FlyDSL cache key moves. - Not changed: the
getattrdefaults in_emit_quant_block_loopstay, because the other builders that share the loop leavehidden_chunks,chunk_prefetchandhidden_lds_loadto them.build_moe_token_multidest_compact_quant_modulestill fills the same fields into aSimpleNamespaceby hand; that is main's code, and this PR does not touch it.
|
Thanks for the review.
|
|
The gfx1250 run asked for above, at |
Move the per-warp _emit_quant_block_loop context of the token-multidest quant into a _quant_ctx closure in its builder. The kernel now only loads its routes' rows and hands them over with the hidden-row staging. Pull the pk8 hidden-row load of _emit_quant_block_loop into _hidden_pk8_load. No behaviour change: every quant build that goes through _emit_quant_block_loop compiles to the same gfx1250 ISA as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t context _quant_ctx took the fields that say how the hidden row arrives through a **staging catch-all, and _emit_quant_block_loop reads hidden_chunks, chunk_prefetch, hidden_lds_load and mx_group_base back with getattr defaults. A misspelled keyword at a call site would take the default without an error: with hidden_lds_load set and hidden_chunks misspelled, every chunk would be read from LDS slot 0. They are now seven required keyword-only parameters, so a missing or misspelled name raises TypeError when the kernel is built. No behaviour change: the call site already passes all seven, and every quant build that goes through _emit_quant_block_loop compiles to the same gfx1250 ISA as before. Co-Authored-By: Claude Fable 5.2 <[email protected]>
517e25b to
32de0e6
Compare
|
Closing: #7543 is being reworked so that it no longer needs this refactor (the route operands become an optional kernel operand of the existing token-multidest kernel instead of a second entry point that shares the quant context). Nothing here is needed on its own. |
What it does
A refactor of the gfx1250 MoE A1 quant kernels, with no change in behaviour. It is split out of #7543 at review, so that #7543's diff stays reviewable and this part can be checked against main on its own.
_quant_ctx. Inbuild_moe_token_multidest_quant_module, a closure now builds the per-warp_emit_quant_block_loopcontext: destination descriptors, scale bases and layout constants for one token and its routes' rows. The token-multidest kernel only loads its routes' rows and passes them in, together with the hidden-row staging. This replaces about 60 lines of locals and the inline context in the kernel._hidden_pk8_load. The pk8 hidden-row load of_emit_quant_block_loop(one aligned dwordx4 per lane per iteration) becomes a helper.Why: #7543 adds a second entry point to this builder, the TP route-in-quant kernel. It needs the same quant context and the same hidden-row load, which it issues early. With this PR in place, #7543 adds only its route step. #7547's route decode then fits between the row loads and
_quant_ctxin the default entry point.Benefit
There is no runtime change. Every quant kernel that goes through
_emit_quant_block_loopcompiles to byte-identical gfx1250 ISA on main and on this branch (below), so no GPU timing is needed. The gain is in review: #7543 shrinks to the route-in-quant change itself.Testing
aiter.aot.flydsl.dry_run,COMPILE_ONLY,FLYDSL_DUMP_IR=1), driven through the public wrappers. Each kernel's final ISA (22_final_isa.s) is compared withcmp. These are FlyDSL kernels, so there is no hipcc step; this dump is the LLVM AMDGPU backend output that the runtime loads.flydsl_tests/test_flydsl_grouped_gemm.py,flydsl_tests/test_route_psum_fused.py,test_grouped_gemm_stream.py,flydsl_tests/test_ep_e8m0_scale.py): 52 failed, 9 passed, 45 skipped, the same as main. The failures are the GPU cases with no device (no ROCm-capable device).Not covered
Dependencies
None. This PR is based on main. #7543 builds on it.
PR Self-Review
Reviewed revision
32de0e6
Behavior and intent
aiter/ops/flydsl/kernels/moe_fused_route_quant_scatter.py. The token-multidest quant context moves into a_quant_ctxclosure, and the pk8 hidden-row load moves into_hidden_pk8_load.Validation and unverified scope
517e25b6against the previous headf41bda5f:_quant_ctxtakes the hidden-row staging as seven required keyword-only parameters instead of a**stagingcatch-all (the review thread onmoe_fused_route_quant_scatter.py:2237). A missing or misspelled name now raisesTypeErrorwhen the kernel is built. Nothing else changes: one commit, +19/-3.f41bda5fand to main (the basebf599489, andffbd9c6awith this branch merged in). Againstf41bda5fthe traced IR and the emitted GPU object are identical too, so no FlyDSL cache key moves. An AOT replay of 11 gfx1250 grouped rows writes the same 48 cache artifacts byte for byte, and--checkpasses.hidden_chunksmisspelled at the call site, all 30 token-multidest builds stop withTypeError. Atf41bda5fthe same typo built without an error and changed the ISA of the six TDM-staged kernels.32de0e65) is517e25b6rebased onto maine6d2d310(under Triton 3.9 the old base failsop_tests/test_gemm_a4w4.pyin CI); no conflicts. Re-checked on a host without a GPU, FlyDSL 0.5.3: the same 96 compile-only builds give 81/81 kernels whose final ISA is byte-identical to maine6d2d310, and whose final ISA and LLVM IR are byte-identical to517e25b6; main did not change these kernels betweenbf599489ande6d2d310. The CPU pytest outcomes of the four neighbouring test files are the same as maine6d2d310test by test (66). black and ruff are clean. The AOT replay was not repeated.PR-specific question
What could change at run time when the source changes but the ISA does not?
Changed op tests
None.