Repository navigation
Conversation
A 4-wave, 128x192x64 BF16/FP16 GEMM with a 4-stage direct-to-LDS ring, one barrier per K tile, and a count-derived sched_group_barrier plan. Each K tile's DMA is split across two half-tiles and issued through the buffer's scalar offset. Registered as tuned-name policy 'rg', and the router row in dsv41_bf16_tuned_gemm.csv now uses it. Hot: 54.0 us (1192 TFLOP/s) vs 58.0 us for hipBLASLt 440130 and 69.4 us for torch.mm. Producer-flush: 85.1 vs 85.5 us. Cold: 95.4 vs 97.0 us.
…6w16 - Move the launch wrapper to aiter/ops/flydsl/gemm_a16w16_ring.py and dispatch through tensor_shim._run_compiled, keyed by config and device. The wrapper gates on get_gfx_runtime(), checks devices and alignment, and keeps every operand under 2 GiB (32-bit buffer byte offsets). - Kernel: issue the LDS DMA through the stable fx.copy async atom instead of the raw intrinsic (no flydsl._mlir import, no measurable change), and name the kernel through flyc.kernel(name=, known_block_size=). Document the remaining unstable sched_barrier/s_barrier sites and the DMA lane map. - Name parser: one shape-independent ring_tile_error check for 'rg'. - tuned_gemm.flydsl_gemm: ring, like skinny, writes its input dtype and takes no fused bias. - Tests: fold the ring cases into op_tests/test_gemm_a16w16.py (-t ring, on by default; CI runs this file). The new tests use the tuned dispatch with an injected row, a NaN-filled out, an exact permutation input, and parser and launcher refusals, and print their own summary table.
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
Summary
Adds a gfx950 FlyDSL BF16/FP16 GEMM (
gemm_a16w16_ring) for the DeepSeek-V4.1 MoE router,torch.mm(x, W.t())with x[16384, 5120] and W[384, 5120]. It is registered as tuned-name policyrg, and the router's gfx950 row indsv41_bf16_tuned_gemm.csvnow uses it: 53.4 µs against 69.2 µs for the current row (torch) and 57.4 µs for the best tuned hipBLASLt solution.Motivation
The router row in
dsv41_bf16_tuned_gemm.csvistorch(77.0 µs tuner time). No FlyDSL configuration in the generic gfx950 catalog fits this shape well: the best is 65.4 µs. The shape (N=384) gives exactly 256 tiles of 128x192 on a 256-CU MI355X, and the generic kernels' 8-wave schedules do not reach that tile's matrix-core rate at one wave per SIMD.Changes
aiter/ops/flydsl/kernels/gemm_a16w16_ring_gfx950.py: the kernel. A 128x192x64 tile with 4 waves of 64x96, and a 4-stage direct-to-LDS ring with one barrier per K tile. The next K chunk's LDS reads and half of a later tile's DMA are interleaved with each chunk's MFMAs by asched_group_barrierplan derived from the tile's instruction counts. N and K are compile-time; M is dynamic, and partial M/N tiles are supported. It has no split-K, bias or fp32 output.aiter/ops/flydsl/gemm_a16w16_ring.py: the launch contract. It dispatches throughtensor_shim._run_compiled, keyed by config and device, gates onget_gfx_runtime() == "gfx950", checks dtype, contiguity, device and 16-byte alignment, and requires each operand under 2 GiB (32-bit buffer offsets).aiter/ops/flydsl/gemm_kernels.py: tuned-name policyrg(for exampleflydsl_hgemm_abf16_wbf16_bf16_t128x192x64x4_ks1_w2x2x1_bias0_ktail0_gm1_prg_gfx950). The name parser accepts only same-dtype output, split_k 1, k_waves 1, no bias, gfx950 and a valid tile;flydsl_hgemm(policy="rg")launches it.aiter/tuned_gemm.py:flydsl_gemmtreatsrglike skinny: input-dtype output, with a bias added after the call rather than fused.aiter/configs/model_configs/dsv41_bf16_tuned_gemm.csv: the gfx950 16384x384x5120 BF16 row changes fromtorch(77.02 µs) to thergkernel (54.03 µs).op_tests/test_gemm_a16w16.py: aringtest, on by default.Performance (if applicable)
MI355X (gfx950, 256 CUs), FlyDSL 0.5.0, torch 2.10.0+rocm7.2.4. Random BF16, W[N,K] as in SGLang, one process. Hot is the median over reps of 20 queued calls / 20. Producer means a 1 GiB write, then A rewritten, then one call. Cold means a 1 GiB write, then one call.
Testing
The kernel is gfx950 only; on other cards the test skips with a warning. Validated on MI355X, see below.
Documentation
The kernel and launcher docstrings state the contract. No user-facing API changes: the kernel is reached through the existing tuned GEMM dispatch.
Dependencies
Breaking Changes
None.
PR Self-Review
Reviewed revision
6b73626
Behavior and intent
The only shape whose dispatch changes is gfx950 cu_num 256, M=16384, N=384, K=5120, BF16 in and out, no bias. Through
aiter.tuned_gemmit now runs the FlyDSL ring kernel instead oftorch.mm. Every other row and policy is unchanged. The newrgname is accepted only for configurations the kernel implements, so anrgrow with split-K, bias, fp32 output, another arch or another block_k is rejected at lookup, as other unknown names are.Validation and unverified scope
python3 op_tests/test_gemm_a16w16.py -t ring(FLYDSL_RUNTIME_ENABLE_CACHE=0, MI355X) passes every case with err 0, plus the exact permutation check on every case.python3 op_tests/test_gemm_a16w16.py(default-t normal ring) passes, and so does-t out, which includes a FlyDSL tuned row.AITER_LOG_TUNED_CONFIG=1, the router shape resolves tolibtype flydslwith the row's kernel name, and the profiler showshgemm_ring_bf16_t128x192x64x4_w2x2_gm1_n384_k5120_0.python -m aiter.aot.flydsl.gemm --csv <the router row>(GPU_ARCHS=gfx950) replays 1/1 ok and writesgemm_a16w16_ring_gfx950into the cache.python3 -m unittest op_tests.tuning_tests.test_config_shape_collisionpasses 33/33.torch.mmfor the router, so the row takes effect only on anaiter.tuned_gemmcall path.PR-specific question
To be answered when the automated PR Self-Review comment is posted.
Changed op tests
op_tests/test_gemm_a16w16.py, newringtest (on by default):rgpolicy.flydsl_gemmwith an injected row, so it does not depend on the production CSV.out.