[Feat] Route FSDP weight all-gather through copy-engine symmetric memory - #65
Merged
Merged
Conversation
jiahy0825
reviewed
Aug 31, 2026
…hey run on hosts without an initialized NVLink fabric
…keep uneven Shard(0) gathers rank-identical
wtr0504
force-pushed
the
feat/ce_ag_reuse_torch
branch
from
September 7, 2026 13:41
606d1ab to
1070f5e
Compare
…s memory ``symm_all_gather`` named the precondition -- the input must live in a symmetric window -- rather than the mechanism, and symmetric memory does not imply the copy engine: PyTorch's own symm_mem all-gathers run on SM kernels. Not doing that is this op's entire reason to exist, and it is what the reorder pass and the cost model key off, so the name should say it. Rename the op to ``magi::ce_all_gather`` / ``_coalesced``, matching the vocabulary already in use at ``transport="copy_engine"`` and ``node_meta.CE_BOUND``. The buffer, binding and registry keep the ``symm`` name: those really are about the memory model, and the split now marks the boundary instead of blurring it. The uneven-transport helper compared sorted results against a literal whose order encoded the old label's alphabetical position, so its expectation moves with the rename. Co-authored-by: Cursor <cursoragent@cursor.com>
…layable kernels at zero
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.

🗂️ PR Category
📝 Description
Add a copy-engine (CE) transport for SimpleFSDP weight all-gather, as an alternative to NCCL ring kernels.
Today
enable_fullgraph_overlaphides weight gathers under upstream compute, but those gathers still occupy SMs and contend with the compute that is supposed to hide them. Withfsdp_config.transport="copy_engine":torch.distributed._symmetric_memorywindows, driven from the captured FX graph between lowering and bucketing, using the live tensors Dynamo handed the backend. Windows are pooled per(process group, dtype)and capped at 4 GiB, so dense FSDP and MoE edp meshes never share a rendezvous. The publish barrier is paid once at bind, never per step.Shard(0)DTensor, contiguous, on CUDA, whose gather input is exactlyto_local(placeholder|get_attr). An unevenShard(0)is refused — the gather copies one fixed-size slab per peer, so a rank whose peers own fewer rows would read past the end of theirs. The decision is agreed across ranks before anything moves: a gather retargeted on only some ranks would never complete.magi::ce_all_gather/magi::ce_all_gather_coalesced. Bucketing splits on the bind flag so a bucket is all-bound or all-unbound; cast/pad gathers and anything left unbound stay on NCCL, so mixed graphs are legal.cudaMemcpyBatchAsync, one submission per bucket) into a fresh dest — zero SM occupancy, no per-step cross-rank barrier. Weights are static in inference, so the NCCL barrier is wasted work.FallbackKernel, so the pass now treatsmagi::ce_all_gather*as collectives (_issues_transfer) instead of counting them as compute.wait(launch()). Timing the launch alone measures CPU issue (~3 µs) and misses the side-stream copies, which undersizes the overlap window by an order of magnitude.Default remains
transport="nccl". CE requires NVLink within the FSDP mesh dim and static weights (inference).Config
fsdp_config.transport"nccl""nccl": SM ring kernels."copy_engine": symmetric-memory peer copies.fsdp_config.symm_min_shard_mib00binds every eligible weight.