Repository navigation
[Triton/Gluon] [Kernel] Add MXFP4 dequant H16 requantization - #6476
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
There was a problem hiding this comment.
🟡 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.
5841ed9 to
9448589
Compare
9448589 to
a3f9919
Compare
a3f9919 to
5ac42f2
Compare
5ac42f2 to
d46e753
Compare
NOT READY FOR HUMAN REVIEWPR Self-ReviewRevision 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
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
2057a12 to
ae0bd42
Compare
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]>
ae0bd42 to
1c94d76
Compare



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
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_benchruns 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.Useful traffic is
17*M*K/16 + 64bytes (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
ae0bd42755e98788bc029ee9403c11dcffbcc2c2Behavior and intent
Add
dequant_hadamard_quant_mxfp4for 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_asynceven 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
ae0bd42755e98788bc029ee9403c11dcffbcc2c2on 2026-11-03. The PR contains one non-merge, DCO-signed kernel commit directly on main snapshotfa0100eb6055be56875de3c598a3eba896c0262a. The old fork dependency and merge commits are not in this PR's own commit list. The complete tree matches revision2057a12e50107592e17e3b005131059d87440f81correctly 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 andgit 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_asyncraises. 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_requiredat 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 usesresolve_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, withnum_warps=4andnum_stages=1.Every accepted gfx950 workload with packed FP4/E8M0 input, 32-aligned logical
(M, K),block_size=32,g=16, and theuse_sr,swizzle_scale,shuffle_data,in_scale_swizzledflags uses that same default entry.M/Kdetermine 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