Skip to content

[gfx950][FlyDSL] Add dense BF16 x MXFP4 GEMM - #4772

Draft
LiuYinfeng01 wants to merge 1 commit into
ROCm:mainfrom
LiuYinfeng01:feat/flydsl-gemm-a16wfp4-gfx950
Draft

[gfx950][FlyDSL] Add dense BF16 x MXFP4 GEMM#4772
LiuYinfeng01 wants to merge 1 commit into
ROCm:mainfrom
LiuYinfeng01:feat/flydsl-gemm-a16wfp4-gfx950

Conversation

@LiuYinfeng01

@LiuYinfeng01 LiuYinfeng01 commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Add a gfx950 FlyDSL dense GEMM for BF16 activations and packed MXFP4 weights.

  • consumes BF16 activations without requantization
  • decodes packed E2M1 weights with E8M0 scales into transient BF16 fragments
  • uses BF16 MFMA with FP32 accumulation
  • avoids both per-call full-weight dequantization and a persistent BF16 weight cache
  • preshuffles packed weights and scales once at model load
BF16 activation --------------------> BF16 MFMA -> BF16 output
packed MXFP4 weight -> BF16 decode --^

This is the fused MXFP4 weight-dequant + BF16 GEMM path used to preserve emulation semantics. Direct A4W4 is intentionally out of scope and will be proposed separately.

Accuracy

Reference: canonical MXFP4 weight decode to BF16 followed by BF16 F.linear on the original activation. Deterministic random packed weights, E8M0 scale 0x7f, M=128.

N x K Existing Triton A4W4 relative L2 This PR relative L2 Existing exact This PR exact
1024 x 3584 11.2099% 0.001776% 1.6022% 99.9924%
3584 x 512 11.2433% 0.001118% 1.5878% 99.9996%

The existing Triton path requantizes arbitrary BF16 activations to MXFP4, while this kernel preserves BF16 activation semantics. When activations already lie on the MXFP4 grid, all paths are exactly equal to the reference.

Latency

MI355X (gfx950), PyTorch 2.11.0+gitd0c8b1f, HIP 7.2.53211, FlyDSL 0.3.0. Weight preparation and JIT compilation excluded.

This PR was 1.75x-4.86x faster than the faster existing AITER Triton path across the measured Kimi-K3 TP2 shapes.

N x K M Existing best This PR Speedup
1024 x 3584 1 27.881 us 10.645 us 2.62x
1024 x 3584 512 29.059 us 16.589 us 1.75x
1024 x 3584 4096 214.094 us 44.048 us 4.86x
3584 x 512 1 28.659 us 8.360 us 3.43x
3584 x 512 512 29.730 us 10.912 us 2.72x
3584 x 512 4096 144.385 us 33.172 us 4.35x

Packed weights plus scales use 73.44% less storage than cached BF16 weights. Warmed launches with preallocated output add zero bytes of peak PyTorch allocation.

Validation

  • 13 passed: op_tests/flydsl_tests/test_flydsl_gemm_a16wfp4.py
  • arbitrary BF16 activations against canonical decode + BF16 F.linear
  • all E2M1 codes and E8M0 edge classifications
  • packed-storage and no-full-BF16-allocation checks
  • Ruff, Black, py_compile, and git diff --check

Scope

  • gfx950 only
  • packed MXFP4 weights and E8M0 scales are preshuffled once by the caller
  • N and K must be divisible by 256
  • downstream vLLM integration will select this path before falling back to a cached BF16 emulation weight

@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; main branch always runs both MI35X and MI300X
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: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
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 4772 --add-label <label>

@LiuYinfeng01
LiuYinfeng01 force-pushed the feat/flydsl-gemm-a16wfp4-gfx950 branch from e32145f to f45dc11 Compare August 15, 2026 02:17
Fuse MXFP4 weight decode with BF16 MFMA so emulation preserves Quark activation semantics without caching a full BF16 weight.
@LiuYinfeng01
LiuYinfeng01 force-pushed the feat/flydsl-gemm-a16wfp4-gfx950 branch 2 times, most recently from e489b19 to 7c880d2 Compare August 15, 2026 16:33
@LiuYinfeng01 LiuYinfeng01 changed the title [gfx950][FlyDSL] Add dense BF16 x MXFP4 GEMM [gfx950][FlyDSL] Add dense MXFP4 GEMMs Aug 15, 2026
@LiuYinfeng01
LiuYinfeng01 force-pushed the feat/flydsl-gemm-a16wfp4-gfx950 branch from 7c880d2 to e489b19 Compare August 16, 2026 02:37
@LiuYinfeng01 LiuYinfeng01 changed the title [gfx950][FlyDSL] Add dense MXFP4 GEMMs [gfx950][FlyDSL] Add dense BF16 x MXFP4 GEMM Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant