Skip to content

[ASM] fix(mla): prevent gfx950 FP8 softmax underflow - #6422

Merged
zufayu merged 3 commits into
mainfrom
chefang/gfx950_fp8_softmax_underflow
Oct 14, 2026
Merged

zufayu merged 3 commits into
mainfrom
chefang/gfx950_fp8_softmax_underflow

Conversation

@fangche123

@fangche123 fangche123 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Refresh 16 gfx950 A8W8 MLA code objects with 448-scaled softmax numerators and compensated output normalization. Align the QH64 non-persistent output flag with the host ABI.

Add uniform and long-tail underflow regression coverage with persistent, LSE, and CP options.

Validation: all 16 updated code objects passed uniform and long-tail checks, including direct legacy-kernel and non-LSE CP tests.

Motivation

Technical Details

Test Plan

Test Result

Summary

Query = 1

Kernel: mla_a8w8_qh16_qseqlen1_gqaratio16_ps.co

KV = 1K

Batch Before (us) After (us) Change (us) Change (%)
1 15.00 14.99 -0.01 -0.1%
2 16.02 15.95 -0.07 -0.5%
4 16.79 16.76 -0.03 -0.2%
8 18.23 18.24 +0.01 +0.1%
16 17.35 17.02 -0.33 -1.9%
32 19.24 19.06 -0.18 -0.9%
64 23.02 22.95 -0.07 -0.3%

KV = 2K

Batch Before (us) After (us) Change (us) Change (%)
1 15.68 15.61 -0.06 -0.4%
2 16.32 16.76 +0.44 +2.7%
4 18.27 18.18 -0.09 -0.5%
8 19.63 19.53 -0.10 -0.5%
16 20.51 20.45 -0.06 -0.3%
32 23.56 23.53 -0.03 -0.1%
64 30.13 30.19 +0.06 +0.2%

KV = 4K

Batch Before (us) After (us) Change (us) Change (%)
1 18.90 18.94 +0.04 +0.2%
2 19.49 19.51 +0.02 +0.1%
4 21.72 21.72 -0.00 0.0%
8 22.68 22.69 +0.01 +0.1%
16 24.70 24.76 +0.06 +0.2%
32 30.43 30.32 -0.12 -0.4%
64 42.38 42.36 -0.02 0.0%

KV = 8K

Batch Before (us) After (us) Change (us) Change (%)
1 22.94 22.98 +0.04 +0.2%
2 23.58 23.55 -0.03 -0.1%
4 24.51 24.52 +0.01 0.0%
8 27.07 26.96 -0.11 -0.4%
16 31.68 31.66 -0.02 -0.1%
32 42.52 42.55 +0.03 +0.1%
64 69.28 69.32 +0.04 +0.1%

KV = 16K

Batch Before (us) After (us) Change (us) Change (%)
1 27.27 27.55 +0.29 +1.0%
2 27.58 27.58 +0.00 0.0%
4 29.80 29.85 +0.05 +0.2%
8 34.12 34.12 -0.00 0.0%
16 43.61 43.64 +0.03 +0.1%
32 69.24 69.23 -0.01 0.0%
64 125.27 125.35 +0.07 +0.1%

Query = 4

Kernel: mla_a8w8_qh16_qseqlen4_gqaratio16_v3_ps.co

KV = 1K

Batch Before (us) After (us) Change (us) Change (%)
1 17.57 17.63 +0.07 +0.4%
2 18.74 18.52 -0.22 -1.2%
4 20.74 20.78 +0.04 +0.2%
8 21.37 21.56 +0.19 +0.9%
16 23.25 23.33 +0.09 +0.4%
32 26.04 26.13 +0.09 +0.4%
64 33.27 33.45 +0.18 +0.6%

KV = 2K

Batch Before (us) After (us) Change (us) Change (%)
1 19.49 19.62 +0.13 +0.7%
2 21.40 21.49 +0.09 +0.4%
4 21.84 21.96 +0.12 +0.6%
8 24.29 24.41 +0.12 +0.5%
16 26.60 26.66 +0.06 +0.2%
32 32.66 32.69 +0.03 +0.1%
64 40.84 40.99 +0.15 +0.4%

KV = 4K

Batch Before (us) After (us) Change (us) Change (%)
1 21.89 21.97 +0.08 +0.4%
2 24.19 24.20 +0.01 0.0%
4 24.14 24.15 +0.01 0.0%
8 27.82 27.95 +0.13 +0.5%
16 32.02 32.31 +0.30 +0.9%
32 39.73 39.81 +0.08 +0.2%
64 57.77 57.94 +0.16 +0.3%

KV = 8K

Batch Before (us) After (us) Change (us) Change (%)
1 25.76 25.96 +0.19 +0.8%
2 26.57 26.67 +0.10 +0.4%
4 27.53 27.65 +0.12 +0.4%
8 32.92 32.99 +0.07 +0.2%
16 38.57 38.67 +0.10 +0.2%
32 56.66 56.84 +0.18 +0.3%
64 90.87 91.10 +0.23 +0.3%

KV = 16K

Batch Before (us) After (us) Change (us) Change (%)
1 30.79 30.83 +0.03 +0.1%
2 31.25 31.23 -0.02 -0.1%
4 34.05 34.35 +0.30 +0.9%
8 40.37 40.39 +0.02 +0.1%
16 55.66 55.82 +0.16 +0.3%
32 91.59 91.73 +0.13 +0.1%
64 152.27 152.64 +0.37 +0.2%

Persistent Latency: nhead=32

The same batch/KV matrix and 100-round alternating method were used. Latencies are medians in microseconds; nhead=16 measurements above are unchanged. Both 32-head groups loaded their own commit-snapshot code objects, not the 16-head kernels.

Query = 1

Kernel: mla_a8w8_qh32_qseqlen1_gqaratio32_ps.co

Identical binary in both commits: A/A control, not a measurement of the fix's overhead.

KV = 1K

Batch Before (us) After (us) Change (us) Change (%)
1 17.22 17.21 -0.01 -0.1%
2 17.87 17.78 -0.09 -0.5%
4 19.63 19.58 -0.05 -0.2%
8 20.54 20.48 -0.06 -0.3%
16 19.63 19.61 -0.02 -0.1%
32 22.08 22.10 +0.02 +0.1%
64 27.08 26.90 -0.18 -0.7%

KV = 2K

Batch Before (us) After (us) Change (us) Change (%)
1 17.36 18.05 +0.69 +4.0%
2 19.17 19.13 -0.04 -0.2%
4 21.15 21.18 +0.03 +0.2%
8 21.68 21.67 -0.01 0.0%
16 23.10 23.11 +0.00 0.0%
32 27.39 27.40 +0.00 0.0%
64 34.91 35.02 +0.11 +0.3%

KV = 4K

Batch Before (us) After (us) Change (us) Change (%)
1 21.28 20.90 -0.38 -1.8%
2 22.82 22.73 -0.09 -0.4%
4 23.77 23.70 -0.07 -0.3%
8 24.93 24.94 +0.01 0.0%
16 27.58 27.66 +0.08 +0.3%
32 34.73 34.73 +0.00 0.0%
64 49.57 49.57 -0.01 0.0%

KV = 8K

Batch Before (us) After (us) Change (us) Change (%)
1 25.00 24.49 -0.51 -2.0%
2 26.38 26.38 -0.00 0.0%
4 26.96 26.96 -0.00 0.0%
8 29.60 29.55 -0.05 -0.2%
16 35.11 35.17 +0.07 +0.2%
32 48.77 48.79 +0.02 0.0%
64 79.19 79.18 -0.01 0.0%

KV = 16K

Batch Before (us) After (us) Change (us) Change (%)
1 29.81 29.73 -0.08 -0.3%
2 31.51 31.42 -0.08 -0.3%
4 34.00 33.97 -0.03 -0.1%
8 37.93 38.05 +0.12 +0.3%
16 49.03 49.00 -0.02 -0.1%
32 78.33 78.33 +0.01 0.0%
64 135.34 135.31 -0.03 0.0%

Query = 4

Kernel: mla_a8w8_qh32_qseqlen4_gqaratio32_ps.co

This code object differs between the two commits.

KV = 1K

Batch Before (us) After (us) Change (us) Change (%)
1 22.41 22.76 +0.35 +1.6%
2 25.23 25.09 -0.14 -0.6%
4 25.38 25.18 -0.20 -0.8%
8 28.96 28.79 -0.17 -0.6%
16 33.43 33.31 -0.11 -0.3%
32 39.66 39.56 -0.10 -0.2%
64 49.10 49.05 -0.05 -0.1%

KV = 2K

Batch Before (us) After (us) Change (us) Change (%)
1 26.40 26.15 -0.24 -0.9%
2 28.93 28.77 -0.16 -0.5%
4 28.75 28.56 -0.19 -0.7%
8 33.98 33.69 -0.29 -0.9%
16 40.42 40.26 -0.16 -0.4%
32 49.27 49.08 -0.19 -0.4%
64 60.40 60.64 +0.24 +0.4%

KV = 4K

Batch Before (us) After (us) Change (us) Change (%)
1 29.59 29.36 -0.23 -0.8%
2 30.28 30.07 -0.21 -0.7%
4 32.16 31.90 -0.26 -0.8%
8 39.63 39.43 -0.20 -0.5%
16 50.08 49.87 -0.21 -0.4%
32 59.93 59.93 +0.00 0.0%
64 87.25 87.30 +0.06 +0.1%

KV = 8K

Batch Before (us) After (us) Change (us) Change (%)
1 35.71 35.50 -0.21 -0.6%
2 35.84 35.74 -0.10 -0.3%
4 38.47 38.35 -0.12 -0.3%
8 46.78 46.70 -0.07 -0.2%
16 60.88 60.86 -0.03 0.0%
32 86.83 86.76 -0.07 -0.1%
64 132.88 133.96 +1.08 +0.8%

KV = 16K

Batch Before (us) After (us) Change (us) Change (%)
1 42.25 42.26 +0.01 0.0%
2 43.68 43.71 +0.03 +0.1%
4 46.70 46.73 +0.02 +0.1%
8 59.43 59.34 -0.09 -0.2%
16 87.19 87.61 +0.42 +0.5%
32 133.09 133.47 +0.38 +0.3%
64 221.17 223.03 +1.86 +0.8%

Submission Checklist

Refresh 16 gfx950 A8W8 MLA code objects with 448-scaled softmax numerators and compensated output normalization. Align the QH64 non-persistent output flag with the host ABI.

Add uniform and long-tail underflow regression coverage with persistent, LSE, and CP options.

Validation: all 16 updated code objects passed uniform and long-tail checks, including direct legacy-kernel and non-LSE CP tests.
@fangche123
fangche123 requested review from a team and a balanced review from Copilot October 12, 2026 07:39
@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:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
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: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
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 6422 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

@github-actions github-actions Bot changed the title fix(mla): prevent gfx950 FP8 softmax underflow [ASM] fix(mla): prevent gfx950 FP8 softmax underflow Oct 12, 2026
@github-actions github-actions Bot added the ASM label Oct 12, 2026

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.

🟡 Changes recommended

CI only exercises the default QH16 path, leaving the advertised modes and QH64 ABI fix uncovered.

1 open finding
What changed in this PR

Adds gfx950 FP8 MLA softmax-underflow regression coverage for the scaled-numerator fix.

Changes:

  • Adds uniform and long-tail numerical references.
  • Supports persistent, LSE, and context-parallel modes via CLI options.
File Description
op_tests/​test_mla_fp8_softmax_underflow.py Adds the FP8 MLA regression harness.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Address PR #6422 review feedback with a default matrix covering persistent, LSE, CP, and the QH64 ABI fix while preserving explicit single-case CLI execution.

Replace unnecessary dict() calls with dictionary literals.

Validation: 10/10 gfx950 cases passed on MI355; CLI checks, Black, Ruff, and Python syntax checks passed.
Copilot AI balanced review requested due to automatic review settings October 12, 2026 08:00

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.

🔵 Needs a closer look

The sweep omits several refreshed kernels, including all non-LSE CP variants.

0 open findings

1 resolved since last review
Previously missed (1)

In code that hasn't changed since last review

Medium severity Force-returned LSE skips testing refreshed non-LSE code objects

op_tests/​test_mla_fp8_softmax_underflow.py:233

Forcing return_lse=True means the gfx950 non-LSE CP code objects are never exercised by this underflow regression: the default (16, 4, ..., 2) and (32, 4, ..., 2) cases can only select the LSE variants. Because those non-LSE binaries were refreshed independently, they could retain the original numerator-underflow bug unnoticed. Preserve the requested mode and merge/check non-LSE rank outputs using independently computed rank LSEs (as test_mla_flydsl.py does).

This issue also appears on line 301 of the same file.

🧠 Review effort: Balanced

Integrate the underflow checks into test_mla.py and test_mla_persistent.py, sharing the reference and metadata setup, and remove the standalone test file.

Keep the original parameter-driven random test loops and reference defaults. Run underflow checks only with explicit CLI options and supported head/query configurations.

Validated non-persistent and persistent/LSE/CP underflow cases, CLI dispatch, original-loop AST equivalence, and Ruff/diff checks.
Copilot AI balanced review requested due to automatic review settings October 12, 2026 10:56

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.

🟡 Changes recommended

Dedicated QH32 qseqlen1 and non-LSE CP code-object paths lack committed regression coverage.

2 open findings

🧠 Review effort: Balanced

Comment thread op_tests/test_mla_persistent.py Resolved
Comment thread op_tests/test_mla_persistent.py Resolved
@zufayu
zufayu requested a review from kaiyang-1 October 13, 2026 01:41
@zufayu
zufayu requested review from bingxche, valarLip and zufayu and removed request for kaiyang-1 October 13, 2026 04:44
@zufayu zufayu assigned zufayu and unassigned kaiyang-1 Oct 13, 2026
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.

4 participants