Skip to content

[checkpoint] Put between hosts through a transfer window: puts, puts='auto' and packed reserves - #9149

Draft
jinyouzhi wants to merge 17 commits into
deepspeedai:masterfrom
jinyouzhi:affine-window-put
Draft

jinyouzhi wants to merge 17 commits into
deepspeedai:masterfrom
jinyouzhi:affine-window-put

Conversation

@jinyouzhi

@jinyouzhi jinyouzhi commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #9118 (which is stacked on #9094); only the last 8 commits belong to this PR. Part of RFC #9026.

Draft / WIP — the code is complete and the unit tests pass on one node with fake hosts, but the multi-GPU two-node runs still have to be redone after the rebase. See the WIP list below.

What changes

TransferWindow can now span hosts. The puts= option chooses how a cross-host operation moves:

  • Staged (default): the operation stays in the NCCL lane as before.
  • puts=True: if NCCL symmetric memory maps the peer (symm_mem_mapped_peers), the operation is put directly into the peer's window shard. Puts are grouped per window, so fan-out does not pay one launch per operation.
  • puts='auto': a sender puts only when it has exactly one peer on another host and sends it at least AUTO_PUT_BYTES (256 MiB) or AUTO_PUT_PARAMETERS (64) parameters; otherwise it stages. The thresholds come from the H20 numbers below, so this is a heuristic, not a cost model (see the note below). The resolved senders are part of the plan fingerprint, so every rank agrees on them.
  • Packed reserve: strided cross-host transfers (for example rows → column bands) are packed into a contiguous window reserve, put once, and unpacked on the target. This avoids many small strided puts.
  • Validation and aliasing:
    • Window options are validated when scheduled, and a changed puts/reserve on a reused plan is refused.
    • Puts and packed operations leave the lane, so they now go through the window alias check. Without this a put or pack that overwrote a region still being read would hang or corrupt data; the new test covers both cases.
  • No registered/plain mixing in send/recv: NCCL leaves a send or receive undefined when one side's buffer is registered with the communicator and the peer's is not; between hosts it hung (NCCL 2.29.7 and 2.32.6). A staged region that lies in the window is therefore sent or received through the plain arena, never in place. [checkpoint] Fused copies, symmetric-memory window and staging release for prepared affine transfers #9118 does this for any live window on the process; this PR also does it for the shards of the passed window in schedule_transfers, so the schedule matches what runs.
  • Hosts that map each other (MNNVL / NVLink domain) copy in place, like a single host.

Puts need torch.distributed._symmetric_memory.put_signal (NCCL backend). With an older torch, puts=True raises a clear error and 'auto' falls back to staging. Single-host windows and XPU are unchanged.

Performance (2×8 H20, RoCE, before the rebase)

Case Staged Put / Pack
Put to 1 peer, 256 MiB 15.3 ms ~12 ms
2048 × 128 KiB parameters 24.7 ms 13.7–14.2 ms
Fan-out to 8 peers 13.3 ms 15.4–15.8 ms grouped (35 ms ungrouped)
32 MiB 2.0 ms 2.8 ms
Pack rows→cols, 128 MiB 4.9–5.2 ms 4.0 ms
Pack rows→cols, 512 MiB 15.6–16.4 ms 15.3 ms

Puts win for large transfers with low fan-out. Staging wins for wide fan-out and small sizes, which is why 'auto' exists and staging stays the default.

Two real nodes, one GPU each (H20 ↔ H20, RoCE, after the rebase onto current #9118), median ms:

Case staged put pack auto
rows→cols 32 MiB 1.11 1.10 1.07 1.10
rows→cols 512 MiB 15.36 15.52 12.88 15.55
1 peer 32 MiB 1.93 1.70 1.70 1.97
1 peer 512 MiB 27.96 22.55 22.55 22.55
128 KiB parameters, 32 MiB 3.18 1.73 1.72 1.73
128 KiB parameters, 512 MiB 47.01 22.96 22.65 22.65

All 24 cases are bit-exact. Rows→cols with put used to hang here (registered/plain mixing); its strided regions are now staged through the arena, and pack puts them. At 1 peer 32 MiB, 'auto' stages because the transfer is below its thresholds, although a put is faster: a case a cost model could handle better.

Tests (after the rebase onto current #9118)

Where Result
CPU (gloo), executor + planner tests 545 passed, 39 skipped
H20, 2 GPUs, executor + planner tests 545 passed, 39 skipped (4-process tests need 4 GPUs)
L20, 4 GPUs, executor file (fake two hosts), before the rebase onto master 137 passed
Two real nodes, 1 GPU each, benchmark above 24/24 bit-exact
New alias test without the fix hangs (so it catches the bug)

WIP: tests to rerun or still to run

  • Real two-node runs with several GPUs per node (2×4 / 2×8) after the rebase; the 1×1 run above is done. Earlier, before the rebase, 2×8 was 40/40 bit-exact.
  • 4-GPU unit tests after the rebase onto master (the GPUs were taken).
  • 32 MiB rerun for rows→cols and 8-peer fan-out, all four modes, 30 iterations.
  • Look into the ~0.8 ms gap of 'auto' on small fan-out sizes.
  • B70 / XPU regression of the single-host window path after the rebase. Puts are CUDA-only, so this only checks that nothing changed.
  • Real MNNVL / NVLink-domain hosts. test_hosts_that_map_each_other_copy_in_place is mocked.

Note for the cost model (cc @Achyuthan-S)

'auto' is only a fixed threshold rule for this transport: the 1×1 numbers above show it staging where a put is faster, while at an 8-peer fan-out staging wins. No change to the cost model from #9145 is planned here. If it later takes this transport into account, these may be useful:

  • A window run has costs besides the staged rounds: puts and signals, pack/unpack copies, mapped copies inside a host, and a closing barrier.
  • 'auto' decides per sender, so all ranks have to resolve it the same way (it is part of the plan fingerprint).
  • 'auto' can stay as the fallback when no fitted model is available.

Future work (limited by torch / NCCL or the environment)

  • Device-side (GIN) puts, so a kernel can issue the fan-out itself: torch does not expose them, and NCCL reports "GIN not supported" on our nodes. This is what would close the 8-peer fan-out gap.
  • Several NCCL contexts or signal indices, for example for credit signals: torch hard-codes ctx=0 and sigIdx=0 in put_signal/wait_signal.
  • Several communicators to spread puts over: possible, but costly in memory and setup.
  • NVSHMEM/Triton device puts: a separate transport, not started.
  • MNNVL / GH200 domains: the code copies in place between hosts that NCCL maps, but this is only tested with mocks.

This PR was prepared with AI assistance (GitHub Copilot CLI); all changes were reviewed and tested by the author.

@jinyouzhi

jinyouzhi commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

@Achyuthan-S just an FYI, no action needed: this PR adds a cross-host put transport for windows, and its puts='auto' is a simple threshold rule for now. If the cost model from #9145 or the policy in #8936 ever wants to take this transport into account, the "Note for the cost model" section in the description lists what it would involve. It's entirely your call.

0z5a and others added 17 commits November 23, 2026 15:08
A weight sync moves the same batch every step, and every
execute_transfers call repeats validation, the alias check, scheduling,
the digest agreement, arena allocation and region views before the
first byte moves.

prepare_transfers does that work once and returns a PreparedTransfer
whose run only moves data. The handle keeps the arenas that deepspeedai#9027's
schedule reports, and for each round one list of (destination, source)
views: the packs before a send and the unpacks after a receive, plus
one list of local copies. execute_transfers is now prepare_transfers
followed by one run, with the same collectives as before. Python's
cyclic collector is paused while the views are built: tens of
thousands stay alive together, and the collections their allocation
triggered made a one-shot call at 8 processes on CPU about a third
slower than master.

A buffer that moves after prepare, as reload_states moves offloaded
ZeRO-3 partitions, would leave those views writing into the old storage. So
run checks by default: each process compares its buffers (the held
tensors, or requests rebuilt from the live state) with what it
prepared, and one small all-gather refuses on every process, before
data moves, if a buffer moved on any of them or the processes are not
running the same handle for the same time.

The shape of prepare_transfers and the buffer layout check follow
#8 (a8c34e3); this is its staged half, without the
window transport.

Signed-off-by: 0z5a <dezhen.lu@student.uni-tuebingen.de>
Co-authored-by: Jin, Youzhi <youzhi.jin@intel.com>
…they run

Two handles prepared for the same batch over different buffers had the
same schedule digest, so run's check passed when each process ran a
different one, and the peers exchanged payloads of different batches.
Each process now counts its prepare_transfers calls and adds the count
to the prepare all-gather. A handle's identity is a hash of the digest
and the gathered counts, the same on every process, and the check
compares that instead of the digest. The scheme is jinyouzhi's, from
the review.

execute_transfers no longer goes through a handle. It runs the same
preflight and agreement, then builds each round's views when the move
reaches that round, as it did before prepare_transfers, so building
them overlaps the previous round's transfer. On L20 GPUs, building them
all first made a one-shot call 10-16 ms slower than master.

The docs and the handle's docstring now say that run() checks only the
tensors the handle holds: a view such as zero_param_storage_shard
returns keeps the old storage when reload_states re-points the
partition, so such handles need run(requests) rebuilt from the live
state. They also say that a handle keeps its buffers allocated until it
is dropped.

The prepared-run test no longer reads the handle's private rounds, and
the garbage-collector test refuses through a too-small budget instead
of patching a private helper.

Signed-off-by: 0z5a <dezhen.lu@student.uni-tuebingen.de>
A prepared handle decides at prepare which local copies are dropped as in place, so a run must refuse a
buffer set that would change that decision. The layout it compares now carries each buffer's conjugate
and negative bits next to its address, shape and strides, and the docs say that check=False cannot see
such a change.

The relay-band and lazy-view tests run through prepare_transfers as well, and a new test rebuilds the
band at run time (cloned, as a negative view, or as a copy where the handle kept a view) and expects
every process to refuse with the destination untouched.

Signed-off-by: 0z5a <dezhen.lu@student.uni-tuebingen.de>
prepare_transfers takes a copier that turns each round's pack/unpack list
and the local copy list into one callable. sequential_copies (default)
keeps one copy_ per region; fused_copies builds a per-alignment tile
table at prepare time and moves the list with one Triton launch per
class on CUDA/XPU, falling back to copy_ elsewhere.

Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
symm_mem_rendezvous allocates a buffer every member of a group can address
and exchanges its handles; symm_mem_peer_tensor maps one peer's buffer into
this process. On backends whose peer views carry no device index (XPU),
the view is rebuilt from the mapped address.

Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
…runs

TransferWindow is a symmetric-memory pool every process of the group can address. An operation between two processes whose source or target lies in a window is copied in place by one of them (the target pulls or the source pushes) with no message, arena or budget; the rest of the batch keeps the staged protocol. Ranks agree on which shards lie in a window as part of the schedule digest, and a run with window copies ends with a group barrier.

Window copies are (destination, source) pairs like a round's packs and unpacks, so the same copier builds them: fused_copies covers copies whose source or destination lies in a peer's mapped window.

PreparedTransfer.release_staging() frees the arenas between runs; the next run allocates them again, and a process that cannot refuses on every process when run checks.

Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
…s off the tile kernel

Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
…the owners' writes, and keep restaging from escaping the check

- A window gets an identity shared by its group and the group's ranks at construction. Both go into the
  agreement, so different windows on different processes are refused instead of copying from the wrong
  one, and a window made over another group than the transfer's is refused locally.
- Every run without check that makes window copies starts with a barrier, the first one too: owners
  may write their shards between prepare and that run.
- With check, a moved buffer is detected before restaging, and any failure to restage joins the
  collective refusal, so one process can no longer raise alone while its peers wait in the check.
- A prepared transfer holds its window, so the peer memory its copies address lives as long as it does.
- fused_copies leaves empty regions to copy_ rather than dividing by a zero tile width.
- symm_mem_rendezvous checks that torch has the allocation API it calls.

Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
NCCL leaves a send or receive undefined when one side's buffer is registered with the communicator and
the other's is not, and it hangs on that pair between hosts. A process cannot know how its peer's buffer
was allocated, so a region of this process that lies in any live window, passed to the transfer or not,
is staged through the plain arena instead of being sent or received in place.

Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
…ween them

A TransferWindow whose group spans hosts is now registered with torch's NCCL
symmetric-memory backend (CUDA only). Processes on one host keep copying in
place; operations between hosts are staged. With puts=True, an operation
between hosts whose source and target are both packed regions of window
shards is a one-sided NCCL put from the source instead. Chunks adjacent on
both sides are coalesced into one put, and every process computes the same
runs, so each target waits for exactly one signal per put before the
closing barrier, which also frees the put's source for reuse.

Puts are opt-in because each one is a separate NCCL operation: on 2x8 H20
over RoCE they beat staging when each process puts to one peer (and by
1.6-1.9x for 2048 small parameters, thanks to coalescing) but are 1.5-1.8x
slower when each process fans out to all eight peers on the other host.

Ported from #9 onto the prepared-transfer structure.

Co-authored-by: iLeGend <824040212@qq.com>
Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
Issue all of a process's puts as one NCCL group. torch's put_signal is one
ncclPutSignal per call on the same communicator, and NCCL serialises
launches on a communicator whatever stream they come from, so ungrouped
puts to several peers ran one after another. On 2x8 H20 over RoCE, every
process putting 256 MiB spread over the eight peers on the other host took
35 ms ungrouped and 15.4 ms grouped (13.3 ms staged); with one peer each,
grouping costs nothing.

Tell which processes map each other's windows from NCCL rather than from
hostnames: hostnames still choose the NCCL backend, so a window on one host
is unchanged, but after rendezvous the peers NCCL has mapped decide which
operations are copied in place. Hosts sharing an NVLink domain then copy
in place instead of putting through the network; processes that disagree
on whom they map fail the window.

Co-authored-by: iLeGend <824040212@qq.com>
Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
Put from a process only when its operations between hosts all go to one
peer and carry at least 256 MiB or 64 parameters, the cases where puts
beat staging on two 8-GPU H20 hosts; stage everything else. Every
process resolves the rule from the whole batch, so they agree.

Co-authored-by: iLeGend <824040212@qq.com>
Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
TransferWindow(..., puts=True, pack_bytes=N) reserves N bytes after each
shard. Operations between domains that are not direct puts are packed per
pair of processes into that reserve, sent as one put and unpacked by the
receiver; pairs that do not fit are staged.

Co-authored-by: iLeGend <824040212@qq.com>
Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
…cheduled window options

puts='auto' now counts staged peers on other hosts too, so a process that also
fans out is not put from. schedule_transfers applies the TransferWindow checks
to window_puts and window_pack_bytes.

Co-authored-by: iLeGend <824040212@qq.com>
Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
…use changed window options

The agreement now covers the senders puts='auto' resolved and the reserve
layout, so ranks reading different thresholds refuse instead of hanging. A
window's puts and pack_bytes are checked collectively per batch, and a
prepared handle refuses to run after they change.

Co-authored-by: iLeGend <824040212@qq.com>
Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
Co-authored-by: iLeGend <824040212@qq.com>
Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>
NCCL leaves a send or receive undefined when one side's buffer is
registered with the communicator and the other's is not; between hosts
it hangs (seen with NCCL 2.29.7 and 2.32.6, rows to columns over two
hosts with puts=True). The local check from the window commit already
stages such regions; the shards of the window passed to the transfer
are now also staged in schedule_transfers, which every process can see,
so what it reports matches what runs.

Signed-off-by: Jin, Youzhi <youzhi.jin@intel.com>

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