Skip to content

[ASM] mla_decode_fwd: wire is_causal through Python and C++ dispatch - #3993

Merged
amd-ruitang3 merged 1 commit into
mainfrom
alyr/mla-is-causal-bugfix
Oct 21, 2026
Merged

amd-ruitang3 merged 1 commit into
mainfrom
alyr/mla-is-causal-bugfix

Conversation

@alexioslyrakis-amd

@alexioslyrakis-amd alexioslyrakis-amd commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

For gfx950 BF16 decode with 8 query heads and 2 query tokens, both the masked and unmasked kernels are registered with causal=1. This gives causal dispatch two matching kernels (the current C++ heuristic selected the unmasked kernel in a CPU reproduction), while causal=False has no matching kernel.

Register the unmasked kernel with causal=0, leaving one correct match for each mode. Also allow the existing BF16 op test to exercise this non-causal gfx950 case instead of skipping it.

The Python-to-C++ causal parameter forwarding is already present on main via #4565. This patch uses the existing causal API and fixes the remaining dispatch regression for the original two-token case.

Validation:

  • Compiled the current get_heuristic_kernel_mla function in a CPU harness against the config header produced by hsa/codegen.py. Before the fix: zero non-causal matches and two causal matches. After the fix: one match per mode, selecting mla_a16w16_qh8_qseqlen2_gqaratio8.co for non-causal and mla_a16w16_qh8_qseqlen2_gqaratio8_causal.co for causal.

  • Evaluated the test support predicate over 600 architecture/dtype/head/query-length/causal combinations; only the intended gfx950 BF16 non-causal two-token case becomes enabled.

  • python3 -m black --check op_tests/test_mla.py, python3 -m ruff check op_tests/test_mla.py, and git diff --check pass.

  • On gfx950, run:

    python op_tests/test_mla.py -n 8,2 -c 64 -b 1 -d bf16 -kvd bf16 --causal
    python op_tests/test_mla.py -n 8,2 -c 64 -b 1 -d bf16 -kvd bf16 --no-causal

@alexioslyrakis-amd
alexioslyrakis-amd requested a review from a team June 29, 2026 09:47
@github-actions

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 3993 --add-label <label>

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

No activity for 15 days, so this is now labelled stale. A push or a comment clears it; keep-open exempts it.

@github-actions github-actions Bot added the stale The PR hasn't been updated in 2 weeks label Oct 7, 2026
Register the unmasked GQA=8, qseqlen=2 kernel with causal=0 so it no longer competes with the masked variant for causal=1 dispatch. Enable the existing BF16 op test for this non-causal gfx950 case.
@alexioslyrakis-amd
alexioslyrakis-amd force-pushed the alyr/mla-is-causal-bugfix branch from 33149d5 to d77199e Compare October 7, 2026 09:12
@alexioslyrakis-amd alexioslyrakis-amd changed the title mla_decode_fwd: wire is_causal through Python and C++ dispatch mla: fix causal dispatch for gfx950 BF16 two-token decode Oct 7, 2026
@github-actions github-actions Bot changed the title mla: fix causal dispatch for gfx950 BF16 two-token decode [ASM] mla_decode_fwd: wire is_causal through Python and C++ dispatch Oct 7, 2026
@github-actions github-actions Bot added ASM and removed stale The PR hasn't been updated in 2 weeks labels Oct 7, 2026
@alexioslyrakis-amd alexioslyrakis-amd self-assigned this Oct 15, 2026
@amd-ruitang3
amd-ruitang3 merged commit 0fdaf79 into main Oct 21, 2026
@amd-ruitang3
amd-ruitang3 deleted the alyr/mla-is-causal-bugfix branch October 21, 2026 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants