Skip to content

chore(EPv2): drop redundant total_recv.zero_() on gfx1250 intranode - #735

Merged
kawhil-amd merged 1 commit into
ROCm:mainfrom
kawhil-amd:fix/ep-intranode-self-resets-counters
Oct 10, 2026
Merged

kawhil-amd merged 1 commit into
ROCm:mainfrom
kawhil-amd:fix/ep-intranode-self-resets-counters

Conversation

@kawhil-amd

@kawhil-amd kawhil-amd commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • The gfx1250 dispatch kernel's first-arriver unconditionally overwrites totalRecvTokenNum every call, making the host-side total_recv.zero_() fill kernel redundant
  • Gate self_resets_counters on self._is1250 so only gfx1250 skips the zero — gfx942/950 still need it because their dispatch uses atomicAdd and relies on combine to clear it

Test plan

  • Existing EPv2 intranode tests pass on gfx1250 (dispatch + combine round-trip)
  • Existing EPv2 intranode tests pass on gfx942/950 (unchanged behavior)

🤖 Generated with Claude Code

The gfx1250 dispatch kernel's first-arriver unconditionally overwrites
totalRecvTokenNum, so the host-side fill kernel is redundant.  Gate
self_resets_counters on _is1250: gfx942/950 still need the host zero
because their dispatch uses atomicAdd and relies on combine to clear it.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@kawhil-amd
kawhil-amd requested a review from jhchouuu October 10, 2026 03:33
@kawhil-amd kawhil-amd changed the title fix(EPv2): drop redundant total_recv.zero_() on gfx1250 intranode chore(EPv2): drop redundant total_recv.zero_() on gfx1250 intranode Oct 10, 2026

@jhchouuu jhchouuu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kawhil-amd

Copy link
Copy Markdown
Contributor Author
image test passed in gfx1250

@kawhil-amd
kawhil-amd merged commit 76d0b30 into ROCm:main Oct 10, 2026
zhangfei829 added a commit that referenced this pull request Oct 11, 2026
Conflicts were all #726's selfFirst-follows-TOKOFF_EXT, which this branch already replaced with aggReserve on the same tokOffExt field; kept the branch side. #725's EP4 topk 8/9 dispatch rows are taken, and its topk 9 row is folded into the one (4, 7168, 9) key so #726's fp4 row no longer shadows it. #735 is taken: the gfx1250 dispatch still stores totalRecvTokenNum.
@zhangfei829 zhangfei829 mentioned this pull request Oct 11, 2026
zhangfei829 added a commit that referenced this pull request Oct 11, 2026
gfx1250 EPv2: one-RMW slot reservation, EP16 fp4 dispatch and push combine, fp8 push combine

## Summary
- Dispatch slot reservation: a rank's blocks add up their token counts and the last block reserves once per destination (one RMW on the slot word instead of one per block). Replaces selfFirst; `MORI_EP_TOKOFF_EXT=1` keeps the per-block protocol for a single-host EP.
- EP16 fp4 dispatch: 128x16 sends each destination's rows from a pinned set of warps.
- fp4 push combine: the landing offset rides the 64-bit dispatch signal, and the landing area is M x min(world, topk) rows instead of world x world x M, so EP16 push fits at 16384 tokens a rank.
- fp8 push combine (`fp8_blockwise`).
- EP16 64x16 bf16/fp8: a metadata warp holding exactly two runs loads both, then stores both. Built into those instances and chosen at run time, with no switch.
- Tuning tables: EP16 dispatch and fp4 push combine, EP4 fp8 push combine. Removed the `MORI_V2_EP_{DISP,COMB}_{BLOCKS,WARPS}` overrides.
- Merged main: #725 and #735 taken; #726's selfFirst change superseded. The duplicate `(4, 7168, 9)` dispatch key on main is folded into one, so #725's topk 9 row takes effect.

## Test
CHECK=1 passes on EP4 (topk 6 and 9), EP8 (2 hosts) and EP16 (4 hosts) at 1 / 64 / 512 / 4096 / 8192 / 8193 / 16384 tokens a rank, for fp4 push, fp4 pull, bf16 and fp8 push.

EP16 (4 hosts x 4 gfx1250), fp4 dispatch, topk 6, 96 experts/rank, HIP graph, ITERS=50, 3 alternating rounds, medians in us. The baseline has main's kernel and its untuned 64x16 geometry; main cannot allocate the fp4 push landing area at EP16 with 16384 tokens, so its combine is pull. The fp4 machine code is identical to this branch's head.

| tokens/rank | dispatch main → branch | combine main (pull) → branch (fp4 push) |
|---:|---:|---:|
| 64 | 27.39 → 26.56 | 17.95 → 16.02 |
| 512 | 38.83 → 31.66 | 50.57 → 28.33 |
| 4096 | 113.03 → 92.57 | 275.81 → 87.99 |
| 16384 | 378.46 → 292.98 | 1032.22 → 302.42 |

EP4 is about even with main: topk 9 fp4 push, same node, 3 alternating rounds, dispatch +0.1..+1.2 us, combine +0.2..+0.7 us (+2.5 at 1536).
@kawhil-amd
kawhil-amd deleted the fix/ep-intranode-self-resets-counters branch October 12, 2026 02:14
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.

2 participants