Skip to content

One Buffer per Attention unit - #40

Open
almogtavor wants to merge 2 commits into
mainfrom
buffer-per-attention-unit
Open

almogtavor wants to merge 2 commits into
mainfrom
buffer-per-attention-unit

Conversation

@almogtavor

Copy link
Copy Markdown
Member

Step 1 of #38.

Goal: each Attention unit writes to its own Buffer, so a unit can be added or removed without rebuilding the Buffers of the others.

Units(group, config, units) builds one Buffer per Attention unit over the same FFN ranks. Nothing else changes: the FFN ranks still wait for every unit.

Results (8x H100, one NVLink domain, exact match with the single-Buffer reference, eager and CUDA graph):

FFN ranks Units Attention ranks per unit Payload Hybrid Result
2 2 3 BF16 on pass
2 3 2 FP8 off pass
2 6 1 BF16 on pass
1 7 1 FP8 on pass
2 1 6 BF16 on pass
2 2 1 BF16 off pass

In every run the last unit closes its Buffer and the other units keep exchanging on theirs.
The existing suite (tests.gpu.deepep --lanes 2, BF16 and FP8) also passes, and so do the 59 unit tests and Ruff.

Not included: DBO inside a unit, and adding a unit while the others run.

Each Attention unit gets its own Gloo subgroup and Buffer, so an exchange or a close on one unit involves only the FFN ranks and that unit. The FFN ranks still wait for every unit they receive from. Lanes and Units share the helpers that give each Buffer its own communication stream.
@almogtavor
almogtavor requested a review from Etelis as a code owner November 17, 2026 12:55
@github-actions

Copy link
Copy Markdown
PR Preview Action v1.8.2

QR code for preview link

🚀 View preview at
https://afdEP.github.io/afdEP-comm/pr-preview/pr-40/

Built to branch gh-pages at 2026-11-17 12:56 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@almogtavor

almogtavor commented Nov 17, 2026 •

Copy link
Copy Markdown
Member Author

Performance: not ready to merge yet.

I measured decode throughput with one Buffer for all units against one Buffer per unit. The FFN ranks wait for every unit in both cases. With one Buffer per unit, throughput is equal at the small load and lower at the large load.

Sum of rounds per second over 6 units, median of 5 repetitions:

Rows per rank, split Alignment 128: one Buffer -> per unit Alignment 1: one Buffer -> per unit
128, random 212 -> 212 (0%) 211 -> 213 (+1%)
128, length 253 -> 224 (-11%) 256 -> 244 (-5%)
1024, random 256 -> 205 (-20%) 259 -> 241 (-7%)
1024, length 300 -> 207 (-31%) 316 -> 271 (-14%)

Setup: 8x H100 in one NVLink domain, 6 Attention units of one rank each, 2 FFN ranks, hidden size 4096, top-k 10, 256 experts per FFN rank. The routes and hidden states are a replay of Qwen/Qwen3.5-397B-A17B-FP8 layer 31 on ShareGPT V3. Each round includes the Attention computation of the layer on the Attention ranks and the expert computation on the FFN ranks, so these are rounds of one decoder layer, not serving throughput.

The numbers were measured on the tree of #33, which contains this change (native source digest b1324d32...), not on this branch itself (bc3d223c...).

Most of the loss disappears at alignment 1, so the likely cause is the padding of each expert to 128 rows, which is paid once per unit instead of once in total. I have not yet separated the remaining part. Prefill and mixed load are being measured now.

I am going to find the cause before asking for a review.

@Etelis

Etelis commented Nov 17, 2026

Copy link
Copy Markdown
Member

I tried one shared buffer vs. one buffer per Attention unit on three H100 nodes over RoCE. The separate groups helped at larger batches, but each FFN rank had to keep more GPU memory reserved.

Layout Groups 1 token/rank 1,024 tokens/rank GPU memory per FFN rank at setup
2 units 1 shared 83 µs 1,138 µs 698 MiB
2 units 2 separate 90 µs 870 µs 968 MiB
5 units 1 shared 215 µs 1,339 µs 678 MiB
5 units 5 separate 156 µs 1,134 µs 1,380 MiB

I also kept the ranks and work fixed and ran the same six chunks through either one reused buffer or six separate buffers. Each timing is for all six chunks.

Tokens per chunk per Attention rank Reuse one buffer Cycle through six buffers Extra latency
1 404.9 µs 416.7 µs +2.9%
16 539.1 µs 617.0 µs +14.4%
128 1,192.4 µs 1,302.9 µs +9.3%
1,024 4,083.4 µs 4,182.2 µs +2.4%

Both tables time communication only. In a separate two-group run, the default GIN settings hit the 8 MiB memlock limit. Raising it fixed startup.

Could we keep the shared buffer as the default and add a flag for per-unit buffers?

@almogtavor

Copy link
Copy Markdown
Member Author

Why would it consume more memory? @Etelis

This branch has not been deployed

No deployments
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