Unit 10 of 10 · about 3 hours · derive

Training-step operation, activation and communication arithmetic

Inference arithmetic is half the track's modeling. Training steps set the scale of the systems later sections parallelize, and the 6ND plus memory lines are the bridge.

You'll be able to

  • Derive per-step training operations (about ) from the forward plus backward walks.
  • Account parameter, Adam-state and checkpoint-activation bytes for a named config.
  • Predict compute-bound versus comms-bound training for a batch and topology from the sharding rule.

Covers

Training-step operation, activation and communication arithmetic
1

Read

In this order, only the parts listed

0 of 2 done

  1. Training problems: parameters, Adam and activation bytes, step timeHow to Scale Your Model - Training

    Some Problems to Work, Questions 1 to 3 with answers (13B parameters; 130 GB optimizer-state line; 42 TB checkpoint activations at 16M tokens; the 300 ms step with its comms-bound verdict)

  2. Data-parallel and FSDP comms-bound rulesHow to Scale Your Model - Training

    Data Parallelism (10 bytes per parameter with Adam) and Fully-Sharded Data Parallelism (FSDP) (the per-device batch over rule with the LLaMA-3 70B 6.3e24 example)

2

Focus on

  • Forward is about , backward about (weight gradients plus input gradients); the total shows directly in the step recomputation.
  • Adam in fp32 with bf16 weights costs 10 bytes per parameter (2+4+4); the 13B line is 130 GB before any activation.
  • Checkpoint activations scale with batch times layers (42 TB at 16M tokens); batch, not depth alone, forces the sharding choice.
  • FSDP and data parallelism stay compute-bound while the per-device batch exceeds the interconnect ratio, 2550 divided by the number of mesh axes on v5p (850 over all three); below it, comms sets the step.
Common mistakes · 3
  • Using for a training step. Inference's forward-only count misses the backward's two matmuls per layer; the step is .
  • Forgetting optimizer state in the fit. The two fp32 moments cost 8 bytes against 2 for weights; the bf16 parameters are a fifth of the 130 GB line, not all of it.
  • Quoting the chapter's 300 ms as exact. It rounds 310 ms at assumed 40% utilization; your utilization and hardware change the step, not the operation count.
3

Try it yourself

Closed-book, before checking anything

Closed-book, derive the Question 3 step: operations at 40% of FLOP/s gives about 310 ms (the chapter rounds to 300), and state why pure FSDP is comms-bound there.
4

Quiz yourself

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

0 got · 0 missed

  1. 1.Why per training step and not ?Answer

    Forward costs about ; backward costs about (one gradient per weight matrix plus one per input), totaling , or per token.

  2. 2.How much memory do 13B bf16 parameters with fp32 Adam take, and why?Answer

    GB: 2 bytes of weight plus 4 bytes per moment accumulator.

  3. 3.What forces sharding at 16M tokens with 3 checkpoints per layer?Answer

    About 42 TB of checkpoint activations: bytes. No single device holds that beside the optimizer state.

  4. 4.Why is Question 3 comms-bound under pure FSDP?Answer

    3M tokens sit below the 3.48M minimum for 4096 chips (), so communication exceeds compute at that batch.

5

Practice

You're done when

You derive 6ND, 130 GB, 42 TB and the 310 ms step without notes and call the comms-bound verdict with the batch rule.

Only when you can do this without notes.

Leads to

Notes

Resources · 1 for this unit, 8 more in the section
  • How to Scale Your Model - TrainingJAX Scaling Book · required

    Work Some Problems to Work Questions 1 to 3 for training-step parameters, Adam and activation bytes and step time; read Data Parallelism and Fully-Sharded Data Parallelism for the comms-bound batch rule.

Also in this section

  • How to Scale Your Model - InferenceJAX Scaling Book · primary

    Work through the single-request, batching, key-value memory and parallelism arithmetic. Recompute every quantity for the small model and workload used by the track project, keeping symbols, units and assumptions visible.

  • AI Performance Engineering - Start HereWafer · reference

    A curated, dated index. Its Start Here list names the readings this section already assigns; use the later sections only to find a primary source for a later section, never as the reading itself.

  • Transformer Inference ArithmeticKipply · required

    Reproduce the FLOP, parameter-byte, key-value-byte and communication estimates for dense transformer inference. Compare the formulas with an instrumented framework trace and explain model residuals instead of fitting constants after measurement.

  • Efficiently Scaling Transformer InferenceMLSys · required

    Study the latency, memory and parallelism model. Use the paper to derive a batch and parallelism crossover for your workload, while reserving distributed execution for GPU-9.

  • EtalonEtalon Authors · support

    Read the latency metric definitions, their pitfalls and fluidity-index. Add TTFT and TPOT SLOs to a small load generator, and show why peak token throughput can rank two systems differently from an SLO-qualified rate.

  • GPU Microbenchmark and Kernel SuiteRoadmap-Final · support

    Adopt the project harness schema, architecture constraints and hardware tiers now. Implement only the environment manifest, independent references, raw-trial storage and the initial operation and byte models in this stage.

  • Amdahl's lawWikipedia · reference

    Read Definition and Derivation for the overall-speedup formula with the worked share examples; apply it to kernel time shares at fixed workload.

  • DistServe: Disaggregating Prefill and Decoding for Goodput-optimized LLM ServingZhong et al. (OSDI 2024) · support

    Read Section 1 with Figure 1 for per-GPU goodput: the highest request rate served while a target share of requests meets the TTFT and TPOT SLOs.