Skip to content

Support FFN ranks on every node - #27

Merged
Etelis merged 14 commits into
mainfrom
ffn-domains-hybrid
Nov 8, 2026
Merged

Etelis merged 14 commits into
mainfrom
ffn-domains-hybrid

Conversation

@Etelis

@Etelis Etelis commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Part of #18. Supersedes #22, whose commits are included as they were.

What and why

FFN ranks had to be ranks [0, F). DeepEP numbers ranks node by node, so the FFN always landed on the first node(s). This PR lets every node hold FFN GPUs, so a deployment can scale by adding identical nodes. It also makes that layout faster.

Main changes

  • ffn_ranks_per_domain=f. The first f GPUs of every node are FFN ranks. Callers keep real expert IDs, and the library maps them to DeepEP's numbering.
  • FFN GPUs skip all cross-node work. No tokens travel on their rails.
  • Attention GPUs no longer wait at a cross-node barrier before each dispatch. That barrier only kept a peer's next dispatch from arriving while this GPU was still combining. To make the early arrival safe:
    • combine signals get their own words, instead of sharing them with dispatch progress;
    • replies and combine staging move to the reserved area at the end of the buffer, where the next dispatch can't overwrite them.
  • Hybrid off (one RDMA hop per token) also works for this layout. It needed a fix in DeepEP's GIN barrier: a GPU could read same-node data before it had arrived. FastAFD's DeepEP M2N has the same bug.

Result (comm-only, kermit, 4 × H200 per node, FP8):

  • Dropping the barrier makes per-node FFN 1.4–8.5% faster on the hybrid path.
  • It's 3.4–16.1% faster than FastAFD's DeepEP M2N in the same layout.
  • Putting the FFN on the first node(s) is still faster below 512 tokens. Per-node FFN wins at 512 tokens on 3 nodes.

Details are in docs/design.md §20.

Checks

  • Unit tests and Ruff pass.
  • GPU suite exact on 2 and 3 nodes: one to three FFN GPUs per node, BF16 and FP8, hybrid on and off. Existing layouts are unchanged, and invalid routes still assert.
  • Fault injection with one node lagging: the change passes, and removing any one of the safety fixes makes it fail.
  • Screens against the per-node layout before this change, FastAFD's DeepEP M2N, and today's best layout, with each arm's source digest recorded.

Evidence

docs/validation-attention-rails.json, plus the per-domain records from #22 (docs/validation-per-domain*.json, docs/validation-direct-per-domain*.json).

Etelis added 13 commits October 26, 2026 18:07
ffn_ranks_per_domain f puts the FFN ranks at local ranks [0, f) of every
NVLink domain, so layouts like 4A1F on each of two nodes can run (#18).
Every domain then holds both roles, which neither directional protocol
covers, so these layouts run the union hybrid with per-rank roles. Sources
validate their real routes as the route guard does and translate them to
DeepEP's logical experts in a new kernel; shared device sources are
unchanged. The FastAFD baseline maps real IDs the same way.

Signed-off-by: Itay Etelis <92247226+Etelis@users.noreply.github.com>
With ffn_ranks_per_domain set, the NVLink domains must always be the
layout's, so f == F across several domains is rejected instead of
silently running the global prefix. Dispatch asserts the domain shape
and the handle copy for native callers. The comm benchmark maps the
baseline's IDs once outside timing and keeps them alive with the graph,
and rejects arms that give a rank different roles.

Signed-off-by: Itay Etelis <92247226+Etelis@users.noreply.github.com>
Design section 20 describes the per-domain FFN prefix, its GPU-suite
record on 2 x 4 and 3 x 4 H200 (source ece614e6) and comm-only screens
against today's layouts. The union protocol runs it at FastAFD M2N's
speed: 12-27% slower than the directional and mixed-role protocols up
to 128 tokens, 4-5% faster than the union with the FFN on one node at
512 tokens.

Signed-off-by: Itay Etelis <92247226+Etelis@users.noreply.github.com>
With FFN GPUs at local ranks [0, f) of every NVLink domain, each FFN rail
joins FFN GPUs only, none of them a source, so nothing crosses domains
on it. FFN GPUs now run generated copies of the hybrid dispatch and
combine that skip every scale-out action (rail barrier halves, counts,
finish tails, combine signals and waits) and keep their NVLink work and
scale-up barriers; Attention GPUs keep the union kernels. A per-call
gate (2L <= U) keeps their partials below a forwarder's unflushed
dispatch staging and falls back to union otherwise. The agreement tuple
reports the per-domain protocol. GPU suite on 2 x 4 and 3 x 4 H200 in
docs/validation-silent-ffn-rails.json.

Signed-off-by: Itay Etelis <92247226+Etelis@users.noreply.github.com>
DeepEP V2's direct (non-hybrid) kernels write NVLink-reachable peers
with TMA stores and the others with RDMA, then pass a barrier that
flushes the QPs and signals through the NIC. Flushing covers RDMA only,
so a same-node receiver could see the signal before the NVLink rows and
read stale data whenever a node holds both senders and receivers
(FastAFD's DeepEP M2N too). The GIN barrier now fences at system scope
before its flush and signals. On 2 x 4 H200, 8 of 8 runs mismatched
without the fence or with the proxy fence alone, and 8 of 8 passed with
the system fence. NVLink barriers are unchanged.

Signed-off-by: Itay Etelis <92247226+Etelis@users.noreply.github.com>
With hybrid off, DeepEP folds the NVLink domains into one logical domain,
so per-domain roles and the route translation now use the physical
domain size, the in-kernel route check gives way to the translating
one, and ffn_ranks_per_domain no longer requires hybrid mode. Each
Attention GPU then reaches each FFN GPU in one RDMA hop. GPU suite on
2 x 4 and 3 x 4 H200 in docs/validation-direct-per-domain.json.

Signed-off-by: Itay Etelis <92247226+Etelis@users.noreply.github.com>
Design section 20 records silent FFN rails, the GIN barrier fence and a
decode screen on 2 x 4 and 3 x 4 H200: with one FFN GPU per node the
direct path wins up to 32 tokens and beats every FFN-first layout on
three nodes, while hybrid wins from 128 tokens and with two FFN GPUs
per node.

Signed-off-by: Itay Etelis <92247226+Etelis@users.noreply.github.com>
With FFN GPUs at local ranks [0, f) of every NVLink domain, each
Attention rail joins one Attention GPU per domain, and each is both a
source and its rail's forwarder. Attention GPUs now also run the
generated per-domain copies, which keep the union kernels' work but no
rail half of the dispatch-entry or combine-entry barrier: every write
across domains for exchange N+1 follows its reader's exchange-N reads
through the round trip. Combine signals take their own words, because a
GPU that both forwards and collects receives a peer's dispatch tail and
its combine signal in the same word, and every rank's reply inbox and
combine staging move into the slices reserved at the window end, as in
the mixed-role hybrid. FFN GPUs keep silent FFN rails or union per call;
the rails are disjoint. The agreement tuple reports the protocol.

Signed-off-by: Itay Etelis <92247226+Etelis@users.noreply.github.com>
The per-domain combine now asserts at compile time that the hybrid tail
words (channels x domains) stay below the combine signal words. The
argument beside afdep_domain_attention_rails also states that it
assumes strict dispatch/combine pairing, which afdep/deepep.py enforces,
and that AFDEP_UNION_HYBRID must be set before construction. The silent
FFN rails comment and its provenance entry no longer say that Attention
GPUs keep the union kernels.

Signed-off-by: Itay Etelis <92247226+Etelis@users.noreply.github.com>
Design section 20 describes the protocol and its three changes, with
comm-only screens on 2 x 4 and 3 x 4 H200 against the per-node hybrid
of #22, the mixed-role and directional layouts and the direct path of
#24: 1.9-9.4% (3.8-10.0 us) faster in every cell, which ties the
mixed-role layout at 512 tokens on two nodes and beats it by 4.6% on
three. The record has the GPU suite on 27c46154 and deferred-put fault
injection: the protocol and a barrier control pass with one domain
lagging, and each negative control (shared signal words, reply inbox
or combine staging at DeepEP's offsets) fails.

Signed-off-by: Itay Etelis <92247226+Etelis@users.noreply.github.com>
FastAFD's DeepEP M2N in the same per-node layouts is 3.7-16.3% slower
than this branch in every cell and repeat. That screen ran in a second
session on the same nodes, where this branch and #22 re-measured within
1% of the first. Design section 20 gains a row per table.

Signed-off-by: Itay Etelis <92247226+Etelis@users.noreply.github.com>
A screen on 2 x 4 and 3 x 4 H200 split the gain: dropping only the
dispatch-entry rail half gives all but 0.7 points of it, dropping only
the combine-entry rail half gives nothing measurable. Attention GPUs
now keep the combine-entry barrier, as in #22. The three fixes stay,
because each guards the next dispatch landing early: combine signals
on their own words, and every rank's reply inbox and combine staging in
the end slices.

The change is also smaller: Attention rails follow afdep_domain_hybrid
instead of a new selector (so the agreement tuple is unchanged), the
combine-word offset lives in the generated copy instead of a header,
one helper names the layouts that use the end slices, and the comments
are condensed.

Signed-off-by: Itay Etelis <92247226+Etelis@users.noreply.github.com>
Design section 20 now describes the protocol as shipped (dispatch-entry
rail half dropped, combine-entry barrier kept) in one short section with
a screen per layout: 1.4-8.5% (3.1-9.1 us) faster than #22's per-node
hybrid in every cell and repeat, and 3.4-16.1% faster than FastAFD's
DeepEP M2N in the same layout. The record is tied to bc3d223c: the GPU
suite (25 runs, invalid routes), deferred-put fault injection where the
protocol and a barrier control pass and each negative control fails
(the reply-inbox control at capacity 512, where the regions overlap),
the barrier split and the screens, as summaries instead of raw
processes.

Signed-off-by: Itay Etelis <92247226+Etelis@users.noreply.github.com>
@Etelis Etelis changed the title Per-node FFN: Attention rails without entry barriers Per-node FFN: Attention rails without the dispatch-entry barrier Nov 1, 2026
@Etelis
Etelis changed the base branch from ffn-domains to main November 1, 2026 15:41
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.2
Preview removed because the pull request was closed.
2026-11-08 06:13 UTC

@Etelis Etelis changed the title Per-node FFN: Attention rails without the dispatch-entry barrier Support FFN ranks on every node Nov 2, 2026
@Etelis
Etelis requested a balanced review from Copilot November 2, 2026 07:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@Etelis
Etelis marked this pull request as ready for review November 2, 2026 07:12
@Etelis
Etelis requested a review from almogtavor as a code owner November 2, 2026 07:12
@Etelis
Etelis merged commit 741b9aa into main Nov 8, 2026
5 checks passed
@Etelis
Etelis deleted the ffn-domains-hybrid branch November 8, 2026 06:12
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