Skip to content

[Triton/Gluon] [Kernel] Add MXFP4 dequant H16 requantization - #6476

Merged
azaidy merged 1 commit into
ROCm:mainfrom
DaiXindi-AMD:dai/mxfp4-dequant-h16-requant
Nov 5, 2026
Merged

azaidy merged 1 commit into
ROCm:mainfrom
DaiXindi-AMD:dai/mxfp4-dequant-h16-requant

Conversation

@DaiXindi-AMD

@DaiXindi-AMD DaiXindi-AMD commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add gfx950 dequant_hadamard_quant_mxfp4: packed MXFP4 + E8M0 scales -> BF16 dequantization -> transpose -> signed normalized H16 -> MXFP4 requantization in one kernel.

#6458 is merged. This PR now contains one DCO-signed kernel commit on main snapshot fa0100eb6055be56875de3c598a3eba896c0262a, with only the dequant-H16 operator and its shared support. It reuses the merged MXFP4 helpers and fused transpose API. No Lumen integration change is included.

API and implementation

  • Accepts uint8 or canonical packed FP4/E8M0 dtypes; logical dimensions must be multiples of 32.
  • Supports RTN/SR, Philox seed/offset, output scale swizzle/payload shuffle, and swizzled input scales. Swizzled inputs must be contiguous; ordinary input layouts support strides.
  • Preserves BF16 narrowing before H16, signed-zero behavior and raw E8M0 0/254/255 semantics (255 poisons the complete output scale block).
  • Includes wrapper, config-aware repr, required gfx950 tuning JSON, unit tests and benchmark. Reuses upstream quantization and shared H16/shuffle helpers.

Validation

Historical GPU result (d46e7536dd010733a42f028b97943ffb288f5c09): 104 passed across dequant-H16, dual-layout and quant-config tests on a single Slurm-visible MI355X, ROCm 7.2.4 / PyTorch 2.10.0 / Triton 3.8.0. Includes shared Philox boundary/type tests and regressions for noncontiguous swizzled scales, cached-sign graph capture and SR versus RTN payloads.

Checks: repository-wide Ruff 0.16.0 (CI pin), Black and whitespace validation. No new third-party dependency or existing-API breaking change. DCO signed.

Performance

Single Slurm-visible MI355X; five do_bench runs per provider (warmup=100 ms, rep=300 ms). Values are medians of those runs; useful bandwidth is calculated from the same latency, not measured HBM traffic. These historical measurements were taken before the review fixes and were not rerun at the current clean revision.

Shape Layout Fused us Decomposed us Effective bandwidth (GB/s)
4096x4096 plain 45.321 385.004 393.32
4096x4096 GEMM 47.600 399.925 374.49
12288x4096 plain 119.481 1101.132 447.58
12288x4096 GEMM 128.481 1136.772 416.23

Useful traffic is 17*M*K/16 + 64 bytes (packed input/output, scales and FP32 signs). On 4096x4096 plain RTN, a separate rocprofv3 run collected 15 dispatches; after five warmups the medians were 17,019,584 read-request bytes, 20,971,520 write-request bytes, and 815.88 GB/s combined TCC-to-DRAM request throughput. This is hardware-counter request traffic, not direct HBM bus utilization. Kernel metadata reports 12 VGPR / 48 SGPR and zero private/group segment sizes; runtime spill and occupancy were not measured.

MI355X specifications: 8 TB/s HBM and 157.3 TFLOP/s FP32 vector peak. The request throughput is 10.20% of advertised bandwidth; the largest-shape useful bandwidth is 5.59%. Source-level RTN arithmetic is approximately 8 FLOPs/element, or 7.53 FLOP/byte, below the theoretical 19.66 FLOP/byte ridge point. These estimates exclude integer/conversion/reduction overhead and do not establish the measured bottleneck. No HBM saturation or Lumen end-to-end speedup is claimed.

PR Self-Review

Reviewed revision

ae0bd42755e98788bc029ee9403c11dcffbcc2c2

Behavior and intent

Add dequant_hadamard_quant_mxfp4 for gfx950: packed E2M1 plus E8M0 scales -> BF16 dequantization -> transpose -> signed normalized H16 -> MXFP4 requantization. Existing single-output quantization and the merged fused transpose op do not accept this packed-input/dequantization contract. The op preserves BF16 narrowing, raw scale endpoints/NaNs, signed zero, RTN/SR and supported strided/plain/GEMM layouts.

It reuses main's device helpers and host layout constants. Single- and dual-stream wrappers share Philox validation/reservation. Shared sign validation detects capture before the eager cache, records _assert_async even after cached warmup, and updates the version cache only after successful eager validation. Replay runs the recorded GPU check, not Python dispatch. No old dual-layout implementation is reintroduced.

Validation and unverified scope

Reviewed ae0bd42755e98788bc029ee9403c11dcffbcc2c2 on 2026-11-03. The PR contains one non-merge, DCO-signed kernel commit directly on main snapshot fa0100eb6055be56875de3c598a3eba896c0262a. The old fork dependency and merge commits are not in this PR's own commit list. The complete tree matches revision 2057a12e50107592e17e3b005131059d87440f81 correctly merged into that same main snapshot, including unrelated upstream files and file modes.

All eight changed Python files passed Ruff 0.16.0 (ruff check --no-fix --no-cache), Black 26.10.1 and 26.3.0 (black --check --workers 1), Python compilation and git diff --check. Repository-wide Ruff also passed. Full-tree hash equality, old-to-new function AST/test/benchmark/config equivalence, exports, config/repr keys, deleted-module references and torch-free device imports were checked.

Standalone host utility checks, isolated execution of the actual Philox adapters and the copied shared-stream suite passed: 18 CPU cases. Mock capture-control-flow checks confirmed cached capture still records an assertion, capture does not update the eager cache, and missing _assert_async raises. These mocks are not GPU replay tests. Local checks used Python 3.12, PyTorch 2.13.0+rocm7.1, triton-rocm 3.7.1 and pytest 9.0.3; this is not a matched CI GPU environment.

For this SHA, Checks, Triton Test and Aiter Test were action_required at the 2026-11-03 check, awaiting maintainer approval. No new GPU/CI numerical result is claimed. Full AITER import/collection, GPU suites, invalid-sign GPU replay, benchmarks and wheel/prebuild were not run locally. No GPU allocation or dependency installation was made. The 104-test GPU and performance results above remain historical, not reruns of this SHA.

PR-specific question

The only new config family is DEQUANT-HADAMARD-QUANT-MXFP4. The wrapper uses resolve_config_dir("fusions", _CONFIG_NAME) and loads aiter/ops/triton/configs/gfx950/triton/fusions/dequant_hadamard_quant_mxfp4/DEFAULT.json, entry _dequant_hadamard_quant_mxfp4_kernel, with num_warps=4 and num_stages=1.

Every accepted gfx950 workload with packed FP4/E8M0 input, 32-aligned logical (M, K), block_size=32, g=16, and the use_sr, swizzle_scale, shuffle_data, in_scale_swizzled flags uses that same default entry. M/K determine runtime dimensions and (M // 32, K // 32) grid, not JSON buckets. The flags are kernel constexpr arguments; seed/offset select Philox streams, not configs. No existing config or config-loader file changes, so unrelated ops/shapes retain their previous config-selection paths. This source/diff check is not GPU validation of every unrelated shape.

Changed op tests

  • op_tests/triton_tests/quant/test_dequant_hadamard_quant_mxfp4.py: independent numerical references cover packed decode, BF16 narrowing, H16, scale endpoints/NaNs, signed zero, strides/layouts, SR versus RTN and input/capture validation. Needed because existing quantization tests do not cover the packed-input fused pipeline or cached-sign capture regression.
  • op_tests/triton_tests/quant/test_mxfp4_philox.py: covers disabled/single/dual-stream reservations, adjacent offsets, inclusive last-counter boundaries and invalid metadata. These CPU helper contracts are not established by GPU payload reproducibility tests.
  • op_tests/op_benchmarks/triton/bench_dequant_hadamard_quant_mxfp4.py: benchmark, not a numerical unit test. Compares fused and decomposed plain/GEMM-layout preparation and reports latency/useful bandwidth. Needed to measure fusion cost/benefit; correctness tests and single-output quantization benchmarks do not provide this comparison.

@DaiXindi-AMD
DaiXindi-AMD requested a review from a team October 13, 2026 08:31
@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 6476 --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 [Kernel] Add MXFP4 dequant H16 requantization [Triton/Gluon] [Kernel] Add MXFP4 dequant H16 requantization Oct 13, 2026
@Boss2002n
Boss2002n requested a balanced review from Copilot October 13, 2026 09:33

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

Graph-capture validation and noncontiguous swizzled-scale handling can produce incorrect behavior, and the dependency kernel must be removed from this diff.

5 open findings
What changed in this PR

Adds fused gfx950 MXFP4 dequantization, transpose, H16 rotation, and requantization for Lumen training.

Changes:

  • Adds the fused Triton kernel, wrapper, configuration, and export.
  • Introduces shared H16/MXFP4 layout helpers and the dependent dual-layout kernel.
  • Adds correctness tests and performance benchmarks.
File Description
op_tests/​triton_tests/​quant/​test_dual_layout_mxfp4.py Tests the dependency kernel.
op_tests/​triton_tests/​quant/​test_dequant_hadamard_quant_mxfp4.py Tests fused requantization behavior.
op_tests/​op_benchmarks/​triton/​bench_dual_layout_mxfp4.py Benchmarks the dependency kernel.
op_tests/​op_benchmarks/​triton/​bench_dequant_hadamard_quant_mxfp4.py Benchmarks fused versus decomposed execution.
aiter/​ops/​triton/​utils/​mxfp4.py Adds host-side layout and sign validation helpers.
aiter/​ops/​triton/​utils/​_triton/​mxfp4.py Adds reusable Triton H16/layout helpers.
aiter/​ops/​triton/​quant/​dual_layout_mxfp4.py Adds the dependency’s public wrapper.
aiter/​ops/​triton/​quant/​dequant_hadamard_quant_mxfp4.py Adds the new public wrapper.
aiter/​ops/​triton/​quant/​__init__.py Exports both APIs.
aiter/​ops/​triton/​configs/​gfx950/​triton/​fusions/​dual_layout_mxfp4/​DEFAULT.json Configures the dependency kernel.
aiter/​ops/​triton/​configs/​gfx950/​triton/​fusions/​dequant_hadamard_quant_mxfp4/​DEFAULT.json Configures the new kernel.
aiter/​ops/​triton/​_triton_kernels/​quant/​dual_layout_mxfp4.py Implements dual-layout quantization.
aiter/​ops/​triton/​_triton_kernels/​quant/​dequant_hadamard_quant_mxfp4.py Implements fused dequantization and requantization.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread aiter/ops/triton/utils/mxfp4.py Resolved
Comment thread aiter/ops/triton/quant/__init__.py Resolved
@zufayu
zufayu requested review from a team and Dewei-Wang-sh October 14, 2026 01:28
@DaiXindi-AMD
DaiXindi-AMD force-pushed the dai/mxfp4-dequant-h16-requant branch from 5841ed9 to 9448589 Compare October 14, 2026 01:48
@ZhangDanyang-AMD
ZhangDanyang-AMD force-pushed the dai/mxfp4-dequant-h16-requant branch from 9448589 to a3f9919 Compare October 14, 2026 02:18
@DaiXindi-AMD
DaiXindi-AMD force-pushed the dai/mxfp4-dequant-h16-requant branch from a3f9919 to 5ac42f2 Compare October 14, 2026 07:47
@Boss2002n
Boss2002n requested a balanced review from Copilot October 14, 2026 20:25

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

Shared Philox validation needs consolidation, and the acknowledged dependency merge and scope-cleanup rebase remain pending.

2 open findings
4 resolved since last review

🧠 Review effort: Balanced

@azaidy azaidy 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.

Please work towards merging #6458 first

@aiter-bot

aiter-bot commented Nov 3, 2026 •

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision 1c94d76a0d12 · 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 — Reviewed revision must contain at least the first 7 characters of the current head SHA

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

@DaiXindi-AMD
DaiXindi-AMD force-pushed the dai/mxfp4-dequant-h16-requant branch from 2057a12 to ae0bd42 Compare November 3, 2026 05:33
Add the gfx950 dequantization, transpose, signed H16 and requantization operator with its wrapper, configuration, tests and benchmark. Reuse the merged MXFP4 device helpers and share Philox reservation and capture-time sign validation with the fused transpose operator.

The clean contribution is based on current main and is tree-identical to the prior PR correctly merged into that same main snapshot. All eight changed Python files pass Ruff 0.16.0, Black, compile and diff checks; 18 isolated CPU shared-stream tests pass. GPU, cold AITER import and wheel/prebuild were not rerun.

Signed-off-by: DaiXindi-AMD <[email protected]>
@ZhangDanyang-AMD
ZhangDanyang-AMD force-pushed the dai/mxfp4-dequant-h16-requant branch from ae0bd42 to 1c94d76 Compare November 3, 2026 05:59

@azaidy azaidy 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.

LGTM!

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