Back to Blog
Oct 2, 2024
•By Swasthik Shetty•commit: 3f9011d

Building Ring All-Reduce over TCP Sockets from First Principles

Decentralized distributed gradient aggregation without MPI or InfiniBand dependencies.

Diagnostic Challenge

TCP socket buffering (Nagle algorithm) was batching tiny chunk packets, introducing 40ms transmission latency spikes.

Architectural Discovery

Setting TCP_NODELAY immediately restored line-rate ring transmission throughput.

Building Ring All-Reduce over TCP Sockets from First Principles

2024-10-02 • By Swasthik Shetty •commit: 3f9011d
What Broke

TCP socket buffering (Nagle algorithm) was batching tiny chunk packets, introducing 40ms transmission latency spikes.

What Was Learned

Setting TCP_NODELAY immediately restored line-rate ring transmission throughput.

Many distributed ML frameworks assume you have an InfiniBand fabric with RoCE and complex NCCL drivers. We wanted Dark Forest to support distributed training over ordinary Gigabit and 10GbE network switches using pure TCP sockets.

The Ring Topology

We split gradient tensors into $N$ equal chunks across $N$ ring workers:

  1. Scatter-Reduce: Workers transmit partial sums in a closed circle.
  2. All-Gather: Workers transmit finalized sums until all nodes hold identical weights.