6.3.4 · HinglishInterconnects, Buses & SoC

NVLink and GPU interconnects

3,127 words14 min readRead in English

6.3.4 · Hardware › Interconnects, Buses & SoC

PCIe ka multi-GPU ke liye fundamental problem

KYA HAI: PCIe devices ko CPU ke PCIe controller se guzarte ek hierarchical tree ke through connect karta hai. Har GPU-to-GPU transfer yeh path leti hai: GPU1 → PCIe → CPU root complex → PCIe → GPU2.

YEH KYUN MATTER KARTA HAI:

  • Latency: Multiple hops microseconds add karte hain
  • Bandwidth: PCIe Gen3 x16 = 15.75 GB/s, Gen4 x16 = 31.5 GB/s
  • CPU overhead: CPU ke PCIe lanes ek shared resource hain
  • Scaling: 8 GPUs sab ek saath gradients synchronize karne ki koshish karte hain to traffic jam ho jaata hai

Math: Agar tumhare paas 8× V100 GPUs (32GB each) hain jo distributed training kar rahe hain:

  • Model size: 1.5 GB weights
  • Per-iteration all-reduce: har GPU ko ~1.5 GB send/receive karna hoga 7 doosron se
  • PCIe Gen3: 1.5 GB ÷ 15.75 GB/s ≈ 95 ms per transfer
  • 7 peers ke saath: ~665 ms sirf communication ke liye (vs. ~300 ms compute time)

High speed par differential signaling kyun?

Electrical signaling ke first principles se shuru karte hain:

Single-ended signaling: Ground ke relative voltage

  • Noise signal aur ground ko alag-alag affect karta hai → measurement corrupt ho jaata hai
  • Switching currents se ground bounce common-mode noise create karta hai
  • Multi-GHz frequencies par, ground inductance = disaster

Differential signaling: Signal ko do wires ke beech voltage difference ke roop mein transmit karo

YEH KYUN KAAM KARTA HAI:

  1. Noise dono wires par equally couple hota hai (common-mode)
  2. Receiver subtract karta hai: (noise cancel ho jaata hai!)
  3. Chhote voltage swings use kar sakte hain → kam power, zyada speed

Physical parameters se bandwidth calculation

Har NVLink multiple differential pairs se bana hota hai jinhein lanes kehte hain. Pehle per-lane payload rate derive karte hain, phir scale up karte hain.

Given (NVLink 1.0, Pascal era):

  • 8 differential pairs per link direction (8 lanes)
  • 20 GT/s (gigatransfers/second) per lane signaling rate
  • 8b/10b encoding (10 transmitted bits mein 8 data bits)

Derivation:

NVLink 2.0 / 3.0 (Volta / Ampere era) signaling rate ko 25 GT/s tak raise karta hai:

8b/10b encoding kyun? DC balance aur clock recovery ke liye zaroori hai:

  • Lambi strings of 1s ya 0s nahi bhej sakte (edges nahi → clock drift)
  • 8 data bits ko 10-bit symbols mein encode karo guaranteed transitions ke saath
  • Cost: 20% overhead, lekin reliable high-speed serial ke liye zaroori

Bidirectional (full duplex) NVLink 2.0/3.0 ke liye: 20 GB/s har direction mein simultaneously 40 GB/s total per link

NVLink 2.0 ke liye, har GPU mein 6 NVLink connections hote hain, isliye:

PCIe Gen3 x16 = 16 GB/s se compare karo → 15× improvement!

NVLink sirf fast wires nahi hai — yeh ek sophisticated protocol stack hai:

Physical layer (PHY)

  • SerDes: Serializer/deserializer parallel data ko serial stream mein aur serial se parallel mein convert karta hai
  • Clock recovery: Phase-locked loop (PLL) data transitions se clock extract karta hai
  • Equalization: Pre-emphasis aur decision feedback equalization (DFE) cable losses ko compensate karte hain

Equalization kyun? 25 GHz par, PCB traces low-pass filters ki tarah act karte hain: jahan loss coefficient hai, length hai. High frequencies zyada attenuate hoti hain → inter-symbol interference.

Pre-emphasis: transmitter par high frequencies boost karo

  • Framing: Data ko flits (flow control units) mein packetize karta hai
  • CRC: Error detection ke liye har flit par 16-bit cyclic redundancy check
  • Retry: Agar CRC fail ho to automatic retransmission
  • Flow control: Credit-based system receiver overflow prevent karta hai

Credit-based flow control ka derivation:

Maano = bandwidth-delay product = "in flight" data ki matra

NVLink ke liye: 20 GB/s × 500 ns (GPU-to-GPU) = 10 KB

Receiver ka buffer ≥ hona chahiye link ko saturated rakhne ke liye. Sender credits track karta hai:

  • Initial credits = buffer size
  • Flit bhejna → credit decrement karo
  • Ack receive karna → credit increment karo
  • Agar credits = 0 → stall (ack ka wait karo)

Transaction layer

  • Load/store semantics: Remote direct memory access (RDMA)
  • Atomic operations: GPUs ke across compare-and-swap, fetch-and-add
  • Coherency protocol: Memory consistency ensure karta hai (home-agent snooping)

Coherency kyun matter karta hai: GPU0 shared memory mein X=5 likhta hai GPU1 X read karta hai (5 expect karta hai)

Coherency ke bina:

  • Write GPU0 ke cache mein buffered reh sakta hai
  • GPU1 stale value padhta hai (X=0)
  • Race condition!

NVLink coherency: GPU0 write broadcast karta hai → GPU1 cache invalidate karta hai → GPU1 fresh value fetch karta hai

NVSwitch: single-server se aage scaling

Problem: Har GPU mein 6 NVLink ports ke saath, seedha zyada se zyada 6 GPUs fully connect kar sakte ho. 16 ke baare mein? 128?

Solution: NVSwitch ek crossbar switch hai jisme 18 NVLink ports hain. GPUs switch se connect hote hain, jo traffic route karta hai.

Crossbar switch basics

Ek crossbar switch row-column intersections par switches ka matrix hota hai:

  • inputs, outputs
  • Koi bhi input kisi bhi output se simultaneously connect ho sakta hai (non-blocking)

Bandwidth (NVLink 2.0 ke liye hamare payload-consistent 20 GB/s/direction per port use karte hue):

(NVIDIA ka headline "900 GB/s" NVLink 2.0 NVSwitch ke liye 25 GB/s/dir raw line rate use karta hai: . 8b/10b ke baad, usable payload 720 GB/s hai.)

Non-blocking property: Sab 18 ports simultaneously full speed par transmit/receive kar sakte hain (agar destinations alag hon).

GPU interconnects ka comparison

Latency tumhare sochne se zyada kyun matter karta hai

Intuition: "Bulk transfers ke liye bandwidth hi sab kuch hai."

Asli baat: Bahut saare workloads mein chhote messages dominate karte hain.

Math: Transfer time = latency + (size / bandwidth)

4 KB message ke liye:

  • PCIe Gen4: 2000 ns + (4 KB ÷ 32 GB/s) = 2000 + 125 = 2125 ns
  • NVLink 3.0: 500 ns + (4 KB ÷ 40 GB/s) = 500 + 100 = 600 ns
  • Speedup: 3.5× (sirf bandwidth ratio se toh sirf 1.25× predict hota!)

4 MB message ke liye:

  • PCIe Gen4: 2000 + 125000 = 127 μs
  • NVLink 3.0: 500 + 100000 = 100.5 μs
  • Speedup: 1.26× (ab bandwidth dominate karta hai)

Takeaway: ~1 MB se chhote message sizes ke liye latency dominate karta hai. Zyaadatar deep learning synchronizations 100 KB – 10 MB hoti hain → latency critical hai.

Recall Ek curious 12-saal ke bacche ko explain karo

Socho tumhare paas 8 super-fast workers (GPUs) hain jo ek giant puzzle (AI train karna) solve karne ke liye team up karte hain. Har worker apne piece par incredibly quick hai, lekin unhe lagaataar information share karni padti hai: "Hey, maine yeh edge piece dhundha!" "Mera section sky jaisa lagta hai!"

Problem: Agar unhe ek bade warehouse ke across ek tiny walkie-talkie (PCIe bus) se shout karna pade, toh ek waqt mein sirf ek hi bol sakta hai, aur bahut time lag jaata hai. Jab tak sabne apne updates share kiye hote hain, woh already bahut zyada puzzle work kar sakte the!

NVLink ka solution: Har worker ko baaki sab workers ki direct phone lines do (point-to-point connections). Ab woh sab simultaneously baat kar sakte hain, information ke bade chunks super fast share kar sakte hain, aur zyaadatar time actually puzzle solve karne mein laga sakte hain communicate karne ka wait karne ki jagah.

Yeh farq hai:

  • Purana tarika: Multiplayer game dial-up internet par khelna (slow, laggy)
  • NVLink: Fiber optic internet par khelna (fast, smooth)

Puzzle WAY faster solve hoti hai kyunki workers coordinating mein kam time aur kaam karne mein zyada time lagate hain!

Concept Map

bottleneck ~16 GB/s

motivates

is

bypasses

built from

enables

cancels

20 or 25 GT/s + 8b/10b

8 lanes aggregated

speeds up

accelerates

PCIe tree via CPU

Multi-GPU comm bottleneck

NVLink interconnect

Point-to-point mesh

CPU root complex

Differential pairs / lanes

Differential signaling

Common-mode noise

Per-lane payload rate

Link bandwidth 16+ GB/s

Gradient all-reduce

Distributed training