← Jagesh Maharjan (Jugs) All posts
15 November 2026torchtitan · llama3_8b · HSDP replicate 2 × shard 4

How torchtitan spreads a Llama over 8 GPUs with FSDP2 and HSDP

The same questions as the nanotron post (where each weight lives, who talks to whom, what happens in one step), answered for fully sharded data parallel. No pipeline blocks, no column/row linears: every parameter is cut along dimension 0 across a shard group and re-assembled just in time.

SHShard group (dp_shard) · together hold one copy REReplicate group (dp_replicate) · same shard, other copy BBatch / loss mesh · all 8 ranks
Contents
    ModelLlama-3 8B · 32 layers · dim 4096
    Attention32 q-heads · 8 kv-heads · d 128
    FFN / vocab14 336 · 128 256
    Params8.03 B · 218 M per layer
    Meshdp_replicate 2 × dp_shard 4 = 8 GPUs
    Per step16 384 tok / dp rank × 8 = 131 072 tokens

    Numbers below are computed for Llama-3 8B on 8 × H100. File references point into torchtitan/torchtitan/ at commit 63de14f58. For the tensor- and pipeline-parallel side of the same problem, see the companion post, How a Llama is spread over 8 GPUs with nanotron.

    Why FSDP / HSDP — the memory arithmetic

    Data parallelism replicates the model; each replica sees different data. With plain DDP every GPU holds the full parameters, gradients and optimizer state. For 8B parameters with fp32 master weights and AdamW that is 16 bytes per parameter = 128 GB — more than an H100. FSDP (ZeRO-3) shards all three across the data-parallel ranks and materialises each layer’s full weights only for the moment it is computing. HSDP does the same inside a group and replicates across groups, trading some memory for cheaper communication.

    Per-GPU persistent state · Llama-3 8B · 8 GPUs · fp32 params + fp32 grads + AdamW (m, v), before activations
    DDPreplicate 8
    128.5 GB
    Does not fit on an 80 GB H100.
    ZeRO-1nanotron dp 8
    56.2 GB
    bf16 params + fp32 grads replicated, Adam ÷ 8.
    HSDPreplicate 2 × shard 4
    32.1 GB
    Everything ÷ 4.
    FSDPshard 8
    16.1 GB
    Everything ÷ 8, plus a 0.44 GB transient bf16 copy of the layer being computed.
    04012080 GB · H100

    torchtitan defaults: training.dtype float32 (master), mixed_precision_param bfloat16 (all-gathered compute copy), mixed_precision_reduce float32.

    Sharding the optimizer alone is not enough at 8B. ZeRO-1 leaves 56 GB of replicated weights and gradients per GPU; FSDP shards all three and needs 16 GB; HSDP sits in between. What FSDP pays instead is communication: every layer’s weights are all-gathered on each forward and backward (Part A3).

    The 8-GPU mesh

    torchtitan describes the cluster as a DeviceMesh rather than hand-built process groups. ParallelDims.build_mesh (distributed/parallel_dims.py) starts from a 1-D world mesh of 8 ranks and unflattens it into named axes several ways — one view for data loading, one for FSDP storage, one for the loss — all over the same 8 processes:

    ("pp", "batch", "cp", "tp")                         # dataloading mesh  → batch = dp_replicate · dp_shard = 8
    ("pp", "dp_replicate", "dp_shard", "cp", "tp")      # dense storage mesh → what fully_shard receives
    loss = dataloading["batch", "cp"].flatten()          # loss mesh          → 8
    assert dp_replicate · dp_shard · cp · tp · pp == world_size   # 2 · 4 · 1 · 1 · 1 = 8
    
    replicate 0
    shard group {0,1,2,3} · one full copy, cut 4 ways · all-gather params, reduce-scatter grads
    rank 0replicate 0 · shard 0rows 0–¼
    rank 1replicate 0 · shard 1rows ¼–½
    rank 2replicate 0 · shard 2rows ½–¾
    rank 3replicate 0 · shard 3rows ¾–1
    replicate 1
    shard group {4,5,6,7} · second full copy, cut 4 ways
    rank 4replicate 1 · shard 0rows 0–¼
    rank 5replicate 1 · shard 1rows ¼–½
    rank 6replicate 1 · shard 2rows ½–¾
    rank 7replicate 1 · shard 3rows ¾–1
    dp_shard{0,1,2,3} {4,5,6,7}. All-gather weights, reduce-scatter grads.
    dp_replicate{0,4} {1,5} {2,6} {3,7}. All-reduce sharded grads once per step.
    batchAll 8 ranks read different data.
    lossAll 8 ranks; token counts and loss are summed here.

    global rank = dp_replicate·4 + dp_shard · rank 0 and rank 4 hold the same rows

    Two copies, each in four pieces. Inside a shard group the four ranks all-gather weights before computing a layer and reduce-scatter its gradients after; across the replicate groups the two copies all-reduce their (already sharded) gradients once per step. All 8 ranks read different data — the batch mesh is the full world.

    Set data_parallel_replicate_degree 1 and the picture collapses to one shard group of 8 — plain FSDP. Set data_parallel_shard_degree 1 and it becomes DDP. HSDP earns its keep across nodes: shard within the 8 NVLink-connected GPUs of a node, replicate across nodes so only the small sharded gradient crosses the slower inter-node link.

    Reading rank numbers

    Three “ranks” again, with mesh-flavoured names:

    global rank dp_replicate dp_shard shard group replicate group batch / loss rank holds
    0 0 0 {0,1,2,3} {0,4} 0 rows 0–¼ of every parameter, fp32 + its Adam state; batch shard 0 of the data
    1 0 1 {0,1,2,3} {1,5} 1 rows ¼–½
    2 0 2 {0,1,2,3} {2,6} 2 rows ½–¾
    3 0 3 {0,1,2,3} {3,7} 3 rows ¾–1
    4 1 0 {4,5,6,7} {0,4} 4 rows 0–¼ (same slice as rank 0, different data)
    5 1 1 {4,5,6,7} {1,5} 5 rows ¼–½
    6 1 2 {4,5,6,7} {2,6} 6 rows ½–¾
    7 1 3 {4,5,6,7} {3,7} 7 rows ¾–1

    Worked example, global rank 5. It owns the second quarter of every tensor — e.g. rows 1024–2047 of layers.7.attention.wq.weight [4096, 4096] — as an fp32 DTensor shard [1024, 4096] plus the matching Adam m, v. Before layer 7 runs it all-gathers with ranks 4, 6, 7 to get the full bf16 [4096, 4096], computes, and (with reshard_after_forward) frees it again. In backward it all-gathers once more, computes the full gradient, reduce-scatters so it keeps only rows 1024–2047 of the gradient in fp32, then all-reduces that slice with rank 1 so both copies agree. Its data loader reads batch shard 5 of 8. Unlike the nanotron post, no rank has a different job: every rank runs the identical program on a different slice — that is what “SPMD” means and why there are no TensorPointers here.

    Part A · The model

    A1 · A plain Decoder, then fully_shard per block

    The model is ordinary PyTorch (models/common/decoder.py:253-308): an Embedding, a ModuleDict of transformer blocks, RMSNorm, and a Linear head. No parallel-aware layers are needed for FSDP — the forward is a for-loop:

    class Decoder(BaseModel):                                   # models/common/decoder.py
        def forward(self, tokens, positions=None, attention_masks=None):
            h = self.tok_embeddings(tokens) if self.tok_embeddings is not None else tokens
            for layer in self.layers.values():                  # ModuleDict → FQNs "layers.0" … "layers.31" survive PP deletion
                h = layer(h, attention_masks, positions)
            h = self.norm(h) if self.norm is not None else h
            return self.lm_head(h) if self.lm_head is not None else h
    

    Sharding is applied from outside, after construction, by apply_fsdp_to_decoder (distributed/fsdp.py), called from parallelize_llama (models/llama3/parallelize.py):

    mp_policy = MixedPrecisionPolicy(param_dtype=bf16, reduce_dtype=fp32, cast_forward_inputs=False)
    fsdp_config = {"mesh": dp_mesh, "mp_policy": mp_policy, "dp_mesh_dims": DataParallelMeshDims(shard="dp_shard", replicate="dp_replicate")}
    
    fully_shard(model.tok_embeddings, **fsdp_config, reshard_after_forward=True)
    fully_shard([model.norm, model.lm_head], **fsdp_config, reshard_after_forward=False)   # last unit: nothing to overlap with
    for layer_id, block in model.layers.items():
        fully_shard(block, **fsdp_config, reshard_after_forward=True)                  # one FSDP unit per transformer block
    fully_shard(model, **fsdp_config)                                                  # root unit: whatever is left
    

    Each fully_shard call defines one FSDP unit: the set of parameters that are all-gathered and freed together. Per-block units are the standard granularity — coarse enough to make each all-gather large (218 M params, 436 MB in bf16), fine enough that only one block’s full weights need to exist at a time. fully_shard is not a wrapper: it swaps the module’s class to FSDPTransformerBlock (a subclass of FSDPModule and the original), so model.named_parameters() keeps its names and the optimizer sees DTensors directly (docs/fsdp.md).

    A2 · One parameter, sharded on dim 0

    layers.7.attention.wq.weight · full [4096, 4096] · fp32 · 67 MB · Shard(0): dim 0 cut into dp_shard = 4 equal blocks
    rows 0 – 1023
    →
    rank 0 · local [1024, 4096] · 16.8 MBrank 4 · identical block (replica)
    rows 1024 – 2047
    →
    rank 1 · local [1024, 4096]rank 5 · identical block (replica)
    rows 2048 – 3071
    →
    rank 2 · local [1024, 4096]rank 6 · identical block (replica)
    rows 3072 – 4095
    →
    rank 3 · local [1024, 4096]rank 7 · identical block (replica)
    tensor full per rank
    tok_embeddings [128256, 4096] [32064, 4096]
    w1 [14336, 4096] [3584, 4096]
    w2 [4096, 14336] [1024, 14336]
    norm [4096] [1024]

    Contrast with nanotron’s TP: there the cut follows the math (columns for qkv, rows for o_proj). FSDP2 always cuts dim 0 — it is a storage layout, not a compute layout.

    A storage cut, not a compute cut. FSDP2 shards every parameter on dimension 0 regardless of what the layer does, because the full tensor is re-assembled before any math. The optimizer state (m, v) and fp32 gradient for a parameter live on the same rank as its shard, which is what makes ZeRO-3 memory ÷ shard-degree.

    A3 · The FSDP unit lifecycle — where the communication is

    For every FSDP unit (one transformer block) on every forward and backward:

    Forward of layer iper rank · shard group of 4
    sharded params · fp32 [¼] · 218 MB
    ①all-gather · cast to bf16 · 436 MB
    full params · bf16 · [4096, 4096] etc.
    ②compute · attention + FFN
    ③reshard · free the full copy (reshard_after_forward=True), go to layer i+1
    Backward of layer isame rank, reverse order
    sharded params · fp32 [¼]
    ④all-gather again · 436 MB
    ⑤compute grads · full grad bf16 · 436 MB
    ⑥reduce-scatter · sum, fp32 out
    sharded grad · fp32 [¼] · 218 MB
    ⑦HSDP only · all-reduce across {r, r+4} · 218 MB · avg

    Weights exist in full for one layer at a time. Steps ① and ④ are the price of FSDP; ⑥ is what DDP would have done as an all-reduce anyway (reduce-scatter is half of it). Step ⑦ is the only thing HSDP adds — and it runs on the sharded gradient, a quarter of the size.

    A4 · FSDP vs HSDP — the same step on two topologies

    FSDPdp_replicate 1 × dp_shard 8

    01234567
    • One shard group of 8. Every all-gather and reduce-scatter spans all 8 GPUs.
    • Memory ÷ 8 (16 GB); each rank holds ⅛.
    • Fine on one NVLink node. Across nodes, every layer's 436 MB crosses the network.

    HSDPdp_replicate 2 × dp_shard 4

    0123
    4567
    • Shard groups of 4 run the all-gather and reduce-scatter locally.
    • Replicate pairs (↕) all-reduce the ¼-size gradients.
    • Memory ÷ 4 (32 GB). Multi-node: shard = the 8 GPUs of a node, replicate = across nodes.

    FSDP1 → FSDP2 → DeepSpeed names (docs/fsdp.md):

    FSDP2 setting ≙ DeepSpeed
    1-D mesh + reshard=True ZeRO-3
    1-D mesh + reshard=False ZeRO-2
    2-D mesh + reshard=True MiCS (HSDP)

    The decision is a bandwidth one: shard as far as the fast interconnect reaches, replicate beyond it.

    On a single 8-GPU node HSDP 2×4 is mostly pedagogical — it costs 2× memory for no bandwidth benefit. Its real form is dp_shard = 8, dp_replicate = number of nodes.

    Same program, different mesh. Nothing in the model or the training step changes between the two — only the DeviceMesh handed to fully_shard and the DataParallelMeshDims(shard="dp_shard", replicate="dp_replicate") that tells FSDP2 which axis is which (distributed/fsdp.py::resolve_fsdp_mesh).

    A5 · Meta-device init, activation checkpointing, compile, TP

    1. Build on the meta device (trainer.py:81): with torch.device("meta"): model = spec.build() — 8B parameters cost nothing. Then parallelize_fn applies AC → compile → fully_shard while the tensors are still meta. Only then model.to_empty(device="cuda") allocates the sharded DTensors (16 GB, not 128), and init_weights() fills them in place (trainer.py:185-217). This is the FSDP2 flow docs/fsdp.md describes — no full model ever exists on one GPU.
    2. Activation checkpointing (distributed/activation_checkpoint.py): FullAC recomputes each block in backward; SelectiveAC (the debug default) saves every other matmul and recomputes the rest; MemoryBudgetAC lets the compiler choose. Applied per transformer block before fully_shard so the AC wrapper sits inside the FSDP unit.
    3. torch.compile (distributed/compile.py): compiles each block individually (so FSDP’s hooks stay at unit boundaries); optionally the loss too.
    4. Tensor / sequence parallel (model.parallelize(parallel_dims), distributed/tensor_parallel.py): only when tensor_parallel_degree > 1. Uses DTensor ColwiseParallel/RowwiseParallel/SequenceParallel plans — the same math as nanotron’s Column/Row linears, expressed as placements instead of custom modules. FSDP then shards the already TP-sharded tensors on dim 0, giving a 2-D placement. Off in this page’s configuration.
    5. spmd_types backend (default): a typed-SPMD layer that annotates each tensor’s placement per mesh axis (spmd.P partial, spmd.R replicated, spmd.I invariant) and can type-check the program. fully_shard receives the multi-axis storage mesh plus dp_mesh_dims so it knows which axes to shard and replicate.

    Part B · One train_step

    trainer.py:774-940. Because every rank runs the same program, the step reads almost like single-GPU PyTorch; the collectives are inside FSDP2’s hooks and three explicit reductions.

    B1 · Tokens → micro-batches → gradient accumulation

    torchtitan counts tokens, not sequences (config/configs.py:37-50):

    num_tokens_per_microbatch_per_dp_rank = 16384        # 8 sequences × 2048, or any packing that fills 16k slots
    num_tokens_per_train_step             = -1           # default: 16384 × num_pp_microbatches(1) × dp_degree(8) = 131 072
    gradient_accumulation_steps = num_tokens_per_train_step // (16384 × 1 × 8) = 1      # trainer.py:409-425
    

    Raise num_tokens_per_train_step to 524 288 and you get 4 accumulation micro-batches per rank. The data loader (components/data, backed by grain) is built with dp_world_size = batch_mesh.size() = 8 and dp_rank = batch_mesh.get_local_rank() (trainer.py:315, 550): each of the 8 ranks reads a disjoint shard of the dataset and packs documents into 16 384-token micro-batches (ConcatThenSplitPacking or FirstFitPacking). Under HSDP rank 0 and rank 4 hold the same weights but see different data — that is the point of the replicate axis.

    B2 · Forward and backward, with the all-gathers overlapped

    Forward on one rank · two CUDA streams · time →
    computelayer 0 fwdlayer 1 fwdlayer 2 fwdlayer 3 fwd… commAG 0AG layer 1AG layer 2AG layer 3AG layer 4

    Communication hides behind compute, or it doesn’t. This is why FSDP throughput depends on the ratio of per-layer FLOPs to per-layer bytes: large hidden sizes and long sequences favour it; small models on slow links do not.

    The code path (trainer.py:669-705) is ordinary: pred = model(inputs) → loss = loss_fn(pred, labels, global_valid_tokens) → loss.backward(). Inside, FSDP2’s pre-forward/pre-backward hooks perform ①–⑦. Loss = CrossEntropy(reduction="sum") / global_valid_tokens (components/loss.py), where global_valid_tokens is the number of non-ignored label tokens across all dp ranks this step (dist_sum_tensor(local_valid_tokens, batch_mesh), trainer.py:800). Dividing by the global count before backward makes the SUM reduce-scatter yield an exact per-token mean regardless of padding or micro-batch count — the reason gradient_divide_factor is set to 1.

    B3 · Clip, sanity, optimizer

    1. Clip (trainer.py:851, distributed/utils.py:571 clip_grad_norm_): gradients are DTensors, so torch.nn.utils-style norm computation is placement-aware — the local partial norms are reduced across the shard and replicate axes to a true global norm; then foreach scaling. PP stages are reduced over pp_mesh if present.
    2. Finite check (trainer.py:858-880): loss_is_finite all-reduced with MIN over the loss mesh (all 8), combined with isfinite(grad_norm), then torch._assert_async — the step aborts before the optimizer update if any rank saw NaN/Inf.
    3. checkpointer.maybe_wait_for_staging() — an async checkpoint from the previous step must finish copying tensors off the GPU before they change.
    4. optimizers.step(); lr_schedulers.step() — AdamW over each rank’s fp32 shards. Nothing to communicate: the shard’s m, v and master weight are local. The bf16 compute copy is produced fresh by the next all-gather.
    5. Logging (trainer.py:889-930): global_avg_loss = dist_sum(accumulated_loss, loss_mesh), global_max_loss, n_tokens_seen, grad_norm, LR — to TensorBoard/W&B via MetricsProcessor.

    B4 · The whole step on one page

    phase communication mesh axis who talks
    next(data_iterator) × accum × pp_mbs — local_valid_tokens = (labels != IGNORE).sum()      
    global_valid_tokens = dist_sum(local, batch) all-reduce SUM, one int64 batch all 8
    forward_backward_step — pred = model(inputs); loss = CE_sum / global_valid · loss.backward() — FSDP hooks do ①…⑦ per layer 32 × all-gather 436 MB (fwd) + 32 × (bwd) dp_shard {0,1,2,3} · {4,5,6,7}
    ″ 32 × reduce-scatter 872 MB → fp32 shard dp_shard  
    ″ 32 × all-reduce 218 MB of sharded grads dp_replicate {0,4}{1,5}{2,6}{3,7}
    clip_grad_norm_(max_norm=1.0) all-reduce of squared partial norms dp_shard × dp_replicate (+pp)  
    loss_is_finite all-reduce MIN → _assert_async all-reduce MIN, one int32 loss all 8
    maybe_wait_for_staging · optimizers.step · lr.step — local fp32 shards only none    

    Then train(): checkpointer.save(step, last_step) every interval · validator every freq · profiler.step(). Logging: dist_sum(loss, loss mesh), dist_max, n_tokens_seen.

    Every collective is on a named mesh axis. The heavy traffic lives in the FSDP hooks on dp_shard; HSDP’s dp_replicate all-reduce is a quarter the size; the explicit reductions in the step itself are single scalars.

    What is different from nanotron’s step, in one sentence each. No pipeline engine unless PP is on — a single forward/backward. No fp32 gradient accumulator object — FSDP2’s reduce_dtype=fp32 does it inside the reduce-scatter. No tied-weight sync — tied params are one FSDP unit (fully_shard([tok_embeddings, norm, lm_head])). No sampler offset arithmetic — the data loader’s own state is checkpointed (Part C). Loss is normalised by a global token count, not by micro-batch count.

    Part C · Checkpointing and resume — DCP

    CheckpointManager (components/checkpointer/dcp.py) wraps Distributed Checkpoint (DCP). The key property: DCP saves DTensors with their placement metadata, so a checkpoint written by 8 ranks as 2×4 can be loaded by 16 ranks as 1×16, or by 1 CPU process — resharding is automatic. That is why torchtitan can create a “seed checkpoint” on one CPU and load it into any topology.

    outputs/checkpoint/
    ├── step-500/  step-1000/  …
    │     (keep_latest_k = 10; rank 0 purges older folders in a background thread)
    └── step-1000/
        ├── .metadata
        │     global index: every FQN → dtype, full shape, and which chunk lives in which file
        │     (written by the coordinator rank)
        └── __0_0.distcp … __7_0.distcp       one file per rank — its own shards, no gathering
              model.layers.7.attention.wq.weight    rows [1024·s, 1024·(s+1))  fp32
              optimizer.state.…wq.weight.exp_avg     same rows
              optimizer.state.…wq.weight.exp_avg_sq  same rows
              lr_scheduler                           scalars
              dataloader.dp_rank_5                   grain iterator state (position in its data shard)
              train_state                            {step: 1000, ntokens_seen}
    

    Resharding is DCP’s job, not the trainer’s. Compare nanotron’s merge_and_shard_tp_tensors and the pp-change warning: here the storage format is topology-agnostic by construction, so tp/dp/pp can all change on resume, and the same folder feeds inference converters (scripts/checkpoint_conversion/convert_to_hf.py, dcp_to_torch).

    What is saved (base.py:27-31): model, optimizer, lr_scheduler, dataloader, train_state. Resume in train() (trainer.py:945) is one call, self.checkpointer.load(step=config.checkpoint.load_step), after which self.step and the data iterator continue exactly where they stopped; the log says Training starts at step N+1. Because the grain data-loader checkpoints its iterator per dp_rank, resuming with a different dp_world_size is rejected (loader.py:163) unless you exclude_from_loading=["dataloader"].

    torchtitan vs nanotron — the same problems, two philosophies

    concern nanotron torchtitan
    Fitting a big model TP (Column/Row linears) + PP (PipelineBlocks), ZeRO-1 for optimizer only FSDP2 shards params+grads+optimizer on dim 0; TP/PP/CP optional on top
    Process topology hand-built 5-D rank matrix → tp_pg, pp_pg, dp_pg, mp_pg DeviceMesh unflattened into named axes; DataParallelMeshDims tells FSDP which is shard/replicate
    Model code parallelism-aware modules; blocks declared on all ranks, built on one plain nn.Module; fully_shard applied from outside; every rank runs the same program
    Cross-rank tensors TensorPointer + P2P inside PipelineBlock DTensor with placements; collectives inside FSDP hooks
    Communication pattern 4 TP collectives per layer (activations); PP activations; 1 DP grad all-reduce per step 2 all-gathers + 1 reduce-scatter of weights/grads per layer; HSDP adds a sharded all-reduce
    8B on 8×H100 persistent memory ≈ 56 GB with ZeRO-1 dp 8 (would use TP/PP instead) 16 GB FSDP · 32 GB HSDP 2×4
    Mixed precision bf16 params, FP32GradientAccumulator fp32 master shards, bf16 all-gathered compute copy, fp32 reduce (MixedPrecisionPolicy)
    Loss normalisation ÷ nb_microbatches, AVG across dp ÷ global valid tokens (all-reduced count), SUM reduce-scatter
    Checkpoint format safetensors per (pp, tp) shard + per-rank optimizer .pt; tp/dp reshard by hand, pp warn-only DCP .distcp + .metadata; reshard to any topology automatically; HF export built in
    Data datatrove Nanoset (pre-tokenized .ds), Megatron sampler sharded by dp_rank grain loader over HF datasets, tokenizes + packs on the fly, sharded by batch-mesh rank; iterator state checkpointed
    Config YAML → dataclasses Python Trainer.Config registry + tyro CLI overrides (--parallelism.data_parallel_shard_degree 4)
    Install stable torch cu124 + flash-attn 2.6 + datatrove pin PyTorch nightly (cu130) + requirements.txt (grain, spmd_types, torch_checkpointing); Python ≥ 3.11

    Running it (8 × H100). pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu130 && pip install -r requirements.txt, download the Llama-3.1 tokenizer with scripts/download_hf_assets.py, then MODULE=llama3 CONFIG=llama3_8b NGPU=8 ./run_train.sh --parallelism.data_parallel_replicate_degree 2 --parallelism.data_parallel_shard_degree 4. Drop the two flags for plain FSDP (shard degree -1 = “all remaining GPUs”). CONFIG=llama3_debugmodel (dim 256, 6 layers, vocab 2048, c4_test) is the smoke test; it runs on a single GPU with NGPU=1. Multi-node: multinode_trainer.slurm (torchrun --nnodes 4 --nproc_per_node 8) — set shard degree 8, replicate degree = nodes.

    Config → mechanism

    config field (tyro path) value here what it selects above
    parallelism.data_parallel_shard_degree 4 size of the dp_shard axis: how many ways each parameter is cut (A2); −1 = fill remaining GPUs
    parallelism.data_parallel_replicate_degree 2 size of the dp_replicate axis; 1 = pure FSDP, >1 = HSDP (A4)
    parallelism.fsdp_reshard_after_forward default free full weights after forward (ZeRO-3) vs keep (ZeRO-2); “default” = True unless PP (A3)
    parallelism.tensor_parallel_degree · enable_sequence_parallel 1 · true optional DTensor TP/SP before FSDP (A5)
    parallelism.pipeline_parallel_degree · pipeline_parallel_schedule 1 · 1F1B optional PP via torch.distributed.pipelining; splits layers ModuleDict by FQN
    parallelism.spmd_backend spmd_types typed-SPMD annotations and mesh resolution (A5)
    training.num_tokens_per_microbatch_per_dp_rank 16 384 tokens per forward per rank; data loader packing target (B1)
    training.num_tokens_per_train_step −1 → 131 072 global tokens per optimizer step → gradient accumulation steps (B1)
    training.dtype · mixed_precision_param · mixed_precision_reduce fp32 · bf16 · fp32 master shards / all-gathered compute copy / reduce-scatter dtype (A3)
    training.max_norm 1.0 clip_grad_norm_ over the mesh (B3)
    activation_checkpoint SelectiveAC per-block recompute policy (A5)
    compile.enable · components false per-block torch.compile, optional loss compile (A5)
    checkpoint.enable · interval · keep_latest_k true · 500 · 10 DCP save cadence and purge (C)
    checkpoint.async_mode disabled / async / async_with_pinned_mem background save; maybe_wait_for_staging before optimizer step (B3, C)
    checkpoint.load_step · exclude_from_loading −1 · [] which step to resume, which states to skip (C)
    checkpoint.last_save_model_only · export_dtype · last_save_in_hf true · fp32 · false final export shape (C)

    Sources: distributed/parallel_dims.py, distributed/fsdp.py, models/llama3/parallelize.py, models/common/decoder.py, trainer.py, components/loss.py, components/checkpointer/{base,dcp}.py, components/data/, config/configs.py, docs/fsdp.md, docs/checkpoint.md, docs/composability.md at torchtitan commit 63de14f58 (2026-08-30). Memory and traffic figures are computed from the Llama-3 8B dimensions in models/llama3/__init__.py; activations excluded. Companion: the nanotron post, for the TP/PP side of the same problem.