Skip to content

Drop the unused NCCL process group from the distributed workers #219

Description

@clemsgrs

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions