Skip to content

[HIP] [FlyDSL] Add gfx1250 implicit-GEMM conv3d - #6662

Merged
coderfeli merged 27 commits into
mainfrom
feature/flydsl-conv3d-gfx1250
Nov 5, 2026
Merged

coderfeli merged 27 commits into
mainfrom
feature/flydsl-conv3d-gfx1250

Conversation

@huizzhan

@huizzhan huizzhan commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add a gfx1250 FlyDSL backend for flydsl_conv_implicit: host pre-pads to NDHWC with C/groups aligned to 32; A is loaded with rank-3 TDM boxes, B with 2D TDM tiles, compute via WMMA 16×16×32 bf16→f32.
  • The software pipeline mirrors compile_gemm_a16w16 on gfx1250: a prologue of num_buffers - 1 TDM tiles, an scf.for main loop with register-prefetched fragments, and a drain. Blocks of 1 to 16 waves; split-K (fp32 atomic staging), dyn_hw (runtime extents) and BIG_OUT (64-bit stores).
  • Tuning and deployment: gfx1250 candidate policy (conv3d_policy_gfx1250.py), csrc/flydsl_conv3d/conv3d_tune.py on gfx1250, AOT in aiter/aot/flydsl/conv.py, and tuned tables for the Qwen-Image VAE and Wan2.1 VAE (aiter/configs/model_configs/*_gfx1250_bf16_tuned_conv3d.csv). The tuner times prepared operands (host pads and weight pack done once), so the tables' us is the kernel alone; warmup/iterations, the fp32 reference and run_config follow the GEMM tuners.
  • Wire arch dispatch in conv_kernels.py (SUPPORTED_GFX includes gfx1250); fix conv3d_transpose LDS sync for gfx1250 (gpu.barrier instead of s_waitcnt).
  • Extend op_tests/test_flydsl_conv_implicit.py with gfx1250 tile/block_rows and a tail-block case.

Scope

  • Supported: bf16, NCDHW/NDHWC, stride/dilation, bias, groups, all padding_mode (host-side pad), split-K, dyn_hw, BIG_OUT.
  • Not in this PR: the kH×kW patch-reuse path (removed for now; patch_reuse is accepted and ignored on gfx1250). num_buffers / variant / main_loop_unroll exist as kernel knobs, but the tuner and the runtime use the defaults (2 / bandwidth_bound / off).

Accuracy

Retuned tables (2026-10-27): conv3d_tune.py checks every candidate it times against an fp32 F.conv3d reference (fp32 bias) rounded to bf16 and fails it on any element outside rtol=atol=2e-2; all 7440 candidates of the 76 shapes pass. Each of the 76 new rows, run 3 times through the tuner's call, the NDHWC entry point and the NCDHW entry point (tuned lookup), outputs NaN-filled before they are freed: zero elements outside rtol=atol=2e-2.

Candidate sweep (2026-10-26): every candidate the tuner enumerates for the 76 shapes of both gfx1250 tuned CSVs: 7444 configs (1/2/4/8/16-wave: 140 / 1259 / 3192 / 2164 / 689; 52 with split-K 2–4), each run 10 times against an fp32 CPU reference, with every output NaN-filled before it is freed. Zero elements outside rtol=atol=2e-2, no NaNs, no hangs. Called with torch's default NCDHW layout (flydsl_conv_implicit, NCDHW in/out, tuned lookup), the op matches F.conv3d on all 76 shapes. None of these shapes needs BIG_OUT.

Performance

gfx1250 (256 CUs), one card, 2026-10-27, retuned tables, FlyDSL 0.4.0. All times are run_perftest (5 warmup + 101 iterations, the tuner's measurement) on the same seeded inputs, average of two passes; per shape the passes agree within 3.5%, every sum within 0.1%. A monitor sampled the card's KFD processes every 10 s, and any record whose window saw another process holding VRAM was dropped and re-measured, so every number below was taken with no other process on the card.

Sum over shapes (us) Qwen-Image VAE (32 shapes) Wan2.1 VAE (44 shapes)
Kernel: NDHWC in/out, tuned tile, prepared operands (the tables' us) 10,189 14,002
NDHWC entry point: flydsl_conv_implicit, tuned lookup 24,883 24,400
NCDHW caller (torch's default layout): flydsl_conv_implicit, tuned lookup 42,438 49,084
Conv kernel only (profiler, NCDHW-output kernel) 9,553 12,819
Baseline: torch F.conv3d bf16, NCDHW (MIOpen) 49,249 57,188
Kernel vs baseline 4.83x 4.08x
NDHWC entry point vs baseline 1.98x 2.34x
NCDHW caller vs baseline 1.16x 1.17x
  • The kernel row is the tuner's timed call: prepared operands, so no host-side pad, channel pad or weight pack. The tables' us column matches it on every row (median 0.998x, within 3.8%). It is faster than the baseline on every shape (down to 1.92x on Qwen-Image and 1.41x on Wan2.1). In the previous version of this description the kernel row (24,989 / 24,537 us) was timed through raw operands, which is what the NDHWC entry point row measures now.
  • The VAEs run NDHWC end to end (csrc/flydsl_conv3d/README.md), so the NDHWC entry point row is the one that applies to them; it is slower than the baseline on 3 shapes of each model (down to 0.77x). Its gap to the kernel row is host-side work, mostly the zero pad: on the 38 unpadded shapes the entry point is 5% above the kernel, on the 38 padded ones 186% (up to 4.78x on a row). The rest is the channel pad to a multiple of 32 where C/groups needs it, and the weight pack, which run_perftest repeats on every call because it rotates weight copies, while a deployed layer pays it once.
  • Called with torch's default NCDHW layout instead, the op is slower than the baseline on 9/32 Qwen-Image and 15/44 Wan2.1 shapes (down to 0.44x). On that path over all 76 shapes the conv kernel is 25.0% of device time; 71.8% is torch direct_copy (the NCDHW→NDHWC permute, plus a second copy for the host-side zero pad on padded layers) and 3.2% the zero fill of that pad; the FlyDSL pre-transpose kernel is not used.

The us values in the tables are bound to the 2026-10-27 machine and FlyDSL 0.4.0. Re-measured on another gfx1250 card with FlyDSL 0.4.1 through the same prepared-operand path, all 76 rows came out faster (median -8.8%, sum -10.3%, up to -30% on individual rows; the only rows above the table are +10.1% and +3.2%), and rotating input and output copies to defeat the cache changed the result by under 2% on 4 of 5 sampled rows, so the gap is the toolchain and the machine rather than the measurement. Read these numbers as relative (which configuration won, and by how much within one environment) rather than as a portable absolute.

Wan2.1 VAE @368x544, per layer

Kernel us is the tables' us (kernel alone, TFLOPS from it); NDHWC entry us is end to end through flydsl_conv_implicit; torch is F.conv3d bf16 NCDHW on the same inputs; average of the two passes. Rows are the first 22 rows of wan21_vae_gfx1250_bf16_tuned_conv3d.csv, in table order.

# Input NxCxDxHxW → K, kernel, stride, pad Tile Kernel us TFLOPS NDHWC entry us torch us Kernel vs torch NDHWC entry vs torch
0 1x3x6x370x546 → K96 3x3x3 s1 p0 t256x96_w4x1_r16 426.3 29.2 506.9 2230.5 5.23x 4.40x
1 1x96x6x370x546 → K96 3x3x3 s1 p0 t256x96_w4x1_r4 882.7 451.5 886.8 2979.9 3.38x 3.36x
2 1x96x1x369x545 → K96 1x3x3 s1,2,2 p0 t256x96_w4x1_r4 37.8 219.5 41.0 320.2 8.46x 7.82x
3 4x96x1x369x545 → K96 1x3x3 s1,2,2 p0 t256x96_w4x1_r4 137.2 242.0 140.7 1258.5 9.17x 8.94x
4 1x96x6x186x274 → K192 3x3x3 s1 p0 t256x192_w4x2_r16 341.8 583.0 346.1 1171.3 3.43x 3.38x
5 1x192x6x186x274 → K192 3x3x3 s1 p0 t256x192_w4x2_r16 509.9 781.5 521.6 1846.7 3.62x 3.54x
6 1x192x1x185x273 → K192 1x3x3 s1,2,2 p0 t64x192_w2x2_r2 37.3 222.7 42.0 171.3 4.59x 4.08x
7 4x192x1x185x273 → K192 1x3x3 s1,2,2 p0 t256x192_w4x2_r8 69.9 475.2 75.4 640.4 9.16x 8.49x
8 1x192x4x94x138 → K384 3x3x3 s1 p0 t256x192_w4x2_r8 138.5 719.1 157.5 480.0 3.46x 3.05x
9 1x384x4x94x138 → K384 3x3x3 s1 p0 t256x192_w4x2_r8 236.1 844.0 273.6 832.9 3.53x 3.04x
10 1x384x1x93x137 → K384 1x3x3 s1,2,2 p0 t128x64_w2x2_r8 54.0 153.8 68.7 126.7 2.35x 1.84x
11 2x384x1x93x137 → K384 1x3x3 s1,2,2 p0 t128x128_w2x2_r8 58.4 284.2 72.7 177.0 3.03x 2.43x
12 1x384x3x48x70 → K384 3x3x3 s1 p0 t128x64_w2x2_r8 131.5 189.5 169.9 200.7 1.53x 1.18x
13 1x384x3x48x70 → K32 3x3x3 s1 p0 t32x32_w1x1_r2 93.5 22.2 96.9 161.9 1.73x 1.67x
14 1x16x3x48x70 → K384 3x3x3 s1 p0 t128x128_w2x2_r8 26.7 38.9 42.2 37.5 1.41x 0.89x
15 1x384x1x92x136 → K192 1x3x3 s1 p0,1,1 t64x192_w2x2_r2 56.9 291.6 108.9 119.1 2.09x 1.09x
16 2x384x1x92x136 → K192 1x3x3 s1 p0,1,1 t128x192_w4x2_r8 71.2 466.5 193.4 219.7 3.09x 1.14x
17 1x384x1x184x272 → K192 1x3x3 s1 p0,1,1 t256x192_w4x2_r16 102.6 647.5 278.1 363.4 3.54x 1.31x
18 4x384x1x184x272 → K192 1x3x3 s1 p0,1,1 t256x192_w4x2_r4 382.8 694.0 1230.0 1337.0 3.49x 1.09x
19 1x192x1x368x544 → K96 1x3x3 s1 p0,1,1 t256x96_w4x1_r2 182.5 364.0 505.1 534.2 2.93x 1.06x
20 4x192x1x368x544 → K96 1x3x3 s1 p0,1,1 t256x96_w4x1_r16 629.0 422.3 2307.9 2170.9 3.45x 0.94x
21 1x96x6x370x546 → K3 3x3x3 s1 p0 t256x32_w4x1_r4 485.8 25.6 487.2 1831.6 3.77x 3.76x
Sum (22 layers) 5092.3 8552.6 19211.3 3.77x 2.25x
Per-shape times (average of the two passes)
Model Input NxCxDxHxW → K, kernel, stride, pad Tile Kernel us NDHWC entry us NCDHW caller us torch us NDHWC entry vs torch NCDHW caller vs torch
Qwen-Image 1x3x1x1024x1024 → K96 1x3x3 s1 p0,1,1 t256x96_w4x1_r16 345.7 449.5 480.5 2144.9 4.77x 4.46x
Qwen-Image 1x96x1x1024x1024 → K96 1x3x3 s1 p0,1,1 t256x96_w4x1_r16 518.0 1346.8 2211.5 2399.4 1.78x 1.08x
Qwen-Image 1x96x1x1025x1025 → K96 1x3x3 s1,2,2 p0 t256x96_w4x1_r2 165.6 168.4 965.7 1607.3 9.55x 1.66x
Qwen-Image 1x96x1x512x512 → K192 1x3x3 s1 p0,1,1 t256x192_w4x2_r4 234.8 449.3 600.6 945.5 2.10x 1.57x
Qwen-Image 1x192x1x512x512 → K192 1x3x3 s1 p0,1,1 t256x192_w4x2_r4 305.2 726.6 1104.8 1166.7 1.61x 1.06x
Qwen-Image 1x192x1x513x513 → K192 1x3x3 s1,2,2 p0 t192x192_w4x2_r4 109.9 115.3 515.3 830.8 7.21x 1.61x
Qwen-Image 1x192x1x256x256 → K384 1x3x3 s1 p0,1,1 t256x192_w4x2_r16 179.3 299.0 370.8 553.9 1.85x 1.49x
Qwen-Image 1x384x1x256x256 → K384 1x3x3 s1 p0,1,1 t256x192_w4x2_r8 271.9 502.7 673.1 790.1 1.57x 1.17x
Qwen-Image 1x384x1x257x257 → K384 1x3x3 s1,2,2 p0 t256x128_w4x2_r16 83.2 98.6 311.8 479.1 4.86x 1.54x
Qwen-Image 1x384x1x128x128 → K384 1x3x3 s1 p0,1,1 t256x128_w4x2_r16 80.4 155.0 200.2 250.3 1.61x 1.25x
Qwen-Image 1x384x1x128x128 → K32 1x3x3 s1 p0,1,1 t96x32_w2x2_r2 40.0 99.2 145.5 76.7 0.77x 0.53x
Qwen-Image 1x16x1x128x128 → K384 1x3x3 s1 p0,1,1 t256x128_w4x2_r2 22.0 46.3 38.3 98.1 2.12x 2.57x
Qwen-Image 1x384x1x256x256 → K192 1x3x3 s1 p0,1,1 t192x192_w2x4_r4 165.2 387.2 556.9 445.7 1.15x 0.80x
Qwen-Image 1x384x1x512x512 → K192 1x3x3 s1 p0,1,1 t256x192_w4x2_r4 470.7 1302.3 2122.4 1683.3 1.29x 0.79x
Qwen-Image 1x192x1x1024x1024 → K96 1x3x3 s1 p0,1,1 t256x96_w4x1_r16 734.3 2314.8 3902.1 2824.4 1.22x 0.72x
Qwen-Image 1x96x1x1024x1024 → K3 1x3x3 s1 p0,1,1 t256x32_w4x1_r2 218.0 1042.7 1895.1 931.3 0.89x 0.49x
Qwen-Image 1x3x1x1328x1328 → K96 1x3x3 s1 p0,1,1 t256x96_w4x1_r16 581.8 747.0 769.3 3595.8 4.81x 4.67x
Qwen-Image 1x96x1x1328x1328 → K96 1x3x3 s1 p0,1,1 t256x96_w4x1_r4 878.2 2260.0 3615.5 4003.2 1.77x 1.11x
Qwen-Image 1x96x1x1329x1329 → K96 1x3x3 s1,2,2 p0 t256x96_w4x1_r8 256.8 259.9 1659.3 2713.6 10.44x 1.64x
Qwen-Image 1x96x1x664x664 → K192 1x3x3 s1 p0,1,1 t256x192_w4x2_r8 371.9 726.1 974.7 1599.7 2.20x 1.64x
Qwen-Image 1x192x1x664x664 → K192 1x3x3 s1 p0,1,1 t256x192_w4x2_r8 481.6 1185.9 1803.5 1946.1 1.64x 1.08x
Qwen-Image 1x192x1x665x665 → K192 1x3x3 s1,2,2 p0 t256x192_w4x2_r16 133.6 139.4 827.4 1816.5 13.04x 2.20x
Qwen-Image 1x192x1x332x332 → K384 1x3x3 s1 p0,1,1 t256x192_w4x2_r16 243.5 432.0 555.0 1800.1 4.17x 3.24x
Qwen-Image 1x384x1x332x332 → K384 1x3x3 s1 p0,1,1 t256x192_w4x2_r16 374.6 736.5 1053.1 2350.7 3.19x 2.23x
Qwen-Image 1x384x1x333x333 → K384 1x3x3 s1,2,2 p0 t256x192_w4x2_r16 136.8 151.7 535.2 851.9 5.62x 1.59x
Qwen-Image 1x384x1x166x166 → K384 1x3x3 s1 p0,1,1 t256x192_w4x2_r16 133.2 242.6 334.6 511.6 2.11x 1.53x
Qwen-Image 1x384x1x166x166 → K32 1x3x3 s1 p0,1,1 t128x32_w4x1_r8 40.6 138.2 215.5 154.3 1.12x 0.72x
Qwen-Image 1x16x1x166x166 → K384 1x3x3 s1 p0,1,1 t128x192_w4x2_r8 36.9 62.5 62.0 243.9 3.90x 3.93x
Qwen-Image 1x384x1x332x332 → K192 1x3x3 s1 p0,1,1 t256x192_w4x2_r16 197.0 554.5 884.7 1373.9 2.48x 1.55x
Qwen-Image 1x384x1x664x664 → K192 1x3x3 s1 p0,1,1 t256x192_w4x2_r8 750.2 2135.9 3474.6 2789.4 1.31x 0.80x
Qwen-Image 1x192x1x1328x1328 → K96 1x3x3 s1 p0,1,1 t256x96_w4x1_r4 1259.0 3852.9 6459.8 4719.0 1.22x 0.73x
Qwen-Image 1x96x1x1328x1328 → K3 1x3x3 s1 p0,1,1 t256x32_w4x1_r4 368.6 1754.4 3119.0 1552.0 0.88x 0.50x
Wan2.1 1x3x6x370x546 → K96 3x3x3 s1 p0 t256x96_w4x1_r16 426.3 506.9 503.3 2230.5 4.40x 4.43x
Wan2.1 1x96x6x370x546 → K96 3x3x3 s1 p0 t256x96_w4x1_r4 882.7 886.8 1713.0 2979.9 3.36x 1.74x
Wan2.1 1x96x1x369x545 → K96 1x3x3 s1,2,2 p0 t256x96_w4x1_r4 37.8 41.0 200.9 320.2 7.82x 1.59x
Wan2.1 4x96x1x369x545 → K96 1x3x3 s1,2,2 p0 t256x96_w4x1_r4 137.2 140.7 981.1 1258.5 8.94x 1.28x
Wan2.1 1x96x6x186x274 → K192 3x3x3 s1 p0 t256x192_w4x2_r16 341.8 346.1 552.4 1171.3 3.38x 2.12x
Wan2.1 1x192x6x186x274 → K192 3x3x3 s1 p0 t256x192_w4x2_r16 509.9 521.6 964.4 1846.7 3.54x 1.91x
Wan2.1 1x192x1x185x273 → K192 1x3x3 s1,2,2 p0 t64x192_w2x2_r2 37.3 42.0 124.6 171.3 4.08x 1.37x
Wan2.1 4x192x1x185x273 → K192 1x3x3 s1,2,2 p0 t256x192_w4x2_r8 69.9 75.4 492.8 640.4 8.49x 1.30x
Wan2.1 1x192x4x94x138 → K384 3x3x3 s1 p0 t256x192_w4x2_r8 138.5 157.5 235.5 480.0 3.05x 2.04x
Wan2.1 1x384x4x94x138 → K384 3x3x3 s1 p0 t256x192_w4x2_r8 236.1 273.6 437.2 832.9 3.04x 1.91x
Wan2.1 1x384x1x93x137 → K384 1x3x3 s1,2,2 p0 t128x64_w2x2_r8 54.0 68.7 108.8 126.7 1.84x 1.17x
Wan2.1 2x384x1x93x137 → K384 1x3x3 s1,2,2 p0 t128x128_w2x2_r8 58.4 72.7 189.7 177.0 2.43x 0.93x
Wan2.1 1x384x3x48x70 → K384 3x3x3 s1 p0 t128x64_w2x2_r8 131.5 169.9 207.0 200.7 1.18x 0.97x
Wan2.1 1x384x3x48x70 → K32 3x3x3 s1 p0 t32x32_w1x1_r2 93.5 96.9 137.8 161.9 1.67x 1.17x
Wan2.1 1x16x3x48x70 → K384 3x3x3 s1 p0 t128x128_w2x2_r8 26.7 42.2 47.8 37.5 0.89x 0.78x
Wan2.1 1x384x1x92x136 → K192 1x3x3 s1 p0,1,1 t64x192_w2x2_r2 56.9 108.9 149.7 119.1 1.09x 0.80x
Wan2.1 2x384x1x92x136 → K192 1x3x3 s1 p0,1,1 t128x192_w4x2_r8 71.2 193.4 286.2 219.7 1.14x 0.77x
Wan2.1 1x384x1x184x272 → K192 1x3x3 s1 p0,1,1 t256x192_w4x2_r16 102.6 278.1 408.0 363.4 1.31x 0.89x
Wan2.1 4x384x1x184x272 → K192 1x3x3 s1 p0,1,1 t256x192_w4x2_r4 382.8 1230.0 2042.2 1337.0 1.09x 0.65x
Wan2.1 1x192x1x368x544 → K96 1x3x3 s1 p0,1,1 t256x96_w4x1_r2 182.5 505.1 782.9 534.2 1.06x 0.68x
Wan2.1 4x192x1x368x544 → K96 1x3x3 s1 p0,1,1 t256x96_w4x1_r16 629.0 2307.9 3929.5 2170.9 0.94x 0.55x
Wan2.1 1x96x6x370x546 → K3 3x3x3 s1 p0 t256x32_w4x1_r4 485.8 487.2 1452.9 1831.6 3.76x 1.26x
Wan2.1 1x3x6x482x834 → K96 3x3x3 s1 p0 t256x96_w4x1_r8 780.5 933.1 915.6 4422.0 4.74x 4.83x
Wan2.1 1x96x6x482x834 → K96 3x3x3 s1 p0 t256x96_w4x1_r4 1605.1 1561.9 3232.8 5852.7 3.75x 1.81x
Wan2.1 1x96x1x481x833 → K96 1x3x3 s1,2,2 p0 t256x96_w4x1_r16 72.4 75.7 394.4 619.0 8.18x 1.57x
Wan2.1 4x96x1x481x833 → K96 1x3x3 s1,2,2 p0 t256x96_w4x1_r16 237.8 239.8 1922.7 2463.5 10.27x 1.28x
Wan2.1 1x96x6x242x418 → K192 3x3x3 s1 p0 t256x192_w4x2_r8 608.5 613.7 1008.2 2327.1 3.79x 2.31x
Wan2.1 1x192x6x242x418 → K192 3x3x3 s1 p0 t256x192_w4x2_r8 924.4 931.4 1823.8 4239.2 4.55x 2.32x
Wan2.1 1x192x1x241x417 → K192 1x3x3 s1,2,2 p0 t256x96_w4x1_r16 47.8 52.9 214.5 340.0 6.42x 1.58x
Wan2.1 4x192x1x241x417 → K192 1x3x3 s1,2,2 p0 t256x192_w4x2_r16 131.5 136.1 965.1 1306.0 9.60x 1.35x
Wan2.1 1x192x4x122x210 → K384 3x3x3 s1 p0 t256x192_w4x2_r16 256.4 275.7 424.6 941.6 3.41x 2.22x
Wan2.1 1x384x4x122x210 → K384 3x3x3 s1 p0 t256x192_w4x2_r16 440.1 483.3 800.7 1623.4 3.36x 2.03x
Wan2.1 1x384x1x121x209 → K384 1x3x3 s1,2,2 p0 t128x128_w2x2_r8 57.7 72.4 161.9 181.3 2.50x 1.12x
Wan2.1 2x384x1x121x209 → K384 1x3x3 s1,2,2 p0 t128x192_w4x2_r8 71.7 86.3 309.2 338.5 3.92x 1.09x
Wan2.1 1x384x3x62x106 → K384 3x3x3 s1 p0 t128x128_w2x2_r8 153.9 192.6 260.9 264.8 1.37x 1.01x
Wan2.1 1x384x3x62x106 → K32 3x3x3 s1 p0 t32x32_w1x1_r2 96.3 99.4 167.4 200.6 2.02x 1.20x
Wan2.1 1x16x3x62x106 → K384 3x3x3 s1 p0 t128x128_w2x2_r8 27.0 46.5 54.1 58.5 1.26x 1.08x
Wan2.1 1x384x1x120x208 → K192 1x3x3 s1 p0,1,1 t128x192_w2x2_r4 70.5 165.7 256.6 190.9 1.15x 0.74x
Wan2.1 2x384x1x120x208 → K192 1x3x3 s1 p0,1,1 t256x192_w4x2_r8 99.9 328.7 556.9 372.5 1.13x 0.67x
Wan2.1 1x384x1x240x416 → K192 1x3x3 s1 p0,1,1 t256x192_w4x2_r4 192.4 519.4 899.4 645.4 1.24x 0.72x
Wan2.1 4x384x1x240x416 → K192 1x3x3 s1 p0,1,1 t256x192_w4x2_r8 669.0 2344.0 4409.6 2545.2 1.09x 0.58x
Wan2.1 1x192x1x480x832 → K96 1x3x3 s1 p0,1,1 t256x96_w4x1_r2 309.9 944.9 1767.9 1069.7 1.13x 0.61x
Wan2.1 4x192x1x480x832 → K96 1x3x3 s1 p0,1,1 t256x96_w4x1_r4 1147.9 4863.3 9903.5 4384.7 0.90x 0.44x
Wan2.1 1x96x6x482x834 → K3 3x3x3 s1 p0 t256x32_w4x1_r4 908.5 880.7 2686.2 3590.3 4.08x 1.34x

Tuning time

gfx1250, one card (256 CUs), 2026-10-27. Both tables re-tuned with csrc/flydsl_conv3d/conv3d_tune.py --mp 1 --timeout 600.

  • Compile (CPU only): all 7440 candidates of both tables precompiled into a FlyDSL cache, 130 s wall on 64 workers (7934 s of compile summed), 0 errors.
  • Tuning on the GPU, from that cache under FLYDSL_RUNTIME_RUN_ONLY=1 (no JIT while tuning), one process:
Table Shapes Candidates Wall time
qwenimage_vae_gfx1250_bf16_tuned_conv3d.csv 32 3174 427 s
wan21_vae_gfx1250_bf16_tuned_conv3d.csv 44 4266 576 s

Wall time covers the whole conv3d_tune.py process (the tuner itself reports 425 s and 573 s). All 76 shapes tuned, no failed shape, err_ratio is 0 on every row.

Known issue

  • gfx1250 dyn_hw launchers still close over extent-bearing values (the full param, the geometry, the output size and the launch args), and FlyDSL folds closure scalars into its cache key, so every resolution and batch size is its own artifact. AOT builds one per tuned row, but a resolution outside the tables JITs on first call even with dyn_hw on.

Test plan

  • PYTHONPATH=. python op_tests/test_flydsl_conv_implicit.py keyword surface on gfx1250 (all cases err=0)
  • Small VAE smoke: --wan-res 64x64 --wan-frames 5 --qwen-res 64x64 (selected cases)
  • Compile-key isolation cases on gfx1250
  • Full Wan/Qwen resolution sweep on gfx1250: all tuner candidates of the 76 tuned shapes, 10 runs each (see Accuracy)
  • Both tables retuned with the aligned tuner, all 7440 candidates pass (see Accuracy and Tuning time)
  • Retuned tables re-timed on gfx1250 against F.conv3d (see Performance)
  • AOT-only deployment on gfx1250: both tuned tables built with aiter.aot.flydsl.conv into an empty cache, all 76 rows served under FLYDSL_RUNTIME_RUN_ONLY=1 and matching F.conv3d
  • gfx950 regression: confirm existing path unchanged / transpose still compiles for gfx950

PR Self-Review

This self-review covers the source and description at this head. GPU results in the Accuracy, Performance, Tuning time and Test plan sections predate this revision (they were taken at or before 11b8450); they are not a claim that the current head was revalidated end to end.

Reviewed revision

2bd7ad791e869b8c44f62e995e4ba4c47297781f

Behavior and intent

This PR adds a gfx1250 TDM/WMMA backend to flydsl_conv_implicit, with host-side spatial padding, NDHWC operands, per-group channels aligned to 32, architecture-specific tile selection, tuning tables, and AOT support. The existing gfx950 MFMA backend does not fit gfx1250's wave32/WMMA execution model, and the previous architecture allow-list rejected gfx1250.

Changes since the previous self-reviewed revision (11b8450):

  • 134c1bd: the public entry now forwards splitk to the gfx1250 backend (previously it was dropped, and the tuner adapter deleted it too). Split-K is resolved by a single helper, _resolve_splitk_gfx1250, which applies the H/W tile-tail, output-channel-tail and BIG_OUT gates; the runtime, the tuner and AOT all call it, so the tuned row, the launched kernel and the AOT artifact agree. Only an explicit caller request that is incompatible with a tail raises; tuned/automatic values fall back to 1. _dispatch keeps the compile-only gate so a launcher warmed in the same process is not run with AOT CPU-probe arguments. run_config now requires a zero strict error count instead of accepting the historical CSV error ratio. gfx1250 grid.y above MAX_GRID_YZ is rejected, as on gfx950.
  • cb25bbd: adds check_splitk_contract to op_tests/test_flydsl_conv_implicit.py.
  • 9ba793d: skips that check (with a log line) when the backend is not gfx1250, because on gfx950 the same shapes take the MFMA path and nothing is captured.
  • a2c7577: moves both operands from the legacy N-D make_tdm_atom + immediate-offset copy to the tiled make_tiled_tdm_atom + tdm_partition path used by the other gfx1250 kernels. Weights are K-tile aligned, so one descriptor covers the channel range and each round selects its K tile; input taps shift the base by whole rows and columns, which is not a multiple of the tile, so that side builds its descriptor per issue from a shifted base. The LDS tiles are unchanged, which keeps LDS_PAD / pad_interval derived from the LDS layout. early_timeout is not part of the tiled API.
  • 06f6f49: fixes the tiled weight partitioning: the complete padded B tile is partition mode 0 and a singleton rest mode is retained, matching the gfx1250 GEMM load path. In this commit A returns to the N-D descriptor/offset path so the weight side can be migrated on its own.
  • 5741cb3: moves the input gather to the tiled atom as well, building A per issue from the runtime tap offset; no make_tdm_atom call remains in the kernel.
  • 6888112, c1b5708, ec511cd: merge main into the branch; no kernel source change of their own.

Carried over from 11b8450: run_conv3d_gfx1250 accepts a caller-owned out, and the gfx1250 tuner NaN-fills it before each candidate so a kernel that leaves elements unwritten fails strict_compare instead of inheriting the previous candidate's values. patch_reuse is accepted but ignored on gfx1250.

Validation and unverified scope

At this head's commits (gfx1250, FlyDSL 0.4.1, as recorded in the commit messages of 134c1bd / cb25bbd / 06f6f49):

  • Strict accuracy on representative NDHWC and NCDHW shapes with no split-K; outputs bitwise identical to the unmodified kernel for those cases; graph-replay time unchanged within noise (the host-side split-K resolution adds a few percent only on ~10-40 us launches).
  • check_splitk_contract: all six checks pass (no_tail: automatic resolution 3, kernel compiled with the explicit split-K=2; row_tail: automatic resolution 1, kernel compiled with split-K=1, explicit 3 raises). The tree before the shared resolver fails the same function, so the check catches the regression it targets.
  • 06f6f49 records two representative shapes on a07 GPU0 and d7 GPU1 with FlyDSL 0.4.1: ten NaN-prefilled accuracy checks per version and three bitwise baseline comparisons per shape. That record covers the weight-side migration only; the input side moved to the tiled atom afterwards, in 5741cb3.
  • The tiled TDM migration was validated as a whole at ec511cd1 on gfx1250 (FlyDSL 0.4.1, one card): all 76 tuned rows x 2 output layouts x 10 runs through the tuned lookup (1520 calls), with 456 both-direction rtol=atol=2e-2 checks finding zero elements outside tolerance, zero non-finite values and bit-identical output across repeats. The public entry served all 76 rows in NCDHW and NDHWC form (152 calls) under FLYDSL_RUNTIME_RUN_ONLY=1 with no JIT fallback, so every tuned row's artifact still matches what the runtime requests. Against an fp64 reference on two layers the kernel stays within one bf16 ulp (99.97% of elements bit-identical) and is closer to fp64 than the fp32 reference. Same-card A/B on four representative layers shows no regression (paired medians -0.47%, -2.84%, -0.08%, -0.03%).

Earlier recorded results (gfx1250, one GPU, 256 CUs, FlyDSL 0.4.0, see the sections above):

  • PYTHONPATH=. python op_tests/test_flydsl_conv_implicit.py: keyword cases err=0; small VAE smoke with --wan-res 64x64 --wan-frames 5 --qwen-res 64x64.
  • Tuning with csrc/flydsl_conv3d/conv3d_tune.py --mp 1 --timeout 600 from a CPU-precompiled cache under FLYDSL_RUNTIME_RUN_ONLY=1; 7440 candidates pass (2026-10-27). Separate 2026-10-26 sweep: 7444 candidates x 10 runs, NaN-filled outputs, no element outside rtol=atol=2e-2, no NaNs, no hangs.
  • Performance: run_perftest (5 warmup + 101 iterations), two passes against F.conv3d with interference monitoring.
  • AOT: both tables built with aiter.aot.flydsl.conv into an empty cache, all 76 rows served under FLYDSL_RUNTIME_RUN_ONLY=1 and matching F.conv3d.

Unverified at this head:

  • The full op test was not rerun in a clean environment after the TDM commits. In a container with torch 2.14.0+rocm10.2.0a20260922 and FlyDSL 0.4.1, op_tests/test_flydsl_conv_implicit.py fails 19/21 cases at this head, but the unmodified 5741cb3 head and 11b8450 fail the same way there, and torch F.conv3d matches CPU on that card. The failure is not attributed to this revision, so it is not used as evidence for or against it; it needs a rerun in the image the earlier results used.
  • Numerical accuracy of split-K > 1 on gfx1250 through the public API: check_splitk_contract asserts the compiled split-K value, not the output values.
  • gfx950 was checked on hardware at this head (smci355-ccs-aus-n12-25, MI355X, torch 2.10.0+rocm7.2.3, FlyDSL 0.4.1): three conv3d shapes (1x32x4x16x16 3x3x3, 1x64x1x32x32 1x3x3 with pad, 1x32x3x32x32 stride 2) ran three times each with no non-finite element and no element outside rtol=atol=2e-2 in either direction, max abs error 0.0039 / 0.0078 / 0.0156 (bf16 rounding steps), and outputs were bit-identical across repeats; compile_transpose_ncdhw_ndhwc also compiles on gfx950 (1x64x1024, 2x128x4096). conv3d_implicit_gfx950.py and conv3d_gfx950_utils.py are untouched by this PR, so the exposure was conv_kernels.py and conv3d_transpose.py, both exercised here. gfx950 performance was not measured and only these three small shapes were used.
  • BIG_OUT is not exercised by the 76-shape sweep. ROCm/PyTorch versions and full standalone sweep commands were not recorded.
  • Known dyn_hw cache-key limitation: a resolution outside the tables JITs a new artifact on first call.

PR-specific question

The shared entry strips architecture feature suffixes and allow-lists only gfx950 and gfx1250, including before the pointwise matmul path. It checks supported convolution ranks and layouts, GPU tensors, bf16 input/weight, bias shape, consistent groups/channels, positive stride/dilation and valid padding semantics. After padding normalization and the pointwise fast-path check, only the remaining convolutions on gfx1250 select the new TDM/WMMA backend.

Host spatial padding and channel packing adapt valid inputs; they are not rejection checks. The gfx1250 backend requires positive output extents. Parameter/launch construction enforces aligned channels and CRS, WMMA tile/block geometry, at most 16 waves, split-K divisibility, split-K staging and grid limits (grid.y and grid.z <= MAX_GRID_YZ), and LDS/prologue capacity. _resolve_splitk_gfx1250 is the single gate for split-K: H/W or output-channel tile tails and BIG_OUT force split-K 1 for tuned/automatic values and reject an explicit request > 1. Dynamic-shape ineligibility selects static compilation rather than rejecting an otherwise supported input. A supplied out must have the expected shape, bf16 dtype, the input device and contiguous storage.

These are the shared-entry and launch invariants, not a claim that direct backend calls validate every input or that cross-device operands are checked.

Changed op tests

The only changed op-test file is op_tests/test_flydsl_conv_implicit.py.

  • 3d_tail_blocks: input (1, 32, 3, 17, 19), 48 output channels, 64x64 tile, block_rows=4, padding and bias. H=17, W=19 and K=48 produce H/W block tails and an output-channel tail at once, covering the masked epilogue and the tail-driven static fallback; default/tuned model sweeps do not guarantee this combined geometry.
  • 3d_tile_128 and 2d_tile_256 pin block_rows=8, exercising wider-tile 2D-block geometry explicitly instead of relying on heuristic or tuned selection. Validating gfx950's wave64 MFMA mapping does not cover gfx1250's wave32 TDM/WMMA mapping.
  • 2d_splitk2 (adjusted) and 3d_splitk2 (added) use fixed tiles, block_rows=4 and patch_reuse=False to avoid H/W/N tails in cases that request split-K. These are numerical checks; the 2D case has 27 K-tiles, so a request of 2 resolves to 1.
  • check_splitk_contract (new, gfx1250 only, runs unfiltered): no_tail x=(1,64,1,8,768) checks that an explicit split-K=2 is the value the kernel is compiled with and that the automatic value matches the flat resolution the tuner records; row_tail x=(1,64,1,3,2048) (Ho=3 not a multiple of block_rows=8) checks fallback to 1 and that an explicit incompatible request raises. Every other case compares values only, so a split-K that silently differs between the tuned row, the kernel and AOT would pass them; this check is not redundant with them.

No negative-input rejection tests were added beyond the explicit split-K tail rejection.

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

Host pre-pads to NDHWC with C/groups aligned to 32; A uses rank-3 TDM
boxes (optional kH×kW patch reuse), B uses 2D TDM tiles, and compute is
WMMA 16x16x32 bf16. Wire flydsl_conv_implicit to the new backend and
extend the op_test keyword surface for gfx1250 tiles and tail blocks.

Co-authored-by: Cursor <[email protected]>
@huizzhan
huizzhan force-pushed the feature/flydsl-conv3d-gfx1250 branch from 84a5e4c to f18f160 Compare October 19, 2026 08:41
@huizzhan huizzhan changed the title [FlyDSL] Add gfx1250 implicit-GEMM conv3d (TDM im2col + WMMA) [FlyDSL] Add gfx1250 implicit-GEMM conv3d Oct 19, 2026
root and others added 7 commits October 19, 2026 09:53
Extend the MVP TDM+WMMA path with 64-bit stores, fp32 atomic split-K,
variable-resolution extents, gfx1250 tile policy, tuned-table lookup
(block_rows), and AOT dispatch; ship a small smoke tuned CSV.

Co-authored-by: Cursor <[email protected]>
Resolve conflicts with #6421 (gfx950 kW / kH x kW LDS reuse), which also
added a block_rows field to the conv3d tuned table:

- Use main's tuned-CSV column block_r (TUNED_BLOCK_ROWS_COLUMN,
  _parse_block_rows) for gfx1250 as well, drop TUNED_OPTIONAL_RESULT_COLUMNS,
  and rename the gfx1250 tuned CSV header from block_rows to block_r. With
  two column names the config merge zero-fills the other arch's column, and
  AOT parse_csv let block_r's default override the gfx1250 value.
- conv3d_tune.py: gfx950 keeps main's per-tile block_rows sweep; gfx1250
  keeps its policy, which already returns block_rows. Both use main's task
  tuple order and write block_r.
- _conv3d_impl takes both block_rows and patch_reuse; keep the new op test
  cases from both sides.

Co-authored-by: Cursor <[email protected]>
…e strict

Blocks of 8 or 16 waves return wrong results on gfx1250: re-running the 38
shipped 8/16-wave winners gave wrong elements on 35 of them, a different subset
on every run, while the same shapes are exact with 4-wave tiles. Until the
kernel is fixed, MAX_WAVES = 4 rejects such tiles in
validate_launch_config_gfx1250, the tuned-table lookup ignores them with a
one-time warning, and the heuristic ladder and DEFAULT_TILE drop to 2x2 waves.

The tuner now scores candidates with strict_compare (1.0 on any element outside
tolerance): mp_tuner rounds the error ratio to 4 decimals, which let thousands
of wrong elements pass as errRatio=0. Borrowed candidates must also be legal
gfx1250 tiles. The op test maps the gfx950-sized pinned tiles to the widest
legal gfx1250 tiles, and the tuner README documents the strict gate.

The tuned CSVs are re-tuned under the cap in a follow-up commit.

Co-authored-by: Cursor <[email protected]>
…wave cap

The tap main loop issued the next tile's TDM before the barrier, into the
buffer other waves were still reading (WAR race with num_buffers=2). That is
why 8/16-wave blocks returned a different set of wrong elements on every run.

Replace both bodies with one pipeline that mirrors compile_gemm_a16w16:
prologue of B-1 TDM tiles, an scf.for main loop carrying accumulators and
register-prefetched fragments, tensor_wait((B-2)*2), a drain, and
sched_barrier(0) before the epilogue when B>2. num_buffers (2..8), variant
(bandwidth_bound / compute_bound) and main_loop_unroll are now real knobs,
passed through run_conv3d_gfx1250 and clamped to the LDS / K-tile budget.
_body is @flyc.jit so the AST rewriter lowers the yield-carrying loop; as a
plain helper it is a Python generator and the kernel traces empty.

The kH x kW patch-reuse body is removed for now (patch_reuse is accepted and
ignored on gfx1250), MAX_WAVES goes back to 16, the heuristic ladder regains
a 2x4-wave tile, and the op test runs the pinned tiles unmapped.

Verified on gfx1250 against an fp32 CPU reference, zero elements outside
rtol=atol=2e-2, 3 runs per config: Wan2.1 down_0_1 @368x544, all 918
policy configs; and all 76 shapes of both gfx1250 tuned CSVs, 20313 configs
(CSV tile plus 24 policy tiles x num_buffers 2/3/4 x 3 variants, including
8/16-wave, split-K 2/4 and dyn_hw on/off).

Co-authored-by: Cursor <[email protected]>
…peline

Re-tune both gfx1250 tables (Qwen-Image VAE, Wan2.1 VAE) against the
pipeline from 01509cf.

Every candidate the tuner enumerates for the 76 shapes (7444 configs,
including 2164 8-wave and 689 16-wave) ran 10 times against an fp32 CPU
reference, each output NaN-filled before it was freed: zero elements
outside rtol=atol=2e-2, no NaNs, no hangs.

Per shape, the 5 fastest passing configs by CUDA-event screening plus the
previously committed tile were re-timed with run_perftest, the tuner's own
measurement (conv3d_tune agrees with it to within 1% on two rows). Against
the previously committed tiles on the new pipeline, the winners are 5.5%
(Qwen-Image) and 9.0% (Wan2.1) faster in sum; 8-wave tiles win 19/32 and
17/44 rows, and one Wan2.1 row takes a 16-wave tile.

The us column is high in absolute terms: the card measured the same
kernels 1.0-2.6x slower than it did on 2026-10-21 (same harness, same
toolchain), so the ranking holds but the times do not compare with the
previous table.

Co-authored-by: Cursor <[email protected]>
@huizzhan
huizzhan marked this pull request as ready for review October 26, 2026 09:21
@huizzhan
huizzhan requested a review from a team October 26, 2026 09:21
@github-actions github-actions Bot changed the title [FlyDSL] Add gfx1250 implicit-GEMM conv3d [HIP] [FlyDSL] Add gfx1250 implicit-GEMM conv3d Oct 26, 2026
huizzhan and others added 2 commits October 26, 2026 09:36
The runtime turned dyn_hw off when (K / groups) % tile_n != 0 after
calling _dyn_hw_ok_gfx1250, but AOT only called the helper. On the K=3
output convs of both tuned tables (Qwen-Image 1024^2, Wan2.1 482x834) AOT
therefore built a dyn_hw kernel the runtime never requests: those rows
raise under FLYDSL_RUNTIME_RUN_ONLY=1 and JIT on first call otherwise.
Move the rule into _dyn_hw_ok_gfx1250 so both sides use it.

Co-authored-by: Cursor <[email protected]>
gfx1250 dyn_hw launchers still close over the full param, geometry and
launch args, and FlyDSL keys a launch on its closure scalars, so every
resolution and batch size is its own artifact. Deduping dyn_hw jobs
across N/D/H/W left 4 of the 76 tuned rows without one (Qwen-Image 1328^2
rows 16 and 30, Wan2.1 N=4 rows 25 and 40). Key gfx1250 dyn_hw jobs on
the whole row until the launcher is shape-agnostic.

Co-authored-by: Cursor <[email protected]>
huizzhan and others added 4 commits October 27, 2026 02:26
…il gate

The 32x32 input under a 2x2x2 filter with no padding gives Ho = Wo = 31, so
npq = 2883 is not a multiple of tile_m = 64 and the explicit splitk=2 hit the
split-K tail assertion on gfx950 (and the 2D block tail check on gfx1250).
Use a 33x33 input so Ho = Wo = 32 and the tile divides the problem.

Co-authored-by: Cursor <[email protected]>
On gfx1250 the tuner timed flydsl_conv_implicit on raw operands, so every
timed call also paid run_conv3d_gfx1250's host-side zeros pad, channel pad
to a multiple of 32 and weight pack. The weight pack is memoized, but
run_perftest rotates weight copies, so it missed on every iteration while a
deployed layer pays it once. The GEMM and MoE tuners hand their timed call
ready-made (quantized, shuffled, sorted) operands instead.

Add prepare_operands_gfx1250, which runs those three steps once with the
dispatcher's own helpers, and an optional packed_weight argument to
run_conv3d_gfx1250 that skips the pack. gfx1250 tuner tasks now generate
the prepared operands in generate_data_gfx1250 and time run_conv3d_gfx1250
on them with padding=0; the reference still uses the raw operands. gfx950
is unchanged.

The kernel param is unchanged: for all 7440 candidates of the 76 tuned
shapes the old and new calls build equal params on CPU, and on gfx1250 the
76 tuned configs return bitwise-equal outputs both ways, 3 runs each, with
no element outside rtol=atol=2e-2. The timing A/B against the old call is
still to be measured; the tuned tables are not re-tuned here.

Co-authored-by: Cursor <[email protected]>
Align conv3d_tune with the GEMM tuners:
- Time with --warmup/--iters (5/101 by default), which the GEMM tuners pass
  to run_perftest; it ran run_perftest's default of 2 warmups. run_config
  does the same.
- Check against fp32 F.conv3d with an fp32 bias, rounded to bf16 once, the
  reference of op_tests/test_flydsl_conv_implicit.py and the GEMM tuners. It
  was bf16 F.conv3d with the bias rounded to bf16 first.
- run_config uses the base class's err-ratio limit and status format;
  strict_compare still turns any element outside rtol=atol=2e-2 into 1.0, so
  the limit's margin does not loosen it.
Kept as is: errRatio=0 with strict_compare, shape_grouped always on, and the
best-of-3 run_config. Preallocated outputs with NaN init would need an out=
argument on run_conv3d_gfx1250 and are left out.

Retune both gfx1250 VAE tables with this tuner (prepared operands from
3f7d146, so `us` is the kernel alone): all 7440 candidates of the 76 shapes
are within rtol=atol=2e-2 of the fp32 reference, none failed or timed out.
The winner changes on 8/32 Qwen-Image and 18/44 Wan2.1 rows; in the same run
the previous tiles time 0.2% slower in sum on both tables (at most 6.4% on a
row).

Co-authored-by: Cursor <[email protected]>
With --run_config <tuned_csv>, report each row's tuned `us` as kernel_us
next to the end-to-end time, as the MoE tuner does; the base class then
prints Kernel(us) and E2E(us) side by side. On gfx1250 the two differ by up
to 4.8x on padded shapes, where the entry point's host-side pad dominates.

Co-authored-by: Cursor <[email protected]>
@zufayu
zufayu removed the request for review from yadaish October 29, 2026 10:17
@huizzhan huizzhan changed the title [HIP] [FlyDSL] Add gfx1250 implicit-GEMM conv3d [FlyDSL] Add gfx1250 implicit-GEMM conv3d Nov 2, 2026
@aiter-bot

aiter-bot commented Nov 2, 2026 •

Copy link
Copy Markdown

READY FOR HUMAN REVIEW

PR Self-Review

Revision 2bd7ad791e86 · mode shadow

Author self-review accepted. Readiness report:

Author answers

  • PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers

Behavior and intent

This PR adds a gfx1250 TDM/WMMA backend to `flydsl_conv_implicit`, with host-side spatial padding, NDHWC operands, per-group channels aligned to 32, architecture-specific tile selection, tuning tables, and AOT support. The existing gfx950 MFMA backend does not fit gfx1250's wave32/WMMA execution model, and the previous architecture allow-list rejected gfx1250.

Changes since the previous self-reviewed revision (`11b8450`):

- `134c1bd`: the public entry now forwards `splitk` to the gfx1250 backend (previously it was dropped, and the tuner adapter deleted it too). Split-K is resolved by a single helper, `_resolve_splitk_gfx1250`, which applies the H/W tile-tail, output-channel-tail and BIG_OUT gates; the runtime, the tuner and AOT all call it, so the tuned row, the launched kernel and the AOT artifact agree. Only an explicit caller request that is incompatible with a tail raises; tuned/automatic values fall back to 1. `_dispatch` keeps the compile-only gate so a launcher warmed in the same process is not run with AOT CPU-probe arguments. `run_config` now requires a zero strict error count instead of accepting the historical CSV error ratio. gfx1250 `grid.y` above `MAX_GRID_YZ` is rejected, as on gfx950.
- `cb25bbd`: adds `check_splitk_contract` to `op_tests/test_flydsl_conv_implicit.py`.
- `9ba793d`: skips that check (with a log line) when the backend is not gfx1250, because on gfx950 the same shapes take the MFMA path and nothing is captured.
- `a2c7577`: moves both operands from the legacy N-D `make_tdm_atom` + immediate-offset copy to the tiled `make_tiled_tdm_atom` + `tdm_partition` path used by the other gfx1250 kernels. Weights are K-tile aligned, so one descriptor covers the channel range and each round selects its K tile; input taps shift the base by whole rows and columns, which is not a multiple of the tile, so that side builds its descriptor per issue from a shifted base. The LDS tiles are unchanged, which keeps `LDS_PAD` / `pad_interval` derived from the LDS layout. `early_timeout` is not part of the tiled API.
- `06f6f49`: fixes the tiled weight partitioning: the complete padded B tile is partition mode 0 and a singleton rest mode is retained, matching the gfx1250 GEMM load path. In this commit A returns to the N-D descriptor/offset path so the weight side can be migrated on its own.
- `5741cb3`: moves the input gather to the tiled atom as well, building A per issue from the runtime tap offset; no `make_tdm_atom` call remains in the kernel.
- `6888112`, `c1b5708`, `ec511cd`: merge `main` into the branch; no kernel source change of their own.

Carried over from `11b8450`: `run_conv3d_gfx1250` accepts a caller-owned `out`, and the gfx1250 tuner NaN-fills it before each candidate so a kernel that leaves elements unwritten fails `strict_compare` instead of inheriting the previous candidate's values. `patch_reuse` is accepted but ignored on gfx1250.

Validation and unverified scope

At this head's commits (gfx1250, FlyDSL 0.4.1, as recorded in the commit messages of `134c1bd` / `cb25bbd` / `06f6f49`):

- Strict accuracy on representative NDHWC and NCDHW shapes with no split-K; outputs bitwise identical to the unmodified kernel for those cases; graph-replay time unchanged within noise (the host-side split-K resolution adds a few percent only on ~10-40 us launches).
- `check_splitk_contract`: all six checks pass (`no_tail`: automatic resolution 3, kernel compiled with the explicit split-K=2; `row_tail`: automatic resolution 1, kernel compiled with split-K=1, explicit 3 raises). The tree before the shared resolver fails the same function, so the check catches the regression it targets.
- `06f6f49` records two representative shapes on a07 GPU0 and d7 GPU1 with FlyDSL 0.4.1: ten NaN-prefilled accuracy checks per version and three bitwise baseline comparisons per shape. That record covers the weight-side migration only; the input side moved to the tiled atom afterwards, in `5741cb3`.
- The tiled TDM migration was validated as a whole at `ec511cd1` on gfx1250 (FlyDSL 0.4.1, one card): all 76 tuned rows x 2 output layouts x 10 runs through the tuned lookup (1520 calls), with 456 both-direction `rtol=atol=2e-2` checks finding zero elements outside tolerance, zero non-finite values and bit-identical output across repeats. The public entry served all 76 rows in NCDHW and NDHWC form (152 calls) under `FLYDSL_RUNTIME_RUN_ONLY=1` with no JIT fallback, so every tuned row's artifact still matches what the runtime requests. Against an fp64 reference on two layers the kernel stays within one bf16 ulp (99.97% of elements bit-identical) and is closer to fp64 than the fp32 reference. Same-card A/B on four representative layers shows no regression (paired medians -0.47%, -2.84%, -0.08%, -0.03%).

Earlier recorded results (gfx1250, one GPU, 256 CUs, FlyDSL 0.4.0, see the sections above):

- `PYTHONPATH=. python op_tests/test_flydsl_conv_implicit.py`: keyword cases `err=0`; small VAE smoke with `--wan-res 64x64 --wan-frames 5 --qwen-res 64x64`.
- Tuning with `csrc/flydsl_conv3d/conv3d_tune.py --mp 1 --timeout 600` from a CPU-precompiled cache under `FLYDSL_RUNTIME_RUN_ONLY=1`; 7440 candidates pass (2026-10-27). Separate 2026-10-26 sweep: 7444 candidates x 10 runs, NaN-filled outputs, no element outside `rtol=atol=2e-2`, no NaNs, no hangs.
- Performance: `run_perftest` (5 warmup + 101 iterations), two passes against `F.conv3d` with interference monitoring.
- AOT: both tables built with `aiter.aot.flydsl.conv` into an empty cache, all 76 rows served under `FLYDSL_RUNTIME_RUN_ONLY=1` and matching `F.conv3d`.

Unverified at this head:

- The full op test was not rerun in a clean environment after the TDM commits. In a container with torch 2.14.0+rocm10.2.0a20260922 and FlyDSL 0.4.1, `op_tests/test_flydsl_conv_implicit.py` fails 19/21 cases at this head, but the unmodified `5741cb3` head and `11b8450` fail the same way there, and torch `F.conv3d` matches CPU on that card. The failure is not attributed to this revision, so it is not used as evidence for or against it; it needs a rerun in the image the earlier results used.
- Numerical accuracy of split-K > 1 on gfx1250 through the public API: `check_splitk_contract` asserts the compiled split-K value, not the output values.
- gfx950 was checked on hardware at this head (`smci355-ccs-aus-n12-25`, MI355X, torch 2.10.0+rocm7.2.3, FlyDSL 0.4.1): three conv3d shapes (`1x32x4x16x16` 3x3x3, `1x64x1x32x32` 1x3x3 with pad, `1x32x3x32x32` stride 2) ran three times each with no non-finite element and no element outside `rtol=atol=2e-2` in either direction, max abs error 0.0039 / 0.0078 / 0.0156 (bf16 rounding steps), and outputs were bit-identical across repeats; `compile_transpose_ncdhw_ndhwc` also compiles on gfx950 (`1x64x1024`, `2x128x4096`). `conv3d_implicit_gfx950.py` and `conv3d_gfx950_utils.py` are untouched by this PR, so the exposure was `conv_kernels.py` and `conv3d_transpose.py`, bot

[truncated in readiness report; see the PR description for the full answer]

PR-specific question

The shared entry strips architecture feature suffixes and allow-lists only gfx950 and gfx1250, including before the pointwise matmul path. It checks supported convolution ranks and layouts, GPU tensors, bf16 input/weight, bias shape, consistent groups/channels, positive stride/dilation and valid padding semantics. After padding normalization and the pointwise fast-path check, only the remaining convolutions on gfx1250 select the new TDM/WMMA backend.

Host spatial padding and channel packing adapt valid inputs; they are not rejection checks. The gfx1250 backend requires positive output extents. Parameter/launch construction enforces aligned channels and CRS, WMMA tile/block geometry, at most 16 waves, split-K divisibility, split-K staging and grid limits (`grid.y` and `grid.z` <= `MAX_GRID_YZ`), and LDS/prologue capacity. `_resolve_splitk_gfx1250` is the single gate for split-K: H/W or output-channel tile tails and BIG_OUT force split-K 1 for tuned/automatic values and reject an explicit request > 1. Dynamic-shape ineligibility selects static compilation rather than rejecting an otherwise supported input. A supplied `out` must have the expected shape, bf16 dtype, the input device and contiguous storage.

These are the shared-entry and launch invariants, not a claim that direct backend calls validate every input or that cross-device operands are checked.

Changed op tests

The only changed op-test file is [op_tests/test_flydsl_conv_implicit.py](https://github.com/ROCm/aiter/blob/ec511cd18775a97bcb1f64fd3fb32e6d752daeea/op_tests/test_flydsl_conv_implicit.py).

- `3d_tail_blocks`: input `(1, 32, 3, 17, 19)`, 48 output channels, `64x64` tile, `block_rows=4`, padding and bias. H=17, W=19 and K=48 produce H/W block tails and an output-channel tail at once, covering the masked epilogue and the tail-driven static fallback; default/tuned model sweeps do not guarantee this combined geometry.
- `3d_tile_128` and `2d_tile_256` pin `block_rows=8`, exercising wider-tile 2D-block geometry explicitly instead of relying on heuristic or tuned selection. Validating gfx950's wave64 MFMA mapping does not cover gfx1250's wave32 TDM/WMMA mapping.
- `2d_splitk2` (adjusted) and `3d_splitk2` (added) use fixed tiles, `block_rows=4` and `patch_reuse=False` to avoid H/W/N tails in cases that request split-K. These are numerical checks; the 2D case has 27 K-tiles, so a request of 2 resolves to 1.
- `check_splitk_contract` (new, gfx1250 only, runs unfiltered): `no_tail` `x=(1,64,1,8,768)` checks that an explicit split-K=2 is the value the kernel is compiled with and that the automatic value matches the flat resolution the tuner records; `row_tail` `x=(1,64,1,3,2048)` (Ho=3 not a multiple of `block_rows=8`) checks fallback to 1 and that an explicit incompatible request raises. Every other case compares values only, so a split-K that silently differs between the tuned row, the kernel and AOT would pass them; this check is not redundant with them.

No negative-input rejection tests were added beyond the explicit split-K tail rejection.

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply
  • ADVISORY — Copilot did not review the current head SHA

Code and op-test hygiene

  • PASS — no committed artifact or conflict marker detected

Required CI

  • PASS — Black: passed
  • PASS — Ruff: passed
  • PASS — Repository dependency: passed
  • PASS — Aiter Test Gate: passed

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

@github-actions github-actions Bot changed the title [FlyDSL] Add gfx1250 implicit-GEMM conv3d [HIP] [FlyDSL] Add gfx1250 implicit-GEMM conv3d Nov 2, 2026
root and others added 4 commits November 2, 2026 03:33
…didate

run_conv3d_gfx1250 takes an optional out= (written in place; behavior is
unchanged without it). The gfx1250 tuner preallocates the NDHWC output and
passes output_keys=("out",), so mp_tuner NaN-fills it before every candidate
and a kernel that leaves elements unwritten fails strict_compare instead of
inheriting the previous candidate's result.

Co-authored-by: Cursor <[email protected]>
The gfx1250 backend accepted splitk in its public signature but the entry
point never forwarded it, and the tuner adapter deleted it before the call.
The tuned row could therefore record a split-K that was not the one executed,
while AOT compiled a third value from that row.

- Forward the public splitk argument to the gfx1250 backend.
- Resolve split-K in one gfx1250 helper that applies the tile-tail and
  BIG_OUT gates and distinguishes a caller's explicit request from a
  tuned/automatic value; use it from the runtime, the tuner and AOT so the
  tuned metadata, the executed kernel and the prepared artifact agree.
- Keep the compile-only gate in the gfx1250 dispatch so a launcher warmed in
  the same process is not dispatched with the AOT CPU probe arguments.
- Require a zero strict error count in run_config instead of letting the
  historical CSV error ratio forgive a current mismatch.
- Reject gfx1250 grid.y values above the shared MAX_GRID_YZ limit, as the
  gfx950 grid builder already does.

Verified on gfx1250 (FlyDSL 0.4.1): strict accuracy on representative NDHWC
and NCDHW shapes with no split-K, bitwise-identical outputs against the
unmodified kernel for those cases, and graph-replay time unchanged within
noise. The added host-side resolution costs a few percent on ~10-40us
launches only.
Every numerical case in this file compares values, so a split-K that changes
between the tuned row, the launched kernel and the AOT artifact was invisible
to it. Add one assertion set to the existing script, run unfiltered like the
compile-key and block-rows checks:

- no_tail, x=(1,64,1,8,768): an explicit split-K of 2 must be the value the
  kernel is compiled with, and the automatic value must equal the flat
  resolution the tuner would record.
- row_tail, x=(1,64,1,3,2048): Ho=3 is not a multiple of block_rows=8, so
  split-K must fall back to 1, and an explicit incompatible request must be
  rejected rather than silently changed.

Checked on gfx1250 with FlyDSL 0.4.1: the current tree passes all six checks
(no_tail auto=3 with the kernel at split-K=2; row_tail auto=1 with the kernel
at split-K=1 and explicit 3 raising). The tree before the shared resolver
fails the same function outright, so the check is red on the regression it
targets.
op_tests/test_flydsl_conv_implicit.py runs on every supported arch, but the new check captured the gfx1250 compile hook and the gfx1250 resolver. On gfx950 the same shapes take the MFMA path, whose split-K is derived inside _implicit_param_from_problem, so nothing was captured and the check failed there.

Skip the check when the backend is not gfx1250, with a log line, matching how the file already skips cases it cannot exercise.
main gained #7331, which rewrote op_tests/test_flydsl_conv_implicit.py
into ci/perf modes and added a 2d_splitk2 case asserting that split-K
survives host resolution. Keep that file and re-home the gfx1250-only
check inside it: the shared resolver assertions and the compile hook stay
behind a gfx1250 guard, so the gfx950 CI path is untouched. No other file
collides.
@zufayu
zufayu requested a review from aoli26 November 3, 2026 06:34
Replace the N-D make_tdm_atom + imm_offset pair with the tiled
make_tiled_tdm_atom + tdm_partition path the other gfx1250 kernels use.

Weights are K-tile aligned, so one descriptor covers the whole channel range,
the N tail is clamped by the view extent, and each round indexes the K tile it
needs. Input taps shift the base by whole rows and columns, which is not a
multiple of the tile, so that side builds its descriptor per issue from a
shifted base.

The LDS tiles are unchanged, which also keeps the padding: make_tiled_tdm_atom
derives pad_interval/pad_amount from the LDS layout, and lds_k already carries
LDS_PAD.

Behaviour changes to measure on gfx1250: early_timeout is not part of the tiled
API, and the input side now rebuilds its descriptor every round.
Pass the complete padded B tile as partition mode zero and retain a singleton rest mode, matching the gfx1250 GEMM load path. Keep the A descriptor/offset path while migrating the weight side independently.

Validated two representative shapes on a07 GPU0 and d7 GPU1 with FlyDSL 0.4.1: ten NaN-prefilled accuracy checks per version and three bitwise baseline comparisons per shape. Full configuration coverage and performance testing remain separate follow-ups.
…atom

Build the A atom per issue from the runtime tap offset, so the input side no longer uses the legacy N-D atom and no make_tdm_atom call remains in the kernel. B keeps the tiled weight path from the previous commit.
main gained #6956, which rewrote aiter/aot/flydsl/conv.py to build the AOT
cache by replaying the runtime. That deleted the hand-enumerated job and
per-kernel compile machinery this branch had extended for gfx1250, so all
six hunks conflicted; take main's file outright.

The gfx1250 compile keys now come from replaying flydsl_conv_implicit, which
already owns the channel pad (CGP_ALIGN), the split-K resolver and the
dyn_hw gate, so this branch's _conv_dedupe_key, _probe/_conv_probe_args and
_compile_conv3d_gfx1250_to_cache paths have no remaining caller.

Checked on gfx1250 (one card): replay builds 10 artifacts for a 5-row tuned
table, --check passes, and every entry point of those rows (2 input x 2
output layouts, bias omitted where the table has none) hits under
FLYDSL_RUNTIME_RUN_ONLY=1.

Numerical accuracy was not re-validated here: this container's toolchain
reproduces the same op-test failures as the pre-merge head, so the merge is
behaviour-neutral but the head's accuracy is still open.
@huizzhan
huizzhan requested a review from coderfeli November 4, 2026 06:41
_run_ci() now calls check_splitk_contract(), which reads the get_gfx module global that _load_backend() installs. tests/test_conv3d_ci_modes.py drives _run_ci() directly, so the name was undefined and the job failed with NameError on the default-dispatch case.

Patch script.get_gfx to a fixed arch in that test; the contract check is gfx1250-specific and returns early on gfx950, so no GPU backend is needed.
@coderfeli
coderfeli merged commit 47b4e08 into main Nov 5, 2026
@coderfeli
coderfeli deleted the feature/flydsl-conv3d-gfx1250 branch November 5, 2026 02:29
huizzhan added a commit to huizzhan/aiter that referenced this pull request Nov 16, 2026
Resolve the conflicts in csrc/flydsl_conv3d/conv3d_tune.py and README.md with
ROCm#6662 / ROCm#7503, which brought the gfx1250 tuner with the same fp32 reference,
strict_compare, run_kwargs and --run_config kernel_us this branch added. Take
main's version and keep this branch's gfx950 part on top of it: a splitK=1
gfx950 candidate is timed as the kernel alone on prepared operands into a
NaN-filled buffer (generate_data_kernel / run_flydsl_conv3d_kernel), split-K
still through the entry point; conv3d_ref keeps the NCDHW-contiguous fp32
input; the docstrings and README say us is kernel-only on both archs.
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.

3 participants