Skip to content

[HIP] [FlyDSL] Add OPUS FP4 MQA writer and query scale layouts - #7128

Merged
valarLip merged 9 commits into
mainfrom
jun/mqa_v2_6952
Nov 8, 2026
Merged

valarLip merged 9 commits into
mainfrom
jun/mqa_v2_6952

Conversation

@junhaha666

@junhaha666 junhaha666 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Add the FP4 cache-writer and query-scale layouts used by ATOM's V4/V4.1 indexer with OPUS MQA, including H32 queries for V4.1 on MI355 (gfx950).

Changes

  • Fused compressor writers emit natural, gfx950 FlyDSL or gfx950 OPUS FP4 layouts directly; fp4_gfx950_opus selects the OPUS cache layout for both single-wave and K-split execution.
  • Add RoPE FP4 scale_layout="none"|"flydsl"|"opus" while preserving the legacy FlyDSL default and positional/keyword shuffle_scale calls. OPUS supports H32/H64, D128 and group size 32, with scales [T, 2, 32, H/16].
  • Preserve legacy fp4 / preshuffle behavior on gfx9 and natural rows on gfx1250; explicit gfx950 modes select their layouts. Keep legacy FP8 mode aliases and reject incompatible FP4 cache views.
  • Size rotate/quant launches using the runtime wave size, preserving gfx1250 wave32 coverage.

The scorer/API from #6952 is already merged into main. ATOM #2809 consumes both PRs; this diff contains the writer/query changes. Rebuild cached module_dsv4_rotate_quant when upgrading.

Validation

CPU wrapper checks and all five legacy-query GPU equality cases passed on gfx950; the query kernel was built from source. OPUS prefill/decode checks with automatic K-split passed. Writer coverage also checks independent natural-reference permutations, physical page mapping, guard pages and forced single-wave execution.

The single-wave padding scale error (255) is fixed by preserving -inf semantics through the softmax maximum and exponential arguments; protecting only comparisons was insufficient under fast-math. The accumulation and other kernel stages retain their compiler settings. On MI355, the full compressor op-test script completed successfully (159 invocations), covering both FP4 layouts, single-wave/K-split writers and masked-NaN cases, with unchanged tolerances. All 18 local query layout/compatibility GPU checks also passed.

MI355 integration performance

These measure the combined integration, not isolated writer speedups: ATOM 75cdfb334, this writer 5927993491, runtime AITER e6833294ff, upstream #6952 791fc88746.

V4.1 Flash, 4 x MI355 / TP4, c4, DSpark5, FP8 KV / FP4 index, Eager without graphs, 1024 output tokens; max sequences 4, batched tokens 512, model length 20480. Median of three warmed, unprofiled engine-E2E runs; target and draft use the listed path.

Input Path FlyDSL (s) OPUS layout (s)
8K Native 30.635 29.778
16K Native, latest repeat 34.340 34.100
8K Mono 6.450 6.353
16K Mono 8.954 8.931

Native 16K is effectively at parity; DSpark acceptance/tail work varies across repeats. GPU 3 had brief independent work during the latest repeat on GPUs 4-7, so host interference is possible. Mono measures its fused scorer reading the selected layout. See ATOM #2809 for per-run values and separate MQA trace timings.

Pending: gfx1250 V4.1 hardware/E2E/performance validation. The integration performance above was measured on the listed earlier revisions; E2E performance has not been rerun after the softmax fix.

@junhaha666
junhaha666 requested a review from a team October 29, 2026 05:21
@github-actions github-actions Bot changed the title [OPUS] Integrate updated MQA API with FP4 cache and query layouts [HIP] [OPUS] [FlyDSL] Integrate updated MQA API with FP4 cache and query layouts Oct 29, 2026
@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:windows Windows JIT op smoke test on the gfx1201 ROCm runner
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 7128 --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.

@junhaha666 junhaha666 changed the title [HIP] [OPUS] [FlyDSL] Integrate updated MQA API with FP4 cache and query layouts [HIP] [FlyDSL] Add OPUS FP4 MQA writer and query scale layouts Oct 29, 2026
@github-actions github-actions Bot changed the title [HIP] [FlyDSL] Add OPUS FP4 MQA writer and query scale layouts [HIP] [FlyDSL] Integrate updated MQA API with FP4 cache and query layouts Oct 29, 2026
@junhaha666 junhaha666 changed the title [HIP] [FlyDSL] Integrate updated MQA API with FP4 cache and query layouts [HIP] [FlyDSL] Add OPUS FP4 MQA writer and query scale layouts Oct 29, 2026
The launchers declared block_size = WARP_SIZE and m_block = vec_size *
WARP_SIZE / dim as const ints. A const int whose initializer is a constant
expression is constant-evaluated, so WarpSizeValue took its host fallback of
64. On gfx1250 (wave32) the kernels are compiled for 32 lanes and cover
vec_size * 32 / dim rows each, while the grid was sized for 64-lane blocks of
twice as many rows: half of the rows were never written. Without const the
initializers run at launch and read the device's wave size.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@aiter-bot

aiter-bot commented Oct 29, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision c3e515a2c989 · mode shadow

Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision.

Questions to answer in the PR description

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. Which architecture, dtype and shape boundaries select the changed kernel path, and what invariant prevents unsupported inputs from reaching it?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — missing ### Reviewed revision in the PR description
  • FAIL — missing ### Behavior and intent in the PR description
  • FAIL — missing ### Validation and unverified scope in the PR description
  • FAIL — missing ### PR-specific question in the PR description
  • FAIL — missing ### Changed op tests in the PR description
  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA
  • FAIL — Behavior and intent has no substantive answer
  • FAIL — Validation and unverified scope has no substantive answer
  • FAIL — PR-specific question has no substantive answer
  • FAIL — changed op test not explained in Changed op tests: op_tests/test_dsv4_rotate_quant.py
  • FAIL — changed op test not explained in Changed op tests: op_tests/test_flydsl_compress_attn.py
  • FAIL — Changed op tests must explain why each changed op test is necessary and non-redundant

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

@github-actions github-actions Bot changed the title [HIP] [FlyDSL] Add OPUS FP4 MQA writer and query scale layouts [HIP] [OPUS] [FlyDSL] Add OPUS FP4 MQA writer and query scale layouts Nov 3, 2026
@github-actions github-actions Bot added the OPUS label Nov 3, 2026
Keep the gfx950-specific FP4 layout guards while routing both gfx1250 variants to the wave32 compressor. Preserve upstream compressor changes.
@junhaha666

Copy link
Copy Markdown
Contributor Author

@aiter-bot review

@aiter-bot aiter-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ROCm/aiter PR #7128 — [HIP] [OPUS] [FlyDSL] Add OPUS FP4 MQA writer and query scale layouts

Review (advisory): ⚠️ NEEDS WORK
Validation (deterministic): NOT RUN — REVIEW_AUTO_VALIDATE=0 (auto-validation disabled; the required target op_tests/test_dsv4_opus_query_layout.py exists but was not run — environment gap, not a PR defect)
Perf (advisory): NOT RUN — target op_tests/test_dsv4_opus_query_layout.py exposes no benchmark entry point (no --scenario bench / perftest harness), so no base-vs-head timing of the changed writers exists; the PR's E2E table is the combined four-SHA ATOM integration, explicitly not isolated writer speedups

⚠️ [verified] No base-vs-head timing exists for any changed writer: the triaged target op_tests/test_dsv4_opus_query_layout.py exposes no benchmark entry point (no --scenario bench / perftest harness), and the run_perftest benches in the touched test files cover only the FlyDSL and natural fp4 modes, so the OPUS writer's latency is unmeasured — the PR's E2E table (e.g. 8K Native 30.635 s vs 29.778 s) is the combined ATOM integration across four pinned SHAs and cannot show a writer-level regression. Author must add a benchmark entry for the OPUS writer, or run the existing compress-attn bench base vs head on gfx950, and report the writer-level delta with its sample count.

📝 [verified] aiter/ops/quant.py is a Tier-2 downstream contract and this diff changes a public signature and its default semantics (shuffle_scale:bool=True → scale_layout:str="none"), with valarLip the de-facto owner by commit count (15 of ~40 commits on the file). Reviewer should ask valarLip to sign off on the rope_rotate_activation contract change before merge, on top of the downstream CI run.

📝 [verified] The WARP_SIZE const→runtime change in csrc/kernels/dsv4_rotate_quant.cu re-sizes all six rotate/quant launches on gfx1250 (block 64→32, grid roughly doubles; the const init const-folds to the host-pass fallback 64 per aiter_hip_common.h while the device kernel steps 32-lane rows on gfx1250), and the PR itself marks gfx1250 hardware/E2E validation as pending while no gfx1250 op-test job runs in the default CI set. Reviewer should ask for the pending gfx1250 run of op_tests/test_dsv4_rotate_quant.py before merge, since nothing else exercises the new launch geometry.

2 finding(s) posted inline, on the lines they are about:

  • aiter/ops/flydsl/kernels/fused_compress_attn.py:1163 — The new OPUS KV-cache writer ships with zero aiter-side coverage: the scale-offset formula is hand-copied…
  • aiter/ops/quant.py:1431 — Existing callers silently get different bytes with no error: aiter/ops/quant.py:1431 flips…

Comment thread aiter/ops/quant.py Resolved
@github-actions github-actions Bot changed the title [HIP] [OPUS] [FlyDSL] Add OPUS FP4 MQA writer and query scale layouts [HIP] [FlyDSL] Add OPUS FP4 MQA writer and query scale layouts Nov 6, 2026
@github-actions github-actions Bot removed the OPUS label Nov 6, 2026
amd-ruitang3
amd-ruitang3 previously approved these changes Nov 7, 2026
@github-actions

github-actions Bot commented Nov 8, 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: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:windows Windows JIT op smoke test on the gfx1201 ROCm runner
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 7128 --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.

@junhaha666 junhaha666 closed this Nov 8, 2026
@junhaha666 junhaha666 reopened this Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 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: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:windows Windows JIT op smoke test on the gfx1201 ROCm runner
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 7128 --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.

@valarLip
valarLip merged commit ef0a5a2 into main Nov 8, 2026
@valarLip
valarLip deleted the jun/mqa_v2_6952 branch November 8, 2026 14:48
ruanjm pushed a commit that referenced this pull request Nov 10, 2026
* [OPUS] Add FP4 MQA compressor and query scale layouts

* [HIP] Size the DSV4 rotate-quant launches with the runtime wave size

The launchers declared block_size = WARP_SIZE and m_block = vec_size *
WARP_SIZE / dim as const ints. A const int whose initializer is a constant
expression is constant-evaluated, so WarpSizeValue took its host fallback of
64. On gfx1250 (wave32) the kernels are compiled for 32 lanes and cover
vec_size * 32 / dim rows each, while the grid was sized for 64-lane blocks of
twice as many rows: half of the rows were never written. Without const the
initializers run at launch and read the device's wave size.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Support 32-head OPUS FP4 query scale layout

* fix(mqa): preserve legacy writer APIs and cover OPUS cache writes

* test(mqa): remove standalone query layout tests

* fix(flydsl): preserve padding infinities in compressor softmax

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants