Skip to content

[c10d] Fix split_group's backend filter for parents with a bare backend string - #192111

Closed
tushar00jain wants to merge 4 commits into
gh/tushar00jain/8/basefrom
gh/tushar00jain/8/head
Closed

tushar00jain wants to merge 4 commits into
gh/tushar00jain/8/basefrom
gh/tushar00jain/8/head

Conversation

@tushar00jain

@tushar00jain tushar00jain commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Summary:
split_group's backend= filter validated the request against a re-expansion of
the parent's backend string through Backend.default_device_backend_map, via
_parse_backend_string. That is not the expansion the parent process group was
built from. _new_process_group_helper iterates BackendConfig(backend), which
expands through Backend.backend_capability -- "which devices can this backend
run on" -- while default_device_backend_map answers "which devices pick this
backend by default". The two agree for every device-qualified parent string, and
disagree for a bare one:

backend string   BackendConfig            default_device_backend_map
"gloo"           cpu, cuda                cpu
"fake"           cpu, cuda, hpu, xpu      hpu

so on a stock init_process_group("gloo", device_id=cuda:0) world, which really
does run gloo on cuda:

split_group(backend="cuda:gloo")
ValueError: Requested backend for device 'cuda' is not present in the parent
process group (parent backends: {'cpu': 'gloo'})

The failure is a hard ValueError at group-construction time on a filter the
parent can actually satisfy, so the caller has no way to build the child it
asked for. Over a bare "fake" parent every filter form fails -- "cuda:fake",
"cpu:fake" and "cpu:fake,cuda:fake" with the ValueError above, bare "fake" with
"RuntimeError: splitGroup deviceTypes filter must include the parent process
group's default backend device type" -- leaving backend=None as the only
usable call.

This is not specific to fake process groups -- a bare "fake" world is built
exactly like a bare "gloo" world, FakeProcessGroup really does support
splitting (supportsSplitting() is true, split() is implemented, and calling
pg.split_group(device_types=...) directly past the Python gate works for
['cpu'], ['cpu','cuda'] and the full device list), and test_fake_pg.py already
splits one. CI never caught it because every existing test of the filter
(test_c10d_nccl.py, test_device_mesh.py) uses a device-qualified parent, where
the two expansions coincide.

How it was found: out of the Megatron --fake-process-group regression triage
during the nccl2 migration. That flag broke on our own wiring commit, and one of
the three defects behind it was "a fake parent is unfilterable by split_group",
which forced the Megatron side to pass backend=None. Filed that way, the entry
read as a fake-PG limitation. Triage of the claim showed the diagnosis was too
narrow: the same rejection reproduces with no fake PG anywhere, on a plain stock
init_process_group("gloo", device_id=cuda:0) world asked for backend="cuda:gloo"
-- so it is a stock c10d bug, found downstream and root-caused upstream, and the
register entry was retitled accordingly. Nothing here needs nccl2: the migration
only raised exposure, because it routes CPU coordination groups through
split_group.

It does not belong downstream. The only workarounds available to a caller are to
pass backend=None -- which drops the filter entirely, so the child carries every
device the parent has -- or to always build device-qualified worlds so the two
expansion tables happen to agree. The first is what Megatron had to do and it
silently gives up a real capability; the second is impossible for a fake world
(fake is registered on four devices and is no device's default, so there is no
qualified spelling that survives the round trip) and is not something a library
can impose on the application that called init_process_group. The wrong answer
is produced by two of torch's own tables disagreeing about what a bare backend
name means; only torch can reconcile them.

Derive the parent's per-device backends from the BackendConfig the group was
actually built from -- already constructed a few lines above, so no new state
and no new API -- intersected with parent_pg._device_types, which is the same
set the C++ check in ProcessGroup::splitGroup validates against. That is the
point of the shape: after this, the Python gate and the C++ gate are answering
the same question about the same parent, instead of one guessing from a global
default map. A device-qualified request still goes through _parse_backend_string
unchanged, deliberately -- that path was never wrong, and narrowing the change
keeps the behaviour of every real production world identical. A bare request now
selects every parent device running that backend, which is what a user asking
for "gloo" over a gloo world means, and raises a clear ValueError naming the
parent's real backends if it matches nothing, instead of the misleading
per-device message. For a device-qualified parent the new parent map is
byte-identical to the old one, and a bare request over such a parent resolves
the same way it did before ("nccl" -> {cuda:nccl}, "gloo" -> {cpu:gloo}), so the
only behaviour that changes is the bare-parent case that was broken.

The same function had a second, independent defect on the other side of the
split, found while triaging the first. After a successful split it looked the
child's backend up unconditionally on torch.accelerator.current_accelerator(),
so any filter that legitimately drops the accelerator leg died afterwards with

RuntimeError: No backend type associated with device type cuda

which reproduces on a stock bare-"gloo" world with backend="cpu:gloo" and has
nothing to do with fake either. The child is already built and registered at
that point, so the caller gets an exception for a split that succeeded. Prefer
the accelerator only when the child actually has it and fall back to cpu
otherwise, keeping the pre-existing RuntimeError for a child that has neither.
split_backend_class is only consumed by the torchcomms _world.comms.append
branch, so this narrows a hard failure to the lookup the caller meant and leaves
the non-torchcomms path unchanged.

Three things are deliberately left alone. ProcessGroup::splitGroup's "the filter
must keep the default backend's device" check picks that device with a find_if
over the unordered_map deviceTypeToBackendType_, so for a parent whose devices
all share one BackendType (bare gloo on cpu+cuda, fake on four devices) the
"default backend device" depends on hash bucket order rather than
bound_device_id; cuda:gloo and cuda:fake filters therefore still fail there.
That is a real wart but needs a C++ change and its own repro; preferring
bound_device_id's device type among the devices sharing backendType_ is the
likely fix. _parse_backend_string's bare-name branch is now unreachable from
split_group but is left in place: it is a generic helper with its own callers'
semantics, and pruning it is not this change's business. And
_world.pg_backend_config for the child is still str(BackendConfig(backend)), so
a bare filter that matches only some parent devices records a wider config than
the child really has -- cosmetic.

Test Plan:
test/distributed/test_fake_pg.py gains
TestFakePG.test_split_group_backend_filter, next to the existing
test_split_group* tests and in the same skipIfHpu / HAS_ACCELERATOR / FakeStore
conventions. It asserts that bare "fake" keeps every parent device, that
"cpu:fake" and "cpu:fake,:fake" keep exactly the named devices, and that
"mps:fake", "cpu:gloo" and bare "gloo" are still rejected:

python test/distributed/test_fake_pg.py -k split_group -v
test_split_group_backend_filter ... ok
test_split_group_consistent_naming_after_partial_split_rank_0..3 ... ok
test_split_group_non_member ... ok
test_split_group_rank_0..3 ... ok
test_split_group_store_not_retained ... ok
Ran 11 tests in 0.903s
OK

Against the old parent expansion the new test fails with the RuntimeError
quoted above:

full = dist.split_group(split_ranks=[[0, 1]], backend="fake")
RuntimeError: splitGroup deviceTypes filter must include the parent process
group's default backend device type.
FAILED (errors=1)

Recursive splits of a filtered child work too (cpu:fake,cuda:fake -> cpu:fake ->
all_reduce), since the child's recorded backend string round-trips through the
same expansion. The post-fix filter matrix, measured directly:

fake parent:  cpu:fake -> OK   fake -> OK   cpu:fake,cuda:fake -> OK
              None -> OK       cuda:fake -> RuntimeError (C++ wart above)
bare-gloo:    cpu:gloo -> OK   gloo -> OK (cpu+cuda)   None -> OK
              cuda:gloo -> RuntimeError (C++ wart above)
cpu:gloo,cuda:nccl (device_id=cuda):
              cuda:nccl -> OK  nccl -> OK   cpu:gloo / gloo / cuda:gloo
              rejected exactly as before

Whole file and the neighbouring split-filter suites:

python test/distributed/test_fake_pg.py
  Ran 73 tests in 1.357s ... OK
python test/distributed/test_c10d_collectives.py -k split_group -v
  Ran 8 tests in 39.653s ... OK (skipped=2)
python test/distributed/test_device_mesh.py
  Ran 76 tests in 297.845s ... OK (skipped=5)

test_c10d_nccl.py's ProcessGroupNCCLGroupTest -k split ran 7 tests; the six
split/filter tests pass, and the seventh,
test_comm_split_world_pg_created_after_another_nccl_pg, failed at the time for
an unrelated reason -- the NCCL split OOB fixed by another commit in this stack,
which uses no backend= filter -- and is green in the post-rebuild sweep of the
whole stack (Ran 284 tests, OK, skipped=15).

Authored with the assistance of an AI coding agent.

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/192111

Note: Links to docs will display an error until the docs builds have been completed.

⏳ No Failures, 2 Pending

As of commit ec54df0 with merge base f3849a4 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

[ghstack-poisoned]

@d4l3k d4l3k left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Re-approving due to switching to ghstack from sl

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Starting merge as part of PR stack under #192113

[ghstack-poisoned]
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Starting merge as part of PR stack under #192113

[ghstack-poisoned]
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Starting merge as part of PR stack under #192113

pytorchmergebot pushed a commit that referenced this pull request Aug 5, 2026
…cator trace hook (#192112)

Summary:
cacheAllocatorRegisterHook ran NCCLComm::registerSegment(window=true) for any
segment allocated into a pool that had been registered with symm=True, and on
NCCL 2.29.7 ncclCommWindowRegister is unconditionally collective:
src/dev_runtime.cc enqueues a group task that runs
bootstrapIntraNodeAllGather to exchange memory handles,
bootstrapIntraNodeBarrier to make sure everyone imported them,
bootstrapIntraNodeBroadcast for the multicast handle, and a final
bootstrapBarrier for the symmetric window. Every rank of the communicator must
call it, the same number of times, in the same order, and none of those
bootstrap sockets has a timeout.

The hook is the wrong place for that. It is called from record_trace, which
CUDACachingAllocator invokes from alloc_block and release_block with the device
allocator's recursive_mutex held, immediately under the comment "Callbacks
should not include any Pytorch call". So the NCCL rendezvous blocks every other
thread in the process that wants to allocate. It also runs on whatever thread
happens to allocate or free -- the main thread, an autograd worker, or for
SEGMENT_FREE the GC pass that drops the last MemPool reference. And
SEGMENT_ALLOC / SEGMENT_FREE are purely local allocator decisions: a
rank-specific tensor, or fragmentation-driven release_available_cached_blocks
firing out of the OOM retry on whichever rank happens to be tight, is enough to
make one rank call and the others not.

Reproduced as a hard hang on stock nccl, 2 ranks, no torchcomms in the process:
all ranks register a symm pool, rank 0 alone allocates one more tensor into it,
and rank 0's next plain torch.zeros() never returns. py-spy --native:

    accept (libc.so.6)
    ncclSocketAccept -> socketAccept (bootstrap.cc:1057)
    bootstrapIntraNodeAllGather (bootstrap.cc:1226)
    symMemoryMapLsaTeam -> symMemoryObtain -> ncclDevrWindowRegisterInGroup
    pncclCommWindowRegister (dev_runtime.cc:1102)
    c10d::NCCLComm::registerSegment
    c10d::cacheAllocatorRegisterHook
    ...::record_trace -> alloc_block -> NativeCachingAllocator::malloc
    at::detail::empty_cuda ... THPVariable_zeros

There is no recovery from that state. ProcessGroupNCCL::abortComms() takes
ncclCommMemPoolMapMutex before aborting the comms, and the parked hook is
holding that mutex for the whole duration of the NCCL call, so the watchdog
blocks behind it. Re-run with a 20 s PG timeout and a 130 s budget, both ranks
still had to be killed.

The defect is in stock ProcessGroupNCCL, not in the nccl2 backend: everything
above was measured with backend="nccl" and no torchcomms loaded. nccl2's
register half was already correct -- registerAddressLocked() is a plain
ncclCommRegister with symmetric windows deferred to the collective
ensureSegmentWindow() -- but nccl2 shares the two secondary hazards below, so
it is hardened the same way here.

How it was found: by inspection while implementing nccl2's register_mem_pool
(earlier in this stack). Writing down *why* nccl2 defers window
registration out of the allocator hook forced the question of whether stock's
version of the same hook was safe, and reading NCCL 2.29.7's dev_runtime.cc
answered it. No downstream run failed: Megatron's nccl_allocator always
deregisters its pool collectively before allocating into it again, which is why
the tp2_dp2_nvls bit-exact cell was clean on both arms. The purpose-built 2-rank
harness is what turned the analysis into the reproducible hang above. Our own
NVLS work raised the reachability -- more segments carry windows -- but did not
create the bug, which predates the migration on both sides.

Working around this downstream is not possible in general. The hang happens
inside an ordinary torch.zeros() with the allocator mutex held, so the only
downstream mitigation is to guarantee that no rank ever allocates into (or frees
from) a symm-registered pool without every peer doing the same, in the same
order -- unachievable when the divergence source is an OOM-driven
release_available_cached_blocks on whichever rank happens to be tight. The
alternative mitigation is "never call register_mem_pool(symm=True)", i.e. give
up NVLS. And once wedged there is no escape hatch at any layer: NCCL's bootstrap
sockets have no timeout, and c10d's own watchdog blocks behind the hook's mutex.
The invariant has to be enforced where the hook is installed.

The rule this change enforces is that the trace hook may only make NCCL calls
that are local to this rank. cacheAllocatorRegisterHook now always registers
with window=false and TORCH_WARN_ONCEs when it sees a symm pool, pointing at
deregister_mem_pool() + register_mem_pool() as the collective way to get new
segments windowed. Symmetric windows are created exclusively by
registerMemPool(), which the user calls collectively -- which is what the nccl2
backend had already been doing during the migration, its registerAddressLocked()
being a plain ncclCommRegister with windows deferred to ensureSegmentWindow().
The rule is written down as NOTE [NCCL calls from the caching allocator trace
hooks] next to the hooks, because the next person to add a call here needs the
reason, not just the current shape.

This is a deliberate behaviour change: segments allocated into a symm pool
*after* register_mem_pool(symm=True) are no longer auto-upgraded to symmetric
windows. They stay registered as plain NCCL user buffers, so collectives over
them take the non-symmetric algorithm -- the same decision on every rank, so no
mismatch. That auto-upgrade is exactly what hangs, and the hook has no way to
know whether the peers are making the same allocation. The cheaper-looking
alternative -- keep the upgrade but only when the allocation "looks symmetric"
-- does not exist: the hook sees one rank's allocator, and any predicate it
could evaluate is exactly the local decision that diverges. Losing NVLS on late
segments is a performance regression for a workload that grows its pool after
registering it; hanging is not a performance regression, so the trade is not
close. Callers that want the windows back have a supported, collective way to
get them, and the warning names it.

Two smaller hazards on the same path are fixed with it. ncclCommMemPoolMap is
keyed by shared_ptr<NCCLComm> and hashed by pointer, so its iteration order is
heap-address order and differs between ranks; with two communicators sharing a
symm pool, rank A could issue windowRegister(commX) then windowRegister(commY)
while rank B did the reverse -- two blocking rendezvous in opposite orders, a
deadlock even under perfectly symmetric allocation. The new
commsInterestedInSegment() returns the interested comms sorted by
NCCLComm::getUniqueHash() -- the hex of the ncclUniqueId plus ":<splitCounter>"
for split children, the one key every rank agrees on; device index or pointer
order would not do. The map mutex is still held across the calls on purpose:
that is what keeps abortComms() from retiring a comm underneath the hook. The
nccl2 side has the same shape -- registeredComms_ is a
std::set<ProcessGroupNCCL*>, i.e. pointer order -- and its new commsForDevice()
sorts by getCommName().

NCCLUtils' deregisterSegment(void* ptr) loses its `window` parameter and uses
the flag recorded at registration time instead. That is required by the above: a
symm pool can now hold both windowed segments (from registerMemPool) and locally
registered ones (from the hook), and handing a ncclReg* to
ncclCommWindowDeregister, or the reverse, is a handle type confusion. Deriving
the API from the registration record rather than from the caller's view of the
pool makes that unrepresentable, which is why the parameter is removed rather
than merely fixed at the two call sites.

One correction to the record while here. ncclCommWindowDeregister is *not*
collective on upstream NCCL 2.29.7: symWindowDestroy -> symMemoryDropRef +
ncclCommDeregister contains no bootstrap call, and the divergent-free case was
verified not to hang here. It is collective under NCCLX with rmaAlgo != orig,
where it goes through ctran::ctranWinFree -> CtranWin::free and takes a
windowBarrier. So the deregister half is build-dependent rather than
unconditionally broken. The teardown is kept regardless -- dropping it would
leave a stale window over an address range the allocator is about to hand out
again, so a later allocation reusing that range would silently resolve to the
stale window, which is memory corruption rather than a hang, and strictly worse
-- but both the stock hook and nccl2's deregister_address(addr,
from_allocator_hook=true) now warn once that this is the uncollective path. In
other words the risky half is kept knowingly, because the safe-looking
alternative is unsafe.

Test Plan:
A 2-rank harness on the four interesting shapes, on GPUs 2,3, each cell under a
200 s cap:

    CUDA_VISIBLE_DEVICES=2,3 timeout 200 python \
      triage/bug6_alloc_hook_collective.py <mode>

  - div_alloc (divergent allocation into a symm pool) -- the direct regression
    check -- went from a hang the watchdog could not break (exitcodes [1, 1]) to
    both ranks printing DONE (exitcodes [0, 0])
  - sym_alloc (symmetric allocation):          exitcodes [0, 0], stayed green
  - div_free (divergent free):                 exitcodes [0, 0], stayed green
  - div_alloc_local (divergence, symm=False):  exitcodes [0, 0], stayed green

The existing registration tests, including the one most likely to notice the
behaviour change above:

    python -m pytest test/distributed/test_c10d_nccl.py \
      -k "window_registration or user_buffer_registration" -v
    NcclUserBufferRegistrationTest::test_nccl_user_buffer_registration PASSED
    NcclUserBufferRegistrationTest::test_nccl_window_registration      PASSED
    2 passed, 282 deselected

    python -m pytest test/distributed/test_c10d_nccl2.py -k register_mem_pool -v
    3 passed, 17 deselected

No CI regression test is added: the pre-fix failure mode is a hang, so such a
test can only fail by timing out.

Two things this does not establish. The NCCLX collective-deregister path is
inferred from source, not measured -- everything ran against upstream NCCL
2.29.7. And all runs were single-node, 2 or 4 ranks, so the getUniqueHash()
ordering fix and the multi-communicator iteration-order deadlock it closes
remain argued rather than reproduced.

Authored with the assistance of an AI coding agent.
Pull Request resolved: #192112
Approved by: https://github.com/d4l3k
ghstack dependencies: #192104, #192105, #192106, #192107, #192108, #192109, #192110, #192111
pytorchmergebot pushed a commit that referenced this pull request Aug 5, 2026
…ress (#192113)

Summary:
_create_c10d_store() began with

    if _torchelastic_use_agent_store():
        return TCPStore(hostname, port, world_size, is_master=False, timeout)

so under torchrun every rank got a client-only TCPStore for whatever host and
port it had been handed. torchrun's elastic agent exports
TORCHELASTIC_USE_AGENT_STORE=True into every worker it spawns, alongside
MASTER_ADDR and MASTER_PORT, and the flag promises exactly one thing: the agent
hosts a store at that endpoint. _create_c10d_store applied it to every
endpoint. So any caller building a private store on a port of its own choosing
-- a library making a stateless group, or a script calling
init_process_group(init_method="tcp://host:port") -- ended up with a client on
every rank, no rank ever started a server, and every rank sat in connect-retry
against nothing until the store timeout expired: thirty minutes on gloo, ten on
nccl. From the outside that is an unexplained hang at startup with no error and
nothing in the logs, on a code path that works perfectly the moment the same
program is run without torchrun.

Torch already knew the address had to match. TCPStore's C++ constructor only
forgives a failed server bind when useAgentStore && masterPort == opts.port --
the same guard, one layer down. The Python layer was contradicting the C++
layer: rendezvous.py behaved as though the agent serves every address, while
TCPStore.cpp assumes it serves only its own.

Found by root-causing a hang rather than by reading. vLLM's
stateless_init_torch_distributed_process_group hangs when called from inside a
torchrun-managed process, on both the gloo and the nccl arms and identically on
stock nccl and on nccl2. Isolating it ruled out everything torchrun-shaped in
turn -- RANK and WORLD_SIZE, MASTER_PORT collisions, store key collisions --
and left one variable: popping TORCHELASTIC_USE_AGENT_STORE out of the
environment makes the identical run succeed. That pointed at
torch.distributed.rendezvous, which is where vLLM was getting its store, and
from there at this branch.

This is a stock defect. rendezvous.py is stock torch, the elastic agent that
sets the variable is stock torch, and the hang reproduces on a stock
init_process_group(init_method="tcp://...") under stock torchrun with nothing
from the migration loaded at all. No part of it requires nccl2.

It is also only fixable here, which is the whole reason it belongs in c10d
rather than downstream. vLLM has already fixed itself, independently, by
building the TCPStore directly instead of going through rendezvous -- and that
bypass is byte-for-byte the branch _create_c10d_store now takes for a private
address, so on a torch carrying this commit the two are equivalent and the
workaround is functionally redundant. It was nonetheless deliberately left in
place, because vLLM supports torch releases that will not carry this fix for a
long time and on a fixed torch it is a no-op that costs nothing. What a
downstream patch cannot close is the broader exposure: an API server started
under torchrun whose workers call
init_distributed_environment(distributed_init_method="tcp://...") reaches this
code through init_process_group, which builds its store via
_create_c10d_store, and no amount of patching a stateless-group helper reaches
that path. Every framework offering a "connect to this address" knob has the
same shape, so the guard has to live in torch.

The fix is a predicate, _agent_store_serves(hostname, port), that honors
TORCHELASTIC_USE_AGENT_STORE only when the hostname and port it is asked about
are the agent's own MASTER_ADDR and MASTER_PORT. _create_c10d_store gates on
that instead of on the raw env read, and the docstring is corrected to describe
what the code now does. _torchelastic_use_agent_store() itself stays, since it
is the raw env read and is referenced elsewhere in the ecosystem. This is
TCPStore.cpp's existing guard extended to the hostname, which the Python layer
has in hand and the C++ layer does not.

Comparing the hostname as a string is safe in both directions. Everything that
legitimately wants the agent's store arrives through env://, and
_env_rendezvous_handler reads MASTER_ADDR verbatim out of the same environment
the agent wrote it into, so for that path the comparison is exact by
construction. A caller who instead hand-writes tcp://<resolved-ip>:<MASTER_PORT>
and so trips the string mismatch does not get the old broken behaviour but the
correct one: rank 0 takes the is_master=True branch, its bind fails because the
agent already holds that port, and TCPStore.cpp's port-only guard forgives the
failure and turns it into a client -- which is precisely what the old code did
directly. The degradation is into a slower path, not into a broken one.

Test Plan:
Two regression tests in test_store.py::RendezvousTCPTest, next to the other
dist.rendezvous("tcp://...") tests and in the same create_tcp_url() /
common.find_free_port() idiom. They are a matched pair on purpose, so that the
fix cannot quietly degrade into deleting the feature:
test_agent_store_ignored_for_other_address sets the agent environment but
points it at a different port and requires the private store to come up and
round-trip a key, while test_agent_store_honored_for_master_address sets it
matching, with nothing listening, and requires a DistNetworkError rather than
some rank silently starting a server.

    python test/distributed/test_store.py -v -k agent_store
    test_agent_store (LibUvTCPStoreTest.test_agent_store) ... ok
    test_agent_store_honored_for_master_address (RendezvousTCPTest...) ... ok
    test_agent_store_ignored_for_other_address (RendezvousTCPTest...) ... ok
    test_agent_store (TCPStoreTest.test_agent_store) ... ok
    Ran 4 tests in 4.175s
    OK

Pre-fix the same selection is 199.719 s and FAILED (errors=1), with
test_agent_store_ignored_for_other_address raising DistNetworkError: The client
socket has timed out after 10000ms while trying to connect to (localhost,
37515). Neither new test is decorated with @retry_on_connect_failures, and that
is deliberate: that helper's default connect_errors=(ADDRESS_IN_USE) is missing
its trailing comma, so it is a plain string rather than a tuple, the membership
test iterates it character by character, and consequently almost any
RuntimeError matches and is retried ten times, each attempt paying its full
timeout. That is what turned the genuine pre-fix failure here into a roughly
190-second hang with the real error buried behind "Failing after 10 retries".
It is a pre-existing wart in common_utils.py whose blast radius covers every
test currently using the decorator, so it is left untouched here and filed
separately.

End-to-end under real torchrun, driven by triage/bug14_private_store_torchrun.py
(stock torch, no vLLM), which can monkeypatch the predicate back to its legacy
form with --legacy so both behaviours are observable on one binary. Two modes:
rendezvous (what vLLM's stateless helper did) and init_pg
(init_process_group(init_method="tcp://..."), the path vLLM cannot bypass):

    torchrun --nproc_per_node=2 --master_port=29502 \
      triage/bug14_private_store_torchrun.py <mode> --port 29783 \
      --store-timeout 15 [--legacy]
    rendezvous --legacy : [rank1] RAISED after 26.1s: DistNetworkError
    rendezvous (fixed)  : [rank0] OK in 0.19s / [rank1] OK in 0.01s,
                          allreduce -> 2.0
    init_pg    --legacy : [rank1] RAISED after 20.8s: DistNetworkError
    init_pg    (fixed)  : [rank0] OK in 0.05s / [rank1] OK in 0.04s,
                          allreduce -> 2.0

With stock timeouts rather than the repro's fifteen seconds the legacy arms
never finish at all. A four-rank env:// run confirms the genuine agent-store
path is untouched: _agent_store_serves reports True on every rank and the
allreduce returns 4.0.

Verified on 4x H100, CUDA 13.0, NCCL 2.29.7, against a freshly rebuilt HEAD:
the pre-existing install predated the commits already landed in this stack, so
unmodified HEAD was rebuilt first to make the before-numbers honest
measurements rather than comparisons against a stale binary. 879 tests across
six suites with zero failures, with only the skips those suites already had:

    test_c10d_nccl.py    Ran 285 tests in 1659.524s  OK (skipped=15)
    test_c10d_gloo.py    Ran 289 tests in 1089.249s  OK (skipped=4)
    test_c10d_nccl2.py   Ran 20 tests in 102.125s    OK
    test_c10d_common.py  Ran 72 tests in 117.529s    OK
    test_store.py        Ran 140 tests in 23.000s    OK (skipped=12)
    test_fake_pg.py      Ran 73 tests in 1.543s      OK

Authored with the assistance of an AI coding agent.
Pull Request resolved: #192113
Approved by: https://github.com/d4l3k
ghstack dependencies: #192104, #192105, #192106, #192107, #192108, #192109, #192110, #192111, #192112
@github-actions
github-actions Bot deleted the gh/tushar00jain/8/head branch October 31, 2026 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/torchtitan Run TorchTitan integration tests Merged release notes: distributed (c10d) release notes category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants