Repository navigation
[FlyDSL] FP8 MQA logits improvements for gfx950 - #7412
vpietila-amd wants to merge 14 commits into
Conversation
…computing optimal KV-split values, add new head accumulation method; improve software pipelining; fix empty KV window handling; use async loads for LDS copies.
…mqa-logits-gfx950-improvements
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
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 |
…t guidelines
Kernel (ISA-identical on all 96 checked gfx950 specializations):
- Use the public fx.fma spelling instead of fx.math.fma.
- Pass DSL values straight to rocdl.readfirstlane, which coerces them;
drop the redundant .ir_value() unwraps.
- Pass tile_skip/dma_guard to the LDS builder directly instead of through
conditional kwargs dicts.
kernels_common strided warp reductions:
- Document why fx.coop (FlyDSL 0.4.1) cannot replace them: all of its
warp collectives, including the ROCm DPP override, fold contiguous lane
groups only, and permlane{16,32}_swap has no typed wrapper.
- Use fx.max for ReductionOp.MAX, matching fx.coop's combine.
op test:
- --shapes-csv rows now sweep the existing --num-heads/--head-dim/--window
axes when a column is absent, replacing the scalar --csv-num-heads and
--csv-window flags.
- -o/--output gets help text, writes every scenario's table (bench no
longer overwrites verify), and reuses the logged speedup line.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…rse variants LDS usage and do not build variants that exceed devices LDS capacity. Fix documentation for gfx950 routes. Add test for auto-routed head dimensions.
…s. Test improvements: every route is checked against reference.
|
Rebase conflict, and please re-run perf on FlyDSL 0.5.0 The PR conflicts with main in I tried it locally (main merged into this PR, FlyDSL 0.5.0):
Main now pins FlyDSL 0.5.0. The perf tables in the description are from FlyDSL 0.4.1 at
So the numbers may not match the code anymore. Please re-run the tables on gfx950 with FlyDSL 0.5.0 at the final head. |
|
After rebase, Main now has This PR changes So on gfx950, through
Only direct calls to I checked with main merged into this PR:
The table shows Triton is 1.2x to 3.9x slower for these rows. For example, 256x16384: FlyDSL 37.7 us vs Triton 147.8 us. CI will not catch this. All 6 old tags still build with the new grammar. They pass Possible fixes:
To make |
|
Suggestion: keep the default verify smaller The PR adds many verify cases (mostly from
gfx950 has about 720 production pins, so it will take longer there. Maybe keep one or two shapes per route in the default verify, and move the full set behind a flag or a separate scenario. |
|
Overlap with #6164 #6164 (gfx942 LDS-staged variant, open) also edits Please agree with @akii96 on the merge order, so the second PR rebases on the first one's variant list and tests. |
…ments Resolve the kernels_common.py conflict by keeping main's pin_i32 (#7727) and this branch's cross-lane reduction helpers. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…improve LDS swizzle to remove remaining bank conflicts.
… logits wrapper. Fix number of splits.
… integration test to verify that shipped flydsl rows are supported.
Main is merged in ( Main now pins FlyDSL 0.5.3, so everything was re-run on 0.5.3 at the final head:
|
Thanks for catching this. After the merge,
|
Done in On gfx950 that is 152 cases in 33 s with The full matrix moved behind |
|
LGTM. Small things, not blocking:
|
Summary
This PR improves the FlyDSL FP8 MQA logits kernel on gfx950:
grid.yKV split uses the occupancy-aware wave-cost model, with tuned fixed splits for long uneven windows.aiter.mqa_logits()([HIP] [CI] [JIT] Add aiter.mqa_logits with a tuned Triton/FlyDSL table #6185) accepts the new variants, and its GLM-5 table is re-tuned with them.Motivation
cu_oversubtarget that ignores how many blocks of a kernel fit on a CU, so small-M / long-KV shapes were badly split.seq_len_kv. Past_end at 2048×131072 takes 1.6–6.0 ms on main.buffer_ops/create_llvm_ptraddressing and a hand-coded swizzle.Changes
aiter/ops/flydsl/fp8_mqa_logits_kernels.py):mfma<MxNxK>_bkv<B>_r<R>_w<W>[_lds<NB>[_pd<PD>][_swp][_rs][_ls][_ts][_dg][_ig]][_h<fma|fma2>][_wpe<N>][_ns<N>]._GFX950_ROUTES, keyed by (num_heads class, head_size class) with seq_len / seq_len_kv bounds, picks the variant. Head sizes above 128 take_GFX950_LARGE_HEAD_FALLBACK._GFX950_ROUTE_SPLITS).variant_supported(tag, num_heads, head_size): the tag builds, its atom tiles the problem, its LDS slots fit and itsvmcntfits the encoding (≤ 63)._wpe<N>setswaves_per_eu.aiter.mqa_logits(aiter/mqa_logits.py,glm5_tuned_mqa_logits.csv):flydsl_supportsusesvariant_supportedinstead of membership inKERNEL_VARIANTS.autoto use the route table.aiter/ops/flydsl/kernels/mqa_logits/fp8_mqa_logits.py):head_acc(add/fma/fma2head-sum chains);rs_head(permlane reduce-scatter over a group of n-tiles, one contiguous 64-lane store);sw_pipe(MFMAs of item k+1 before the epilogue of item k;_igforcesiglp_optat any WPB);lds_scales,tile_skip,dma_guard,prefetch_depth.BufferLoadAsyncLDS{128b,32b}), and the bank-conflict swizzle as aSwizzleTypelayout. For the 32x32x64 atom at head_size ≤ 128 the swizzle is 16-byte granular, which removes a 2-wayds_read_b128conflict.[seq_len_kv, 0).aiter/ops/flydsl/kernels/kernels_common.py):warp_reduce_stridedandwarp_reduce_scatter_strided. FlyDSL 0.5.3'sfx.cooponly folds contiguous lane groups, while the head reduce folds lane bits at and aboveMFMA_N.Performance
MI350X (gfx950, 256 CUs), ROCm 7.2.2, torch 2.10.0, Triton 3.8.0, FlyDSL 0.5.3. PR
02598fa593, main3486e43ba. Geomean speedup, > 1 means this PR is faster.aiter.mqa_logits(), 24 GLM-5 shapes (H32 D128)The 960-case sweep is
op_tests/test_flydsl_fp8_mqa_logits.py --scenario bench --fullover:Every case is graded, then timed with HIP-graph replay (LLC flush per replay, median of 20 × mean of 50). All 960 cases pass on both trees. The PR and main shards alternated on one GPU. GLM-5 times are from
mqa_logits_tune.py --run_config.Per (num_heads, head_dim) and per window
Notes:
Testing
MI350X (gfx950) only; see "Validation and unverified scope".
Documentation
The tag grammar, route table and builder options are documented next to the code; this op has no user-guide page.
Dependencies
Breaking Changes
None for
flydsl_fp8_mqa_logitsandmqa_logits. One exported constant changes on gfx950:KERNEL_VARIANTS(exported fromaiter.ops.flydsl) now lists the routed tags plus the large-head fallback, not the old fixed registry. The old tags still build. Code that validates a tag by membership inKERNEL_VARIANTSshould callvariant_supported(tag, num_heads, head_size)instead;aiter.mqa_logitsdoes so in this PR.PR Self-Review
Reviewed revision
03f8253Behavior and intent
mqa_logits: FlyDSL rows are validated byvariant_supported. Without this, after this PR every GLM-5 FlyDSL row would silently run Triton.head_acc(default unchanged) reach its builder; its routes and split policy are unchanged.Validation and unverified scope
MI350X, ROCm 7.2.2, torch 2.10.0, Triton 3.8.0, FlyDSL 0.5.3:
FLYDSL_RUNTIME_ENABLE_CACHE=0 python op_tests/test_flydsl_fp8_mqa_logits.py --scenario verify: 152/152 in 33 s. With--full: 1833/1833.python op_tests/test_mqa_logits.py: passes.--scenario bench --fullon PR and main: 960/960 graded on both.mqa_logits_tune.pyon GLM-5, then--run_config: 24/24 within 10%.op_tests/tuning_tests/test_config_shape_collision.pypasses.black --checkandruff checkpass.Unverified:
mqa_logits()admits only head_dim 64 and 128.hipModuleUnloadduring capture), so it uses the fixedcu_oversub=4split. Output is unaffected. One eager call before capture gives the tuned split.PR-specific question
What would each changed op test fail on before this PR, and why is that coverage not already provided?
test_flydsl_fp8_mqa_logits.py):--full.bfe265224), all head_dim 512 cases failed (wrong logits or LDS overflow), and nothing else would have caught it.check_shipped_flydsl_rows_supported(test_mqa_logits.py): it fails when a shipped FlyDSL row would fall back to Triton, which was the state of all 24 GLM-5 rows after this PR's registry change.check_dispatches_shipped_rowexpects Triton wheneverflydsl_supportsis False, so it cannot catch this.Changed op tests
op_tests/test_flydsl_fp8_mqa_logits.py, still the single FlyDSL fp8_mqa_logits correctness and perf test:variantcolumn in the bench output;--shapes-csv(bench production shape dumps through the same path);-o(save the tables);--full.op_tests/test_mqa_logits.py:check_shipped_flydsl_rows_supported, the guard against silent Triton fallback described above.