Summary
The distributed workers build an NCCL process group that has zero live collectives. It can be
removed: read rank/world-size from the environment torchrun already exports, and drop
init_process_group entirely.
Surfaced while scoping distributed dense extraction (the new dense worker deliberately won't use
NCCL); the existing pooled/direct workers don't need it either.
Evidence
slide2vec/distributed/__init__.py:197 enable() calls
dist.init_process_group(backend="nccl", timeout=14 days, device_id=...), invoked from
pipeline_worker.py:32 and direct_embed_worker.py:37.
- Grep across live code (excluding
.ipynb_checkpoints): no all_gather, all_reduce,
broadcast, or reduce. All cross-rank coordination is via the filesystem (shard files / final
artifacts + the JSONL progress bridge).
- The only
dist.barrier() is in hf_login() (slide2vec/utils/config.py:176), reachable only
from cli.py:27 — the parent process, where is_enabled_and_multiple_gpus() is False. It
never executes. Workers authenticate via a different path (inference.py:105, plain
huggingface_hub.login, no barrier).
So the group exists purely so get_global_rank() / get_world_size() can call dist.get_rank() /
dist.get_world_size() — values torchrun already exports as RANK / WORLD_SIZE. Cost: NCCL init,
a comms buffer per rank, and a 14-day-timeout hang surface. Benefit: none.
Latent landmine (fix regardless)
If that barrier ever did run multi-rank with HF_TOKEN unset: non-main ranks hit
if token is None: return and leave, while rank 0 blocks on dist.barrier() alone → a 14-day hang.
Dead today (barrier only runs in the single-process parent); armed the moment anyone calls
hf_login() from a worker. Either remove the barrier or make it collective-safe.
Scope
- Replace
dist.get_rank() / dist.get_world_size() in slide2vec/distributed/__init__.py with
reads of the torchrun-exported env vars; drop init_process_group. Keep torch.cuda.set_device().
- Remove or guard the dead
dist.barrier() in hf_login().
- Verify the existing multi-GPU pooled paths (
pipeline_worker, direct_embed_worker) still behave
identically — they never used a collective, so this should be transparent.
References
slide2vec/distributed/__init__.py (enable, get_global_rank, get_world_size)
slide2vec/distributed/{pipeline_worker,direct_embed_worker}.py
slide2vec/utils/config.py:160 (hf_login, the dead barrier)
Summary
The distributed workers build an NCCL process group that has zero live collectives. It can be
removed: read rank/world-size from the environment torchrun already exports, and drop
init_process_groupentirely.Surfaced while scoping distributed dense extraction (the new dense worker deliberately won't use
NCCL); the existing pooled/direct workers don't need it either.
Evidence
slide2vec/distributed/__init__.py:197enable()callsdist.init_process_group(backend="nccl", timeout=14 days, device_id=...), invoked frompipeline_worker.py:32anddirect_embed_worker.py:37..ipynb_checkpoints): noall_gather,all_reduce,broadcast, orreduce. All cross-rank coordination is via the filesystem (shard files / finalartifacts + the JSONL progress bridge).
dist.barrier()is inhf_login()(slide2vec/utils/config.py:176), reachable onlyfrom
cli.py:27— the parent process, whereis_enabled_and_multiple_gpus()isFalse. Itnever executes. Workers authenticate via a different path (
inference.py:105, plainhuggingface_hub.login, no barrier).So the group exists purely so
get_global_rank()/get_world_size()can calldist.get_rank()/dist.get_world_size()— values torchrun already exports asRANK/WORLD_SIZE. Cost: NCCL init,a comms buffer per rank, and a 14-day-timeout hang surface. Benefit: none.
Latent landmine (fix regardless)
If that barrier ever did run multi-rank with
HF_TOKENunset: non-main ranks hitif token is None: returnand leave, while rank 0 blocks ondist.barrier()alone → a 14-day hang.Dead today (barrier only runs in the single-process parent); armed the moment anyone calls
hf_login()from a worker. Either remove the barrier or make it collective-safe.Scope
dist.get_rank()/dist.get_world_size()inslide2vec/distributed/__init__.pywithreads of the torchrun-exported env vars; drop
init_process_group. Keeptorch.cuda.set_device().dist.barrier()inhf_login().pipeline_worker,direct_embed_worker) still behaveidentically — they never used a collective, so this should be transparent.
References
slide2vec/distributed/__init__.py(enable,get_global_rank,get_world_size)slide2vec/distributed/{pipeline_worker,direct_embed_worker}.pyslide2vec/utils/config.py:160(hf_login, the dead barrier)