Skip to content

[HIP] [JIT] feat(dsv41): silu_mul_mxfp8, SiLU-mul + group-32 MXFP8 quant in one launch (bit for bit silu_and_mul + quant) - #8871

Open
yhl-amd wants to merge 1 commit into
ROCm:mainfrom
yhl-amd:hyi/dsv41-silu-mul-mxfp8
Open

yhl-amd wants to merge 1 commit into
ROCm:mainfrom
yhl-amd:hyi/dsv41-silu-mul-mxfp8

Conversation

@yhl-amd

@yhl-amd yhl-amd commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Motivation

DeepSeek-V4.1's shared expert is a native MXFP8 module (group-32 E8M0 scales) that runs apart from the routed experts. On its dense path (the three DSpark draft layers every decode step, target-layer row counts the routed MegaMoE call does not fuse, and prefill) the chain is gate_up GEMM -> silu_and_mul -> quantize_fp8 -> w2 GEMM: silu_and_mul writes the BF16 product and the next launch reads it back only to quantize it to group-32 MXFP8 for w2.

This PR adds one op that does both in one launch, bit for bit the two launches it replaces.

What it adds

New JIT module module_dsv41_seg_fuse (its own sources; built with module_activation's flags; no existing module or source is touched, and nothing is imported from aiter/__init__, so a process that never calls it never builds it):

aiter.ops.dsv41_seg_fuse.silu_mul_mxfp8(input [.., 2d] bf16, limit=0.0, out=None, scale=None)
    -> (q [.., d] e4m3, scale [.., d/32] e8m0, row-major)
  • csrc/kernels/dsv41_seg_fuse_kernels.cu: act_and_mul_kernel<bf16, bf16, silu, 8, HAS_LIMIT> (activation_kernels.cu) copied statement for statement (same clamp, same v_pk_mul_f32, same launch geometry), with MegaMHCQuantOutput<true>::store (mega_mhc.cu) as its epilogue: the product is rounded to BF16 and the quant reads those BF16 bits (amax floor 1e-10, E8M0 = ceil_pow2(amax / 448), E4M3 RNE via cvt_scalef32_pk_fp8_bf16). A lane quad owns one group of 32.
  • csrc/include/dsv41_seg_fuse.h, csrc/pybind/dsv41_seg_fuse_pybind.cu, aiter/ops/dsv41_seg_fuse.py, optCompilerConfig.json entry.
  • gfx950 only (the kernel body is compiled for gfx950; the ATOM caller checks the arch). d must be a multiple of 32.

Why not the existing silu_and_mul_quant: its FP8 path quantizes the FP32 product with an FP32 scale (amax / 448), so its codes differ from silu_and_mul + group-32 MXFP8 of the BF16 result, which is what w2's native MXFP8 GEMM would compute. This op keeps the numerics of the unfused chain exactly.

Provenance

The kernel comes from the DeepSeek-V4.1 DEP8 AgentX PoC: coderfeli/plugin_poc PR #129 (commit 158b4b5, csrc/kernels/dsv41_seg_fuse_kernels.cu in its AITER patch), author Bin Ding. The kernel body is unchanged; this PR renames comments, adds the op test and formats with clang-format. The commit carries Co-authored-by: Bin Ding.

Correctness

op_tests/test_dsv41_seg_fuse.py (torch.equal on codes and scales) against aiter.silu_and_mul followed by a torch group-32 MXFP8 reference: rows 1..16384 (33 counts), d in {2304, 32, 512, 1536, 4096}, limit 10 and 0, three seeds, with an all-zero row (amax floor), values at/beyond the clamp, 1e-30-scale rows and a row with silu ~ 0.

GPU results (MI355X, gfx950): op_tests/test_dsv41_seg_fuse.py 284 passed, 48 skipped (the skips are rows > 1024 at widths other than 2304, by design), 0 failed; tested by overlaying this PR's files on the AITER build of the rocm/atom-dev:nightly_202611251520 image (fb3f506); the module builds on its own. Also checked under torch.compile(fullgraph=True, dynamic=True) and inside a captured HIP graph (replay on new inputs): identical bytes.

ATOM-side checks (ROCm/ATOM#3940): the op against silu_and_mul + ATOM quantize_fp8, and the real DeepSeek-V4.1-Flash shared-expert chain (layers.10/39, mtp.0/2) fused vs unfused: 894 op cases (widths 2304 / 320 / 576 / 32 / 4096, limit 10 and 0, 1-16,384 rows, 3 seeds, edge rows), 0 mismatches; chain: 4 checkpoint shared experts x 33 row counts x limit 10 / 0, 0 mismatches, and flipping one FP8 code of the op's output changes the w2 output (the comparison is sensitive).

Performance

Per launch, CUDA-graph back to back, one MI355X, V4.1-Flash shared expert (d = 2304), µs:

rows silu_and_mul quantize_fp8 silu_mul_mxfp8 saved
1 2.47 2.30 2.56 2.21
64 2.80 2.25 2.86 2.19
186 3.11 2.30 3.20 2.21
512 3.61 2.39 3.61 2.40
4096 11.51 5.54 11.35 5.70
16384 38.29 21.79 36.83 23.25

End to end (DeepSeek-V4.1-Flash, MI355X DEP8, InferenceX AgentX, SA-compliant configuration: 48 local experts / top-6, FP8 shared expert computed separately, draft layers not merged, BF16 draft lm_head; 900 s per run, runs ordered A,B,B,A on the same node; B = this op plus the FFN-seam MXFP8 input of ROCm/ATOM#3940, A = without; both arms on the same AITER build):

conc total tok/s (A -> B) P90 interactivity TPOT p90
512 300,952 -> 301,223 (+0.09%) 140.05 -> 140.5 (+0.32%) 7.14 -> 7.115 ms
128 83,393 -> 85,402 (+2.41%, one run; +0.12% excluding it, within noise) 222.1 -> 223.15 (+0.47%) 4.505 -> 4.48 ms

GSM8K (no fixed acceptance length): B 0.9325 ± 0.0069, A 0.9303 ± 0.0070; DSpark acceptance 0.4859 vs 0.4869. Both P90 runs of B are above both runs of A at both concurrencies; the gain is small (the launches it removes are ~2 µs each) and is not claimed beyond "no regression, fewer launches".

Consumers

ROCm/ATOM#3940 (uses it on the dense shared-expert path when aiter.ops.dsv41_seg_fuse imports and the GPU is gfx950; otherwise ATOM keeps the unfused launches).

🤖 Generated with Claude Code

…uant in one launch

New JIT module module_dsv41_seg_fuse (own sources, module_activation's
flags; no existing module is touched) with one op:

  silu_mul_mxfp8(input [.., 2d] bf16, limit) -> (q [.., d] e4m3, scale [.., d/32] e8m0)

The kernel is act_and_mul_kernel<bf16, bf16, silu, 8, HAS_LIMIT>
(activation_kernels.cu) copied statement for statement, with
MegaMHCQuantOutput<true>::store (mega_mhc.cu) as its epilogue: the product
is rounded to BF16 and the group-32 MXFP8 quant reads those BF16 bits.
Output is bit for bit silu_and_mul followed by the group-32 MXFP8 quant
(ATOM quantize_fp8 / Mega-MHC out_dtype="mxfp8"). gfx950 only.

The kernel comes from the DeepSeek-V4.1 DEP8 AgentX PoC
(coderfeli/plugin_poc PR ROCm#129, commit 158b4b5, by Bin Ding).

op_tests/test_dsv41_seg_fuse.py: torch.equal against silu_and_mul + a
torch group-32 MXFP8 reference, 1..16384 rows, d in {32..4096}, limit
10 and 0, zero rows, values at/beyond the limit, tiny magnitudes.

Co-authored-by: Bin Ding <Bin.Ding@amd.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yhl-amd
yhl-amd requested a review from a team November 27, 2026 18:37
@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 8871 --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 feat(dsv41): silu_mul_mxfp8, SiLU-mul + group-32 MXFP8 quant in one launch (bit for bit silu_and_mul + quant) [HIP] [JIT] feat(dsv41): silu_mul_mxfp8, SiLU-mul + group-32 MXFP8 quant in one launch (bit for bit silu_and_mul + quant) Nov 27, 2026
yhl-amd added a commit to yhl-amd/ATOM that referenced this pull request Nov 27, 2026
… one launch (silu_mul_mxfp8)

On the dense shared-expert path (the three DSpark draft layers every step,
and target-layer row counts the routed MegaMoE call does not fuse,
prefill included) silu_and_mul wrote the BF16 product and w2's native
group32 FP8 GEMM then quantized it (quantize_fp8). AITER's silu_mul_mxfp8
(module_dsv41_seg_fuse, ROCm/aiter#8871) does both in one launch: the
product is rounded to BF16 and quantized with the same group-32 MXFP8
math, so w2 gets the same codes and E8M0 scales.

- model_ops/activation.py: silu_mul_mxfp8_available() (gfx950 and an
  AITER with the op; otherwise the unfused path is kept) and the
  silu_mul_mxfp8_fuse custom op.
- Expert.w2_takes_silu_mul_mxfp8(): a native group32 FP8 w2 (not the BF16
  fallback) whose padded input width is a multiple of 32 and half the
  gate_up output; Expert.forward uses it for an ungated call. The Triton
  fused_clamp_act_mul path (ATOM_V4_USE_TRITON_FUSION) keeps precedence.
- tests: which experts take it, the call wiring, the op against
  silu_and_mul + quantize_fp8 byte for byte, and real-checkpoint shared
  experts (layers.10/39, mtp.0/2) against the fully unfused chain.

Kernel from the DeepSeek-V4.1 DEP8 AgentX PoC (plugin_poc PR ROCm#129, Bin Ding).

Co-authored-by: Bin Ding <Bin.Ding@amd.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aiter-bot

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision a278c7fa455a · 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_dsv41_seg_fuse.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.

This branch has not been deployed

No deployments
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.

2 participants