Repository navigation
[Triton/Gluon] Add gluon support for MXFP4 and MXFP8 quant kernel in gfx950 - #4383
Merged
Merged
Conversation
Contributor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
Contributor
Author
|
#4193 is the parent PR. |
NimitPtl
marked this pull request as draft
July 24, 2026 22:27
NimitPtl
marked this pull request as ready for review
July 27, 2026 18:50
Added pre fetch slight modification in bench script
…push-hw-cvt # Conflicts: # aiter/ops/triton/_gluon_kernels/gfx950/quant/quant.py # aiter/ops/triton/quant/quant.py # op_tests/op_benchmarks/triton/bench_quant_mxfp4.py
…ler team, now successfully uses the correct instruction
cagrikymk
previously approved these changes
Sep 29, 2026
azaidy
requested changes
Sep 30, 2026
…e mid-M configs - Drop the Python BLOCK_SIZE_M/N overrides in dynamic_mxfp4_quant and dynamic_mxfp8_quant; launch configs now come only from the JSON tables. - Tune the 33<=M<=1024 buckets (more, smaller CTAs) for MXFP4 and MXFP8. - Compute e8m0 scale bias in int32 before narrowing to uint8.
Replace lookup_tuned_config with lookup_config(table, axes, **values) and drop the "schema" key from the gfx950 mxfp4/mxfp8 JSON tables.
…ig, backend argument - Share the e8m0 scale math (common/utils.py), the tile store and the warp layout between the MXFP4 and MXFP8 Gluon kernels. - Extend select_leq_config to many axes and reject bad calls; add get_quant_config and drop lookup_config. - Add a keyword-only backend argument (None, "triton", "gluon") to dynamic_mxfp4_quant and dynamic_mxfp8_quant; the benchmark gets a gluon provider and the triton provider forces the Triton kernel. - Drop unused SCALING_MODE and waves_per_eu=0 from the Gluon launches; add num_warps and EVEN_M_N to the kernel repr keys. - Add CPU-only tests for the config lookup and the Gluon quant JSON tables; update the config docs.
NimitPtl
added a commit
that referenced
this pull request
Oct 7, 2026
…gfx1250 (#4894) * Merge branch 'ROCm:main' into quant_mxfp4 * Update bench_quant_mxfp4.py * Resolve formatting issues * Resolve formatting issues * Resolve formatting issues * Resolve formatting issues * Resolve typing deprecation and import formatting * Fix Ruff import and __all__ ordering * Replace deprecated typing.Tuple in quant module * Use PEP 604 unions for optional tensor annotations * Include instruction for mxfp4 qunatization. * Change hueristic Added pre fetch slight modification in bench script * Consolidate comments and fix formatting/duplicate imports * Modifying shapes to be tested * Remove the inline asm part as the test triton patch provided by compiler team, now successfully uses the correct instruction * Removing unwanted files * Removing json file * Migrate gfx950 Gluon mxfp4/mxfp8 quant tuning to JSON configs Also update mxfp4/mxfp8 quant test files with representative shapes covering the benchmark shape sweep. * COnfig file format change * Add MXFP4/MXFP8 gfx950/gfx1250 gluon quant kernels (squashed) * style: black-format bench_quant_mxfp4_fp8.py * refactor(quant): switch gfx1250 mxfp4/mxfp8 block-config to JSON rule trees Replace the hardcoded if/else tuning chains and the flat bucket-key config lookup with configs/gfx1250/gluon/quant/{quant_mxfp4,quant_mxfp8}/DEFAULT.json default+rules trees, resolved via config_utils.select_tuned_config. Drops the now-unused quant_config_utils module. * fix(quant): pin mxfp4 gfx1250 config lookup to arch=gfx1250 _mxfp4_gfx1250_config's launch config is also reused, unchanged, by the plain-Triton fallback kernel on non-gfx1250 archs. Without an explicit arch override, resolve_config_dir defaulted to the running arch, so the config lookup 404'd on every non-gfx1250 arch (e.g. gfx950), breaking every dynamic_mxfp4_quant call there -- including the gfx950 stochastic-rounding tests and downcast_to_mxfp_pow2_scale_fp4. * fix(quant): remove dead/broken leftover code in _mxfp4_pack_op from main merge The merge of main introduced main's own refactor splitting _mxfp4_quant_op into scale computation + a new _mxfp4_pack_op(qx, ...) helper that takes already-scaled qx. The merge left dead leftover lines inside _mxfp4_pack_op that referenced an undefined 'x' (not a parameter of this function) and recomputed an unused scale, causing a NameError at trace time (flagged by CI as ruff F821/RUF059). * perf(quant): narrow gfx1250 mxfp8 small-M tile width for K > 1024 For M <= 32, the launch config previously picked BLOCK_SIZE_N purely from a fixed element budget over BLOCK_SIZE_M, independent of K. Benchmark sweeps (repeated trials, not single samples) show that for K > 1024 a narrower 128-wide tile robustly beats the wider budget-derived tile -- more independent CTAs hides TDM latency better than one bigger transfer per CTA at this size. ~11-13% bandwidth improvement at M=8, K=3072/7168 (closes the largest lag vs the Triton fallback at these shapes). * refactor(quant): table-based mxfp8 small-M BLOCK_SIZE_N + tighten comments Replace inline if/else BLOCK_SIZE_N arithmetic for mxfp8's M<=32 branch with an explicit _MXFP8_SMALL_M_BLOCK_SIZE_N lookup table + helper. Also shorten a duplicated multi-line comment in the gluon kernel and condense select_tuned_config's docstring. * Address PR review comments: bucket-key config lookup, kernel repr, lazy Gluon import, config dir rename, trim redundant test shapes - Replace the rule-tree select_tuned_config with lookup_tuned_config, a flattened bucket-key resolver ({schema, "M_GEQ_33.N_LEQ_16384": {...}, "any": {...}}) matching unified_attention_utils's existing pattern. - Add make_kernel_repr-based repr= to both gfx950 Gluon quant kernels. - Move the gfx950 Gluon kernel imports in quant.py out of the module header into the arch-gated dispatch branches that use them. - Rename configs/gfx950/gluon/quant/{mxfp4,mxfp8}_quant -> {mxfp4,mxfp8} to match the sibling PR's naming convention. - Drop one of three redundant large-non-square shapes from the mxfp4/ mxfp8 quant parametrize lists. * fix(quant): address gfx950-PR review feedback applicable to gfx1250 - Replace select_tuned_config's invented default+rules JSON schema with the repo's established composite bucket-key format (config_utils. lookup_config), matching the pattern used by unified_attention/gemm/ conv config families. Flattens mxfp4/mxfp8 DEFAULT.json into complete, mutually exclusive buckets instead of stacked rules. - Add repr= (make_kernel_repr) to the two launched gfx1250 gluon kernels so tuned specializations are distinguishable in traces/artifacts. - Make the gluon kernel import lazy, gated behind the gfx1250 arch check, matching gemm_a16w16.py's pattern -- importing aiter.ops.triton. quant.quant no longer unconditionally pulls in triton.experimental.gluon. - Rename configs/gfx1250/gluon/quant/{quant_mxfp4,quant_mxfp8} to {mxfp4_quant,mxfp8_quant} to align directory naming with the gfx950 sibling PR (#4383). * docs(quant): shorten config lookup docstrings and comments * docs(quant): shorten config lookup and gfx950 kernel comments * revert(quant): restore _triton_kernels/quant/quant.py to main (drop unneeded fp32-cast removal) * Update quant.py * Move gfx950 Gluon quant shape-derived block sizes into JSON and retune mid-M configs - Drop the Python BLOCK_SIZE_M/N overrides in dynamic_mxfp4_quant and dynamic_mxfp8_quant; launch configs now come only from the JSON tables. - Tune the 33<=M<=1024 buckets (more, smaller CTAs) for MXFP4 and MXFP8. - Compute e8m0 scale bias in int32 before narrowing to uint8. * Use lookup_config for gfx950 Gluon quant configs to match the sibling PR Replace lookup_tuned_config with lookup_config(table, axes, **values) and drop the "schema" key from the gfx950 mxfp4/mxfp8 JSON tables. * perf(quant): retune gfx1250 gluon mxfp4/mxfp8 configs; JSON is gluon-only - Re-tune per-bucket block/warp/buffer configs via the dispatch path with cold inputs (old config kept as a candidate); mxfp4 +10.6%, mxfp8 +5.4% geomean vs previous gluon configs. - Move the former in-code shape rules (small M / small N tile sizes) into the JSON buckets so the JSON is the single source of block sizes. - mxfp4: JSON is used only by the gfx1250 gluon launch; the Triton fallback is main's original heuristics again. - mxfp4: fix compile failures for M<=8 at N>1024 and M<=4 (wide BLOCK_SIZE_N at tiny BLOCK_SIZE_M) by using BLOCK_SIZE_N=128 tiles there. - Shorten comments/docstrings across the touched files. * bench_quant_mxfp4_fp8: match the gfx950 branch (drop duplicate line_vals, original comment) * gfx1250 quant: shared e8m0 helper, tile helpers, drop dead params, waves_per_eu in JSON, backend tests * gfx1250 quant: drop unreachable table entries, restore async_store note, add mxfp8 bucket shape * gfx1250 quant: int64 mxfp8 strides, overlap mxfp4 stores, infer table axes in get_quant_config * gfx1250 quant: retune mxfp4 bucket table (38 -> 30 keys) --------- Co-authored-by: Satya Nikhil Kodukula <[email protected]>
4 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Using gluon instead of triton for performance improvement
Technical Details
Test Plan
Test suite as well as benchmark script for speed of quant kernel. Test script for verifying accuracy.
Test Result
Focusing on MoE layers for GPTOSS and DSR1
Gluon gives positive numbers compared to triton.
Triton vs Gluon (gfx950) — mxfp4, bf16 input:
Triton vs Gluon (gfx950) — mxfp8, bf16 input,
float8_e4m3fn:Submission Checklist