Skip to content

[Triton/Gluon] [Config] Add gfx1250 A16W16 GEMM configs for FLUX.2 shapes - #4851

Merged
valarLip merged 2 commits into
ROCm:mainfrom
sogalin:gfx1250-gemm
Aug 21, 2026
Merged

valarLip merged 2 commits into
ROCm:mainfrom
sogalin:gfx1250-gemm

Conversation

@sogalin

@sogalin sogalin commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Two commits. The first adds tuned GEMM-A16W16 tile configs for the FLUX.2
projection shapes on gfx1250; without a matching config they fall back to
BLOCK_M=32, BLOCK_N=64. The second adds the tuned_gemm dispatch table that
actually routes those shapes to Triton — without it, lookups fall through to
the default libtype torch and FLUX.2 stays on hipBLASLt no matter how well
the Triton side is tuned.
Config-only; no kernel or Python changes, and nothing outside gfx1250 with
these exact shapes is affected.

Backend choice is measured, not assumed

Every (M,N,K) FLUX.2-dev feeds to tgemm at 512x512, 1024x1024 and 2048x2048
was collected with AITER_TUNE_GEMM=1 and timed both ways. Triton takes 23 of
the 27 shapes, by 1.5x to 9.4x, peaking at ~613 TFLOP/s on a 96 CU gfx1250
The four that stay on torch are the useful ones, because a plain "large M
means Triton" rule gets them wrong: the two M=1 modulation projections, and
M=1024 with an N or K of 128, where Triton is 2.2x to 2.6x slower.

NUM_BUFFERS is deliberately capped at 2

NUM_BUFFERS >= 3 benchmarks faster but is not run-to-run deterministic on
this architecture: repeated launches on identical inputs disagree on thousands
of elements. Every tile config here uses NUM_BUFFERS=2, which measured zero
mismatches. Please keep this in mind if these files are ever re-tuned.

Validation

  • Bit-exact against torch on all 27 shapes, and deterministic across repeated
    launches; Triton is only selected where both hold.
  • End-to-end FLUX.2-dev on gfx1250,
    12 steps, median of repeated runs on an otherwise idle GPU, measured with the
    companion SGLang change that routes linear layers through tgemm:
    Resolution hipBLASLt aiter Speedup
    512x512 1.08 s/step 0.22 s/step 4.9x
    1024x1024 3.06 s/step 0.55 s/step 5.6x
    2048x2048 11.71 s/step 2.39 s/step 4.9x

Submission Checklist

The gfx1250 GEMM-A16W16 fallback (BLOCK_M=32, BLOCK_N=64) leaves the FLUX.2
projection shapes at ~270 TFLOP/s; tuned per-shape tiles reach ~840 TFLOP/s
on a DPX partition (96 CU). Shapes are resolution-independent, so the M
buckets cover 512x512 through 2048x2048.

NUM_BUFFERS is held at 2 throughout. Three or more buffers is measurably
faster (~934 TFLOP/s) but not run-to-run deterministic on this arch:
repeated launches on identical inputs disagree on thousands of elements.
@sogalin
sogalin requested a review from a team August 19, 2026 08:57
@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 4851 --add-label <label>

PR title tags:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf] and op tags like [MLA] are left untouched. Add the no-auto-title label to opt this PR out of title tagging.

@github-actions github-actions Bot changed the title [config] Add gfx1250 A16W16 GEMM configs for FLUX.2 shapes [Triton/Gluon] [Config] Add gfx1250 A16W16 GEMM configs for FLUX.2 shapes Aug 19, 2026
The tile configs from the previous commit only take effect once a caller
actually reaches the Triton kernel. tuned_gemm has no gfx1250 rows for these
shapes, so lookups fall through to the default libtype "torch" and FLUX.2 stays
on hipBLASLt regardless of how well the Triton side is tuned.

Adds the dispatch table for every (M,N,K) FLUX.2-dev feeds to tgemm at 512x512,
1024x1024 and 2048x2048, collected with AITER_TUNE_GEMM=1. Each shape was timed
both ways and the winner recorded; triton takes 23 of the 27, by 1.5x to 9.4x.

The four that stay on torch are the interesting ones, because a plain "large M
means triton" rule gets them wrong: the two M=1 modulation projections, and
M=1024 with an N or K of 128, where triton is 2.2x to 2.6x slower.

Triton is only selected where it is also bit-exact against torch and
deterministic across repeated launches on identical inputs.

@Dewei-Wang-sh Dewei-Wang-sh 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

@valarLip
valarLip merged commit 4bb7f1f into ROCm:main Aug 21, 2026
69 checks passed
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.

3 participants