Unit 1 of 11 · about 4 hours · explain, derive

Replica serving and tensor-parallel inference shapes and collectives

A router distributes requests across replicas; tensor parallelism distributes one request's model work across ranks. Confusing the two gives the wrong capacity estimate and the wrong recovery boundary.

You'll be able to

  • Distinguish independent serving replicas from ranks cooperating on one forward pass, including their request-level fault domains.
  • Derive local MLP and attention projection shapes for a tensor-parallel serving plan.
  • Place forward collectives and explain why added memory capacity need not reduce small-batch latency.

Covers

Replica or data-parallel servingTensor-parallel inference shapes and collectives
1

Read

In this order, only the parts listed

0 of 2 done

  1. Replicas versus model shardsHands-On LLM Serving and Optimization - Chapter 7, multi-GPU and disaggregation

    Chapter 7, Data Parallelism, printed pp. 243 to 245; Tensor Parallelism and Pipeline Parallelism, printed pp. 245 to 250

    Read the replica and TP paths now. Leave the pipeline decision path for the next unit; do not run the multi-GPU launch snippet.

  2. The paired column and row shardsLLM Inference: From scratch, one token at a time - Module 09

    Module 09, Tensor parallelism: split inside the layer - The MLP block and The attention block

    Stop before Communication volume. Two reductions per layer describes this replicated-activation dense forward schedule, not every TP implementation.

2

Focus on

  • Reuse Collective contracts and the latency-bandwidth cost model. Serving replicas do not synchronize gradients; a replica can itself contain a TP group.
  • For input of shape , column-shard the first MLP weight of shape , then row-shard the second of shape . Each local intermediate has shape for divisible width and ranks.
  • An elementwise activation stays local between these shards. The second projection produces same-shaped partial outputs that sum, not concatenate. Add a replicated output bias once after summation.
  • Attention head shards can compute independently before the output projection reduction. KV-head replication and vocabulary-parallel output paths need separate ownership accounting.
Common mistakes · 3
  • Counting replicas as additional memory for a single request. Each independent replica needs the full model and its own admitted KV state.
  • Calling every column-sharded output an all-reduce. Disjoint output features concatenate; row-sharded dot-product contributions sum.
  • Promising a latency speedup from rank count. Smaller kernels, startup costs and dependencies can consume the extra compute or memory bandwidth.
3

Try it yourself

Closed-book, before checking anything

Closed-book, derive a bias-free two-rank ReLU MLP with input shape , first weight shape and second weight shape . Give each rank three intermediate features, sum its partial output, and check against the unsharded MLP on CPU using small deterministic float64 tensors. State a numerical tolerance rather than demanding bitwise equality.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.Does inference replica serving require the training gradient all-reduce?Answer

    No. Independent requests run forward passes against fixed weights. Shared routing or cache metadata is a separate control-plane concern.

  2. 2.Why can the first projection's activation remain local?Answer

    Each rank owns complete values for its output features, and ReLU acts independently on each feature. No partial sum is needed before that activation.

  3. 3.What shape does each second-projection partial have in the reproduce example?Answer

    . Each rank multiplies a intermediate by its weight rows; the two partials sum to the full output.

  4. 4.Can replicas lower endpoint latency without making the forward pass faster?Answer

    Yes. Distributing arrivals can reduce queueing. It does not shorten the isolated forward service time on an unchanged replica.

You're done when

Your paired-shard MLP matches the unsharded reference within the stated tolerance, and your diagram separates replica routing from TP collectives and their fault domains.

Only when you can do this without notes.

Leads to

Notes

Resources · 2 for this unit, 11 more in the section

Also in this section