Repository navigation
[checkpoint] Put between hosts through a transfer window: puts, puts='auto' and packed reserves - #9149
Draft
jinyouzhi wants to merge 16 commits into
Draft
[checkpoint] Put between hosts through a transfer window: puts, puts='auto' and packed reserves#9149jinyouzhi wants to merge 16 commits into
jinyouzhi wants to merge 16 commits into
Conversation
_validate_aliases refused a batch whenever a target buffer overlapped a source buffer. A relay rank in stage two holds its band as a view of its own destination: it sends the band to its peers and receives the other bands around it, so no element is both read and written, but the buffers overlap and the batch was refused. Keep the whole-buffer check as the fast path. When it finds an overlap, check the regions this process's schedule reads and writes instead. A local copy whose source and target are the same memory at the same strides moves nothing: drop it and count its region as read, so another write into it is still refused. Regions are compared by the bytes they span, so strided regions that interleave are refused as before. Signed-off-by: 0z5a <dezhen.lu@student.uni-tuebingen.de>
The region check took a conjugate or negative view of a destination for the destination itself: same address, same strides, so the copy was dropped as in place and the batch returned without moving anything. Master refused that batch only because the view shares the destination's storage. The lazy bit is not safe across processes either, on master too. Point-to-point transport does not carry it. With gloo on CPU, a conjugate shard fails inside the send on its own process after the preflight has agreed, and the peer waits for it; a negative-view target is never written. Refuse both views in the preflight, on the process that holds one, so every process refuses before data moves. Region extents now come from address_range, as in _validate_buffers. schedule_transfers sees no buffers, so it still counts a copy dropped as in place as a local copy; its docstring now says so. Signed-off-by: 0z5a <dezhen.lu@student.uni-tuebingen.de>
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>
…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>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #9118 (which is stacked on #9094); only the last 7 commits belong to this PR. Part of RFC #9026.
What changes
TransferWindowcan now span hosts. Theputs=option chooses how a cross-host operation moves: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': each sender counts every cross-host peer it has, and only puts when the fan-out is small enough to beat staging (see the numbers below). The resolved senders are part of the plan fingerprint, so every rank agrees on them.puts/reserve on a reused plan is refused.Puts need
torch.distributed._symmetric_memory.put_signal(NCCL backend). With an older torch,puts=Trueraises a clear error and'auto'falls back to staging. Single-host windows and XPU are unchanged.Performance (2×8 H20, RoCE, before the rebase)
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.Tests (after the rebase onto #9118 95e799d)
tests/unit/checkpoint/test_affine_transfer_executor.py+ planner testsWIP: tests to rerun or still to run
'auto'on small fan-out sizes.test_hosts_that_map_each_other_copy_in_placeis mocked.Future work (limited by torch / NCCL or the environment)
ctx=0andsigIdx=0input_signal/wait_signal.This PR was prepared with AI assistance (GitHub Copilot CLI); all changes were reviewed and tested by the author.