Repository navigation
[CK] [FlyDSL] Clean up kernel IR and consolidate shared helpers - #5476
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
PR title tags & labels: |
Restore conditional method calls and remove the select migration wrappers and branches. Keep LOG2E in kernel common and retain the independent cleanup skill changes.
Preserve the upstream MXFP4 GEMM1 variants and stage2 input-row ABI while reusing shared activation, buffer and scale helpers. Remove redundant bitcasts, copies and unused validation parameters, and keep the native scale allocation caller aligned with the common helper.
Fold the two identical 0/1 environment selectors into one helper, route the host and kernel ceiling divisions through kernels_common.ceildiv, and merge the global/LDS view builders into a single tensor_view now that the global offset folds into the pointer. Drop the AS_ROW alias of AS_FULL_INNER, two dead locals, and a commented-out intrinsic call. Gate: gfx1250 COMPILE_ONLY ISA dump over 22 kernel variants -- 20/20 byte-identical 21_final_isa.s; the two EP-scatter variants cannot link locally (mori device bitcode is built for gfx950) and were compared at 18_reconcile_unrealized_casts.mlir, identical op multisets.
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
PR title tags & labels: |
…#5476) * refactor(flydsl): share single-GPU helpers and replace raw dialects * docs(flydsl): remove stale migration comments Gate: gfx1250 COMPILE_ONLY ISA dump over 22 kernel variants -- 20/20 byte-identical 21_final_isa.s; the two EP-scatter variants cannot link locally (mori device bitcode is built for gfx950) and were compared at 18_reconcile_unrealized_casts.mlir, identical op multisets. Signed-off-by: Xiake Sun <[email protected]>
main reverted #5274 in #5581, so its compact-scale and a_gather work is gone and this branch no longer overlaps it. The only conflict left is the scale staging in launch_gemm_a8w4_tdm: take main's ceildiv helpers from #5476 while keeping row_major_ascale dropped, which is what this branch's compact path replaces. Also drops AS_ROW. It was defined as (K // 128) * wmma_m_rep * 16, which is exactly the AS_FULL_INNER that already existed a few lines above, and the merge had already moved its uses over to that name.
The gfx942 _CAPIPtr crash in AITER's FlyDSL fp8_mqa_logits is fixed in AITER 0.1.23 (ROCm/aiter#5476), which vLLM picked up in #58867. The current vllm/vllm-openai-rocm:nightly (0.30.1rc1.dev396+gac68c3087) ships it: on MI325X the kernel-level repro with float8_e4m3fn inputs returns max_rel 9.5e-4, where nightly-29468dde8b (AITER 0.1.22.post1) still raises the AttributeError. Replace the AMD-section warning with the AITER 0.1.23 requirement and how to check a cached image, and key the troubleshooting entry to the image's AITER version. Drop the vLLM #56607 fallback, whose diff no longer applies to current nightlies, and the VLLM_ROCM_USE_AITER fallback, which is no longer needed. The serve command and benchmark were not re-run on the new nightly; the end-to-end validation is still the 2026-09-21 nightly with #56607 applied. Signed-off-by: Jin Tao <[email protected]> Co-authored-by: Cursor <[email protected]>
Single-GPU FlyDSL kernels duplicated activation, pointer and reduction helpers and used low-level constructs where the pinned API provides an equivalent. This consolidates the shared code while preserving numerical behavior, memory addressing and scheduling. Corresponding cleanup is ported to ROCm/FlyDSL#1127.
act.py, withLOG2Edefined once inkernels_common.py. Preserve distinct clamp behavior, constant rounding, reciprocal placement and multiplication order.fx.copy. Keep the new A4/A8 input, FP4/FP8 output, bias, activation, prefetch and wave configurations.kernels_common.ceildiv, and onetensor_viewin place of the separate global/LDS view builders now that the global offset folds into the pointer. Drop theAS_ROWalias ofAS_FULL_INNER, two dead locals and a commented-out intrinsic.cond.select(t, f)expressions. FlyDSL itself and its pinned 0.3.2 dependency are unchanged.Note that the MQA item is the one deliberate behavior change in this PR. In the FN to FNUZ conversion path, a cleaned low dword whose high byte held a negative fp8 value was sign-extended into the high dword and corrupted the packed result. It is reachable only on gfx942 with e4m3fn inputs.
Validation
Rerun against main
ffa945f93with the branch fully merged, sogit diff origin/main..HEADis exactly this cleanup. Installed FlyDSL 0.3.2, local gfx950, runtime disk cache disabled for every compile gate, and anorigin/mainworktree as the A/B baseline. gfx1250 is covered by cross-arch compile plus ISA comparison, since no gfx1250 device is available here.moe2556,gemm3408,mxfp4_moe486,grouped_moe222,chunk_gdn_h288,mega_moe144. 7104 kernels, 0 failures.21_final_isa.s. The 7 that differ are alla16w4/a16wi4: identical memory-operation multiset, identical MFMA multiset, identical VGPR and SGPR counts, zero spills, instruction counts within 12. The largest delta is 13 fewers_waitcnton the branch.test_flydsl_moe.py,test_flydsl_moe_a16wfp4.pyandtest_silu_and_mul_fq.py: 49 passed on each tree. Script-modetest_flydsl_compress_attn,test_flydsl_moe_aux,test_flydsl_qk_norm_rope_quant,test_flydsl_causal_conv1d_updateandtest_flydsl_gdr_mtp: identicalcheckAllcloseverdict histograms, including the 6 pre-existing bit-exactcsa_indexercache-scale failures, which fail identically on main.origin/mainworktree, 971 byte-identical in21_final_isa.s:COMPILE_ONLYvariants (gemm1 and gemm2, fp8 and fp4 activations, row-major and blocked A-scale, A-scale prologue, next-stage prefetch, cluster, tile and buffer-count sweeps): 19 of 19 linkable modules identical. The 2 EP-scatter variants cannot link on either tree because the mori device bitcode is built for gfx950; compared at18_reconcile_unrealized_casts.mlir, identical operation multisets.grouped_moeAOT, 120 gfx1250 jobs run serially (route/quant/scatter, preshuffle, prefix-sum/remap, gather-reduce): 814 of 814 identical.gemmAOT, all 71 gfx1250 job families (ptpc, mxfp8_128, mxfp8_128 compute-bound, split-K reduce): 63 of 73 identical, 10 differ (below).csa_main,csa_indexer,hca_maincross-compiled withGPU_ARCHS=gfx1250 FLYDSL_GPU_ARCH=gfx1250 COMPILE_ONLY=1: 19 of 19 identical, coveringfused_compress_attn_gfx1250and the HCA compress/norm-rope-scatter kernels.gemm_a8w8_mx128_compute_*, from the one-lineVec.from_elements([zero] * n)toVec.filled(n, 0, fx.Int32)change ingemm_a8w8_256x256_gfx1250.py. Both build the same zero vector, and it is a placeholder overwritten in thewave == 0branch; the splat form just materializes with fewer scalar moves. Memory-operation multiset, WMMA multiset, VGPR count and LDS size are identical with zero spills; SGPR drops by 5 to 9 and instruction count by 12 to 45, entirelys_mov_b32/s_mov_b64. No occupancy change.Not covered locally:
op_tests/test_moe_2stage.py, whoseFLYDSL_RUNTIME_RUN_ONLY=1gate misses even with the AOT cache populated because the tuned-CSV configs it selects are not in the AOT job set; multi-GPU and EP execution; and execution on architectures other than gfx950, which rely on the compile and ISA checks above. Under pytest,op_tests/test_flydsl_*.pyreports 43 collection failures, an identical set on main and on this branch, because thosetest_*functions are argparse entry points rather than pytest tests.Earlier per-area coverage of the attention, convolution, GDR and HSTU cleanup, recorded against main
fe4814c64, still stands and is not repeated here. Temporary probes, reports and performance artifacts are outside the PR.