Skip to content

[HIP] Gfx1250 ll128 cas2shot - #5616

Closed
TennyWang1223 wants to merge 2 commits into
mainfrom
gfx1250_ll128_cas2shot
Closed

TennyWang1223 wants to merge 2 commits into
mainfrom
gfx1250_ll128_cas2shot

Conversation

@TennyWang1223

Copy link
Copy Markdown
Contributor

Motivation

gfx1250 custom_all_reduce perf optimize with 2 new kernel: LL128 ar, cas_sync ar

Technical Details

use LL128 proto in middle size case
replace start_sync and end_sync by cas_sync in simple proto allreduce kernel at little bigger case

Test Plan

see ut

Test Result

LL128 ar optmize middle size case(tp4: [64 * 8192, 1024 * 8192), tp2: [512 * 8192, 8192 * 8192) ), cas_sync ar optimize big size case(tp4:[1024 * 8192, car_max_inp_size), tp2: [8192 * 8192, car_max_inp_size)), small size case still use LL ar, so there is no perf change at small case, perf speedup only in middle case and big case

tp4

  inp shape main(us) new(us)
1024 8.15173 8.0432
2048 8.08729 8.16327
4096 8.9654 8.92976
7168 9.47128 9.66376
8192 9.56235 9.58275
2*7168 9.51827 9.65726
2*8192 9.59254 9.41531
4*7168 9.76326 9.5056
4*8192 9.30216 9.46216
8*7168 9.38907 9.52538
8*8192 9.48378 9.37105
16*7168 9.68099 9.57648
16*8192 9.69899 9.68703
32*7168 10.7197 10.8654
32*8192 10.9762 10.7838
64*7168 13.1434 12.4853
64*8192 13.0442 13.1241
128*7168 18.6827 15.8534
128*8192 19.6389 16.7339
256*7168 31.3752 25.5031
256*8192 32.4365 26.3072
512*7168 74.2109 46.2062
512*8192 84.1591 47.958
1024*7168 127.617 72.1395
1024*8192 143.949 77.1561
2048*7168 236.018 105.676
2048*8192 261.208 120.204
4096*7168 436 160.893
4096*8192 493.437 181

tp2

inp shape main new
1024 7.5302 7.52866
2048 7.45195 7.5136
4096 8.08854 7.6548
7168 8.76918 7.57564
8192 8.81069 7.71748
2*7168 8.62961 8.37235
2*8192 8.7362 8.12017
4*7168 8.4946 8.42365
4*8192 8.63972 8.43372
8*7168 8.48936 8.45099
8*8192 8.53745 8.49663
16*7168 8.5136 8.67337
16*8192 8.5566 8.52597
32*7168 8.73247 8.65818
32*8192 8.81467 8.77146
64*7168 9.2428 9.223
64*8192 9.42118 9.40881
128*7168 13.204 10.5741
128*8192 13.9736 11.183
256*7168 22.5199 15.7527
256*8192 22.9536 16.1813
512*7168 34.6918 21.8386
512*8192 35.4806 22.9447
1024*7168 47.8687 34.9285
1024*8192 49.6193 37.0888
2048*7168 72.1109 58.0645
2048*8192 79.1672 68.8529
4096*7168 125.759 113.464
4096*8192 140.294 129.59

Submission Checklist

@TennyWang1223
TennyWang1223 requested a review from a team September 17, 2026 04:08
@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
multigpu 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: 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 5616 --add-label <label>

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 opt this PR out.

@github-actions github-actions Bot changed the title Gfx1250 ll128 cas2shot [HIP] Gfx1250 ll128 cas2shot Sep 17, 2026
@github-actions github-actions Bot added the HIP label Sep 17, 2026
TennyWang1223 and others added 2 commits September 17, 2026 07:18
Ports ar_ll128_vec_unroll2 and ar_cas_2shot_gfx1250 from the POC branch and
routes by measured size thresholds (bf16/fp16, world_size 2 or 4):

  ws=4:  <=1 MiB LL/512, <=2 MiB LL128/512, <=16 MiB LL128/1024, else CAS/1024
  ws=2:  <=8 MiB LL/1024, <=64 MiB LL128/1024, else CAS/1024

Raising the tp2 LL band to 8 MiB doubles the LL staging scratch, so the meta
buffer grows from 64 to 128 MiB. The LL128 and CAS buffers deliberately do NOT
live there: sized for the worst-case world size they would cost every rank
hundreds of MiB, so each rank allocates its own and the bases get a second IPC
exchange. Both bands stay disabled (falling back to the naive kernel) until
that exchange runs, which is also how the VMM transport — where a plain
hipMalloc cannot be exported — keeps working.

The b128 load/store helpers keep the POC's system-scope builtins rather than
the gfx9 port's nontemporal ones: a split access can expose an updated flag
over stale payload.

Also adds ar_cas_2shot_gfx1250_scratch, which stages the reduce-scatter in a
separate buffer so the input stays read-only. The routed kernel overwrites the
caller's registered input, which is fine when the host staged a copy but not
under graph capture with an already-registered input. It is reachable only via
its standalone entry point pending a perf comparison.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: TennyWang1223 <[email protected]>
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

No activity for 15 days, so this is now labelled stale. A push or a comment clears it; keep-open exempts it. Nothing is closed automatically.

@github-actions github-actions Bot added the stale The PR hasn't been updated in 2 weeks label Oct 7, 2026
@AndreasKaratzas

Copy link
Copy Markdown
Contributor

The gfx1250 LL128 kernel in this PR computes its slot stride and bank offset from the message size (total_group * 128 * 2 / 4), like the gfx9 ar_ll128_unroll2. On gfx9 that causes a deadlock when consecutive calls have different sizes. A rank that has finished call k writes call k+1 into slots a slower peer hasn't read yet for call k. The peer then never sees the flag it's waiting for. We hit this on MI355 under host load, and #6446 fixes it for gfx9. That PR has rocgdb dumps of the overwritten words at TP2 and TP4, an address model that predicts them, and a regression test.

The gfx1250 kernel looks exposed in the same way. This is from reading the code; I haven't run it on gfx1250. Your scratch is already sized for the largest message, so the fix needs no extra memory: compute the per-rank stride from ll128CapBytes(world_size) on the host, pass it to the kernel, and use it for both the bank offset and the slot offsets. You can check it with the test in #6446 (test_allreduce_ll128_mixed_size_regression) by using three different LL128 sizes per round, so each size alternates banks. Two sizes always land in the same bank and can miss the bug.

@github-actions github-actions Bot removed the stale The PR hasn't been updated in 2 weeks label Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants