Skip to content

[Triton/Gluon] Add OPUS FP4 mode to the DSA cache writer - #7730

Closed
junhaha666 wants to merge 1 commit into
mainfrom
codex/dsa-opus-writer-review
Closed

junhaha666 wants to merge 1 commit into
mainfrom
codex/dsa-opus-writer-review

Conversation

@junhaha666

@junhaha666 junhaha666 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Move ATOM's DSA FP4 cache writer into AITER. This is the companion change for
ROCm/ATOM#3042 and its writer-ownership review.

Technical Details

  • Add scale_layout="opus" to indexer_qk_rope_quant_and_cache on gfx950.
    Support BF16 Q/K, H32/H64, D128, and NoPE/RoPE64.
  • Write OPUS packed data and E8M0 scales directly. Preserve unscaled head
    weights, negative-slot masking and the all-Q option used by DCP.
  • Keep the default FP8/FlyDSL HIP writer and existing positional arguments.
    No weight quantization or cache repacking is added.
  • Include the Triton wrapper, kernel, JSON config, tests and rotating-buffer
    benchmark. PR [HIP] [FlyDSL] Add OPUS FP4 MQA writer and query scale layouts #7128 supplies the V4 query/compressor APIs; this adds the DSA
    LayerNorm/QK writer mode.

Test Plan And Results

Validation below used the identical writer patch before rebase (84b57cf9b0
on main 0de43e662b, FlyDSL 0.4.1). The pushed commit a021b2e8dd is based on
main fb372c9c08, which requires FlyDSL >=0.5; that toolchain rerun is pending.

  • gfx950: 14 GPU tests pass, including an independent Torch reference,
    graph replay, strided inputs, negative/padded slots and writes beyond 4 GiB.
  • 16 migration comparisons with the previous ATOM writer pass byte-exactly
    for Q/K payloads, scales and head weights (M1/6/64/252, H32/H64, NoPE/RoPE).
  • Companion ATOM regression: 1065 passed, including native-writer integration
    through ATOM's DCP adapter and LMCache tests. This is not a full-model rerun.
  • Black, Ruff and diff checks pass. The benchmark completes all 12 default
    shapes; M6/H32 NoPE and RoPE64 measured 2.216 and 2.156 us. These are writer
    timings only, not Mono or end-to-end speedups.

@junhaha666
junhaha666 requested a review from a team November 10, 2026 10:32
@junhaha666 junhaha666 self-assigned this Nov 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

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

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
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 Radeon R9700 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 7730 --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.

Reviews:
A reviewer is usually assigned within one working day after the PR is ready for review (see Code Review Process). If nobody has responded for about a week, mention the area contact listed in CONTACTS.md. Want to help review? See REVIEWERS.md.

@github-actions github-actions Bot changed the title [Triton] Add OPUS FP4 mode to the DSA cache writer [Triton/Gluon] Add OPUS FP4 mode to the DSA cache writer Nov 10, 2026
@aiter-bot

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision a021b2e8dd1c · 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 exact workload keys consume these configuration changes, and what evidence shows that unrelated shapes keep their previous selection?
  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/op_benchmarks/triton/bench_indexer_qk_quant_and_cache_fp4.py
  • FAIL — changed op test not explained in Changed op tests: op_tests/triton_tests/fusions/test_indexer_qk_quant_and_cache_fp4.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.

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

An accepted strided Q view can overflow the int32 offset calculation at head 32, causing out-of-bounds reads before the Q buffer.

1 open issue
What changed in this PR

Moves ATOM’s DSA FP4 cache writer into AITER through an opt-in OPUS layout on gfx950, complementing the query and compressor APIs in #7128.

Changes:

  • Adds scale_layout="opus" while preserving the default HIP dispatch and existing positional arguments.
  • Adds a Triton wrapper, fused writer kernel and JSON configuration for BF16 Q/K with packed FP4 data and OPUS scales.
  • Adds reference, graph-replay, masking and large-offset tests, plus a rotating-buffer benchmark.
File Description
op_tests/​triton_tests/​fusions/​test_indexer_qk_quant_and_cache_fp4.py Tests output bytes, graph replay, input validation and dispatch compatibility.
op_tests/​op_benchmarks/​triton/​bench_indexer_qk_quant_and_cache_fp4.py Adds a rotating-buffer benchmark for writer shapes.
aiter/​ops/​triton/​fusions/​indexer_qk_quant_and_cache_fp4.py Validates tensors and launches the gfx950 OPUS writer.
aiter/​ops/​triton/​configs/​gfx950/​triton/​fusions/​indexer_qk_quant_and_cache_fp4/​DEFAULT.json Defines launch and floating-point fusion settings.
aiter/​ops/​triton/​_triton_kernels/​fusions/​indexer_qk_quant_and_cache_fp4.py Implements normalization, optional RoPE and direct OPUS FP4 writes.
aiter/​ops/​cache.py Adds OPUS dispatch while retaining the legacy HIP path.

Review effort: Balanced

MAX_POS: tl.constexpr,
):
token = tl.program_id(0).to(tl.int64)
task = tl.program_id(1)
@junhaha666

Copy link
Copy Markdown
Contributor Author

Superseded by #7798, which extends the existing fused HIP indexer writer with OPUS FP4 and NoPE support. ROCm/ATOM#3042 now uses #7798 through the same public API (ATOM commit f1485d59f). The HIP integration passed 1183 ATOM regression tests; eight graph-replay cases verify actual HIP launches, cache bytes/scales, and DCP adapter padding semantics. Closing this Triton alternative to keep a single writer implementation. The branch is retained for historical comparisons.

@junhaha666 junhaha666 closed this Nov 11, 2026
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.

3 participants