Skip to content

MI350 MLA ps mode BF16 case support mask0 - #4565

Merged
amd-ruitang3 merged 10 commits into
mainfrom
mmd/dev/mla_bf16_non_mask
Aug 10, 2026
Merged

amd-ruitang3 merged 10 commits into
mainfrom
mmd/dev/mla_bf16_non_mask

Conversation

@minmengdie

@minmengdie minmengdie commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

This PR wires a new causal control through the MLA decode path to enable selecting mask0 (non-causal) variants—primarily for gfx950 persistent BF16—and updates kernel metadata CSVs and test harnesses accordingly.

Technical Details

Add a causal kwarg to aiter.mla.mla_decode_fwd and forward it into the asm stage1 launcher / kernel heuristic selection.
Update gfx942/gfx950 MLA asm kernel registries (mla_asm.csv) to reflect causal routing and add gfx950 BF16 persistent mask0 entries.
Plumb causal through existing test drivers (and add a CLI toggle in the persistent test script).

Test Plan

python3 op_tests/test_mla_persistent.py -d bf16 -kvd bf16 -lse -n 16-128,1-4 --no-causal -b 1 16 128 -c 23 512 8192
python3 op_tests/test_mla_persistent.py -d bf16 -kvd bf16 -lse -n 16-128,1-4 -b 1 16 128 -c 23 512 8192

Test Result

nhead qseqlen nhead x qseqlen configs comparisons out-of-tol max abs err (out) max abs err (lse) max abs err (split_out) max abs err (partial_out) worst err / ref absmax
16 1 16 9 34 0 0.007812 1.907e-06 0.007812 0.002437 0.004878
16 2 32 9 34 0 0.007812 1.907e-06 0.007812 0.002532 0.005319
16 3 48 9 34 0 0.007812 1.907e-06 0.007812 0.002646 0.00565
16 4 64 6 23 0 0.007812 9.537e-07 0.007812 0.00322 0.005525
32 1 32 9 34 0 0.007812 1.907e-06 0.007812 0.003073 0.005128
32 2 64 9 34 0 0.015625 1.907e-06 0.015625 0.004231 0.005882
32 3 96 9 31 0 0.015625 1.907e-06 0.015625 0.002082 0.006211
32 4 128 6 23 0 0.007812 9.537e-07 0.007812 0.003063 0.004878
48 1 48 9 34 0 0.007812 1.907e-06 0.007812 0.002818 0.005348
48 2 96 9 31 0 0.007812 1.907e-06 0.007812 0.002058 0.004975
48 3 144 9 33 0 0.015625 1.907e-06 0.015625 0.001647 0.006369
48 4 192 6 22 0 0.007812 1.907e-06 0.007812 0.002005 0.004926
64 1 64 9 34 0 0.007812 1.907e-06 0.007812 0.003049 0.005236
64 2 128 9 34 0 0.007812 1.907e-06 0.007812 0.003056 0.004878
64 3 192 9 31 0 0.015625 1.907e-06 0.015625 0.002209 0.006061
64 4 256 6 22 0 0.007812 9.537e-07 0.007812 0.002258 0.004762
80 1 80 9 34 0 0.015625 1.907e-06 0.015625 0.003502 0.006579
80 2 160 9 31 0 0.007812 1.907e-06 0.007812 0.002173 0.005025
80 3 240 9 33 0 0.015625 1.907e-06 0.015625 0.002089 0.005814
80 4 320 6 22 0 0.007812 1.907e-06 0.007812 0.002327 0.005181
96 1 96 8 28 0 0.007812 1.431e-06 0.007812 0.003147 0.005051
96 2 192 9 31 0 0.015625 1.907e-06 0.015625 0.002299 0.005
96 3 288 9 33 0 0.015625 1.907e-06 0.015625 0.002085 0.005076
96 4 384 6 22 0 0.007812 9.537e-07 0.007812 0.001966 0.004785
112 1 112 6 23 0 0.007812 9.537e-07 0.007812 0.003099 0.004444
112 2 224 9 31 0 0.015625 1.907e-06 0.015625 0.002362 0.005682
112 3 336 9 31 0 0.015625 1.907e-06 0.015625 0.002142 0.005917
112 4 448 6 22 0 0.007812 1.907e-06 0.007812 0.001914 0.006098
128 1 128 6 23 0 0.007812 9.537e-07 0.007812 0.002672 0.005
128 2 256 9 31 0 0.015625 1.907e-06 0.015625 0.002294 0.005291
128 3 384 6 22 0 0.007812 9.537e-07 0.007812 0.002046 0.004695
128 4 512 6 22 0 0.015625 1.907e-06 0.015625 0.002133 0.005556

dtype = fp8, mode = nocausal

nhead qseqlen nhead x qseqlen configs comparisons out-of-tol max abs err (out) max abs err (out vs fp8 golden) max abs err (lse) max abs err (split_out) max abs err (partial_out)
16 1 16 9 43 17 0.148438 0.0429688 0.0686326 0.03125 0.0208367
16 2 32 9 43 15 0.179688 0.0332031 0.0796671 0.0332031 0.0426117
16 3 48 9 43 18 0.1875 0.0351562 0.0525725 0.0292969 0.0228309
16 4 64 9 43 18 0.171875 0.03125 0.0751386 0.0302734 0.0358335
32 1 32 9 43 14 0.134766 0.03125 4.93432 0.03125 0.0146825
32 2 64 9 43 17 0.15625 0.046875 0.0568733 0.046875 0.0232134
32 3 96 9 41 17 0.167969 0.0507812 0.0581069 0.0429688 0.0296482
32 4 128 9 43 21 0.195312 0.0507812 0.0753016 0.0507812 0.0303925
64 1 64 9 41 14 0.201172 0.0344238 0.0660622 0.0344238 0.0213577
64 2 128 9 41 18 0.1875 0.0371094 0.0808263 0.0371094 0.030175
64 3 192 9 40 15 2.96875 2.85938 1.39974 0.0390625 0.0194591
64 4 256 9 40 18 2.58984 2.59766 1.19264 0.0429688 0.0218984
128 1 128 9 43 18 0.1875 0.0390625 0.0738668 0.0390625 0.0297146
128 2 256 9 40 17 2.24414 2.25977 0.839362 0.0429688 0.0277818
128 3 384 9 42 19 2.71875 2.75 1.29877 0.0625 0.0283784
128 4 512 9 40 18 2.875 2.92188 1.59458 0.0625 0.0238754

Submission Checklist

@minmengdie
minmengdie requested review from a team and a lite review from Copilot August 5, 2026 01:51
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:triton-300x Run an additional Triton test job on MI300X in PRs; main branch always runs both MI35X and MI300X
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 4565 --add-label <label>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR wires a new causal control through the MLA decode path to enable selecting mask0 (non-causal) variants—primarily for gfx950 persistent BF16—and updates kernel metadata CSVs and test harnesses accordingly.

Changes:

  • Add a causal kwarg to aiter.mla.mla_decode_fwd and forward it into the asm stage1 launcher / kernel heuristic selection.
  • Update gfx942/gfx950 MLA asm kernel registries (mla_asm.csv) to reflect causal routing and add gfx950 BF16 persistent mask0 entries.
  • Plumb causal through existing test drivers (and add a CLI toggle in the persistent test script).

Reviewed changes

Copilot reviewed 8 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
op_tests/test_mla.py Passes causal into mla_decode_fwd calls so decode tests can control masking behavior.
op_tests/test_mla_persistent.py Threads a new causal parameter through the persistent test pipeline and adds --causal/--no-causal CLI support.
hsa/gfx950/mla/mla_asm.csv Updates decode entries to causal=1 and adds BF16 persistent mask0 (non-causal) kernel rows for gfx950.
hsa/gfx942/mla/mla_asm.csv Updates decode entries’ causal field to align with new dispatch expectations.
csrc/py_itfs_cu/asm_mla.cu Extends the C ABI for stage1 decode with a causal parameter and uses it in kernel selection.
csrc/kernels/mla/metadata/v1_2_device.cuh Makes batch_tail adjustment conditional on params.is_causal to support non-causal behavior.
aiter/ops/attention.py Updates the @compile_ops signature for mla_decode_stage1_asm_fwd to include causal.
aiter/mla.py Adds causal to mla_decode_fwd and forwards it into stage1 asm decode calls.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread aiter/mla.py Resolved
Comment thread csrc/py_itfs_cu/asm_mla.cu Resolved
@zufayu
zufayu requested a review from amd-ruitang3 August 6, 2026 02:34
@fangche123
fangche123 requested a review from shengnxu August 7, 2026 01:41
@amd-ruitang3
amd-ruitang3 merged commit 45ef304 into main Aug 10, 2026
42 checks passed
@amd-ruitang3
amd-ruitang3 deleted the mmd/dev/mla_bf16_non_mask branch August 10, 2026 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants