Skip to content

ezpz: AGPT-2B throughput recovery on Sunspot (TT vs MDS) - #74

Merged
saforem2 merged 109 commits into
ezpzfrom
codex/agpt-perf-recovery-20261102
Nov 12, 2026
Merged

saforem2 merged 109 commits into
ezpzfrom
codex/agpt-perf-recovery-20261102

Conversation

@saforem2

@saforem2 saforem2 commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

TT vs MDS throughput on Sunspot (AGPT-2B), October 31 to November 5: replicated comparison, the evidence audit, and the throughput recovery. All changes are under torchtitan/experiments/ezpz/.

Full write-up: 2026-11-02-throughput-recovery.md. Earlier records: 2026-10-31-replicated-comparison.md, 2026-11-01-handoff-audit.md.

Results

  • Per-block torch.compile takes TT native DDP/ZeRO-1 from 75.84 to 79.42-80.20 model TFLOP/s/tile. At two sequences per rank per update, TT is 2.3-2.6% faster than the MDS SophiaG control in the same allocation (2.2852 vs 2.344-2.347 s/update, 12482111).
  • Opt-in block-causal attention (EZPZ_XPU_ATTN_CAUSAL_BLOCKS=4) gives 2.0788 s/update, 88.17 TFLOP/s/tile, 10.5% faster than its same-job control (12482301).
  • Loss A/B for block-causal (12482374-12482376): three seeds, 400 updates from random init. Paired difference from default is at most 0.013 in any window; seed-to-seed spread is 0.018-0.034. 7.8-9.5% faster per update in every pair. It stays opt-in until it runs multi-node and past 400 updates.
  • MDS reproduces its March number: 89.76 vs 89.99 TFLOP/s/tile (8dscnx65 config). The lower November 2 MDS rate came from accumulation 2 and the BF16_Optimizer path.
  • The TT anchor 4a72fa1bf gives 88.00 on a cold first launch vs 92.6-95.1 on later launches (July: 93.75). Cause still open.
  • Against MDS's fastest AGPT-2B config (AdamW, ZeRO-1), same allocation (12482619, 24 tiles): MDS 2.2046/2.2056 s/update; TT FP32 storage 2.3023 (4.4% slower); TT BF16 storage 2.1387 (3.0% faster); TT BF16 storage + block-causal 1.9200 (12.9% faster, 95.46 TFLOP/s/tile).
  • At the wider 2025 MDS shape (z2rrt02w: hidden 4096, sequence 4096, accumulation 16), TT is 26% slower than MDS AdamW/ZeRO-1, 14% with block-causal. An MDS trace (12482583) puts the block-causal gap in attention backward (+0.54 s/update, IPEX xetla vs TT) and casts/elementwise work (+0.50 s): TT's ZeRO-1 model held BF16 values in FP32 storage, so every weight was cast on every microbatch.
  • Opt-in BF16 ZeRO-1 model storage (BENCH_DDP_ZERO1_PARAMS=bfloat16) with block-causal: 8.082/8.087 s/update (108.9 TFLOP/s/tile) vs 8.956-9.463 s for FP32 storage (12482585), 0.9% behind MDS (8.008 s), peak memory 20.3 vs 41.8 GiB.
  • Loss A/B for BF16 storage at AGPT-2B (12482597-12482599, three seeds, 400 updates): at most 0.072 per window against 0.053-0.104 seed spread; over the last 10 updates BF16 is higher in all three seeds by 0.004-0.008. 2.5-6.2% faster at accumulation 2. Opt-in.
  • Loss A/B of block-causal plus BF16 storage against the default (12482631-12482633): every seed/window inside the 0.048-0.087 seed spread, mean -0.007 over updates 301-400, final windows mixed in sign. 11.7-18.6% faster at one node.
  • Loss and performance charts for the combination A/B: https://claude.ai/artifact/2vPQ4dnfS13Vbrjrb6FabE (private until shared)
  • Same A/B at 24 tiles for 2000 updates (12482684-12482686): every window inside the default seed spread, mean -0.004 over updates 1601-2000, final 10-update windows 2.803/2.812/2.830 vs 2.801/2.821/2.826. 15.1-16.4% faster.

What's in it

  • agpt/xpu_block_causal_attention.py and the EZPZ_XPU_ATTN_CAUSAL_BLOCKS route in XPUScaledDotProductAttention. Off by default.
  • zero1.py, accumulated DDP, the ddp-bf16-losscompile arm with blocks-loss compile.
  • native_ddp_zero1_param_dtype (BF16 model storage, FP32 master shard), off by default; tests/test_zero1.py covers it.
  • Configs: mds-4096x10 flavor, agpt_mds_shape_benchmark_adamw, agpt_2b_loss_ab.
  • Benchmark launchers: benchmark_agpt_replicated_{tt,mds,matrix}.sh, benchmark_mds_historical_shape.sh, with BENCH_SEQ, BENCH_SEQS_PER_RANK, BENCH_SEED, BENCH_TT_CONFIG.
  • summarize_xpu_trace.py (same kernel buckets for TT and MDS traces); MDS_PROFILE=1 in benchmark_mds_historical_shape.sh.
  • Probes: probe_block_causal_grads.py, check_block_causal_compile.{py,sh}, probe_fsdp_reduce_precision.py, bench_xccl_overlap.py, audit_agpt_batch_hashes.py, initial_parameter_audit.py.
  • Evidence JSON for the November 1 audit (2026-11-01-*-evidence.json, about 36k lines, mostly timing-evidence.json).
  • docs/journal.md entries for each step.

Open

  • Cause of the cold-first-launch slowdown.
  • Attention backward at the z2rrt02w shape: TT's block-causal path is 0.54 s/update slower than IPEX xetla.
  • BF16 storage and block-causal: both have now passed a two-node, 2000-update loss A/B. Whether to make them the default is open.
  • TT FSDP with deferred reduction at that shape.

Merge state

ezpz is merged in (b175a7c86). Conflicts resolved:

  • docs/journal.md: this branch's November 2-4 entries on top, then all ezpz entries. The duplicate November 1 handoff entry keeps the ezpz version, which includes jobs 12481905/12481906.
  • 2026-11-01-handoff-audit.md: the ezpz version. It supersedes this branch's copy, whose only extra text was in-progress status for 12481904/12481905.
  • 2026-10-31-replicated-comparison.md: takes the ezpz heading, Gates and arms (historical plan).

Review fixes (2026-11-11)

  • zero1.py: in BF16 all-gather mode the FP32 master was built from the pre-load weights on a full checkpoint resume, and the first step overwrote the restored model with them (max |param - ckpt| 36 after one step). Fixed in da9ceb8f; test_bf16_master_rebuilt_from_weights_loaded_after_optimizer_state fails on the old code.
  • Known limitation: the FP32 master is not checkpointed, so each resume rounds it to BF16.
  • validate_native_ddp rejects fsdp_defer_gradient_reduction.

Default-path behavior changes (no flag)

  • blendcorpus_builder.py: with emit_positions=False and local batch > 1, rows now get their own positions from 0. RoPE is now correct per row, and flex/varlen backends build per-row document masks. B>1 loss curves will differ from runs before this PR.
  • Native-DDP checkpoint keys drop the module. prefix. Native-DDP checkpoints saved before this PR fail to load (DCP reports missing keys).
  • Uneven-row FSDP falls back to padded Shard(0) with a warning. w13 all-gathers about 6x its size at 12 ranks.

NativeDDP adds a module. prefix to every FQN, so loading the audited
native-weight DCP failed with missing module.layers.* keys. Point the
checkpointer's model state at the unwrapped modules; parameters are
shared, so saves and loads still act on the live DDP model.
MDS job 12481849 exited training on all 24 ranks, then hung in the
finally-block Sophia witness: its .item() reads waited on device work
left by the aborted step, so the original exception was never printed.
Print the traceback first and skip witness reductions after a failure.
Native DDP always runs the model under autocast, and Linear rejects
inplace_wgrad_accum=True there. Full-model run 12481850 failed in the
first forward on all 24 ranks. Turn it off when wrapping.
MDS rejects --checkpoint-activations without a recompute method (job
12481858: Invalid activation recompute method). One layer per uniform
chunk matches TT activation-checkpoint:full.
…cher

ZeRO-0 SophiaG runs fail at the first training step three ways
(hang 12481849, OUT_OF_RESOURCES 12481855, GPU page fault 12481859),
while the Oct 23 ZeRO-1 AdamW baseline ran on the same runtime. These
knobs bisect stage and optimizer at the 24-rank geometry.
AGPT-2B stacked w13 [2, 11008, 2048] shards on dim 1, which FSDP2 rejects
unless 11008 divides the shard degree. TT FSDP job 12481864 failed at 24
ranks; PPN=8 gives 16 ranks (11008 / 16 = 688) for a matched pair.
…d launcher

DeepSpeed <=0.17.5 defaulted bf16 without ZeRO to FP32 gradient
accumulation and BF16_Optimizer (DP-sharded FP32 masters and optimizer
state). DeepSpeed 0.18.5 defaults to BF16 accumulation and
FP16_UnfusedOptimizer (unsharded), and rejects ZeRO-0 with FP32
accumulation. MDS_ZERO0_PATH=ds0175 selects BF16_Optimizer through ZeRO
stage 1 plus grad_accum_dtype=fp32 and asserts the wrapper at init.
TT_ROOT can now point at a separate worktree.
AGPT-2B w13 is [2, 11008, 2048]. The Shard(1) override from cde3c93
(core linear_param_shard_placements, upstream pytorch#4808) makes fully_shard
raise NotImplementedError at 12 or 24 ranks because FSDP2 only pads
dim 0 and 11008 % 12 != 0. Drop the override for params whose local
row count does not divide the FSDP shard degree (shard axes only, so
HSDP replicate axes do not count) and warn once with the shapes.
ARM=hsdp-{eager,losscompile} shards over HSDP_SHARD ranks (default PPN,
one replica per node) and replicates across the rest of the world.
Rebind trainable parameters to one padded FP32 buffer before DDP wraps
the model, retarget the recipe's single elementwise optimizer group to
this rank's contiguous shard, and all-gather the updated buffer after
each step. native_ddp_zero1_allgather_dtype=bfloat16 keeps an FP32
master shard and BF16-rounded replicated parameters, as MDS's
BF16_Optimizer does.
BENCH_DDP_ZERO1 selects the ZeRO-1 all-gather dtype, and
BENCH_DDP_BUCKET_FIRST bucketizes DDP's first backward. The ablation
launcher accepts per-variant KEY=VALUE overrides, so DDP and FSDP arms
can share one allocation. The Sophia witness records ZeRO-1 shard state.
…rchy

qsub -v splits on commas, so comma-separated per-variant overrides
could not be submitted.
…PZ_XPU_ATTN_CAUSAL_BLOCKS

Batch each block diagonal into one flash call; wire the flag into
XPUScaledDotProductAttention and the TT ablation launcher.
@saforem2
saforem2 force-pushed the ezpz branch 3 times, most recently from fff19c4 to 10bd786 Compare November 5, 2026 14:36
tyro parses the bare "False" as a positional, not a value for the
boolean flag — every rank exits with "Unrecognized options: False".
wandb is off by default so the flag is unnecessary; removing it.
saforem2 and others added 6 commits November 11, 2026 14:06
License header on 16 files, ufmt, wrap long lines in the
watch_agpt_replicated remote script, rename the _null context
manager, explicit weights_only on torch.load, plain attribute
access instead of constant getattr in blendcorpus_builder.
A DCP resume builds optimizer state (init_optim_state steps, firing
pre_step -> ensure_master) before the checkpoint's model weights are
copied in. The FP32 master latched the pre-load weights and the first
real step all-gathered them over the restored model: max |param - ckpt|
36 after one step, vs 0.005 in FP32 mode. Reset master_initialized from
an optimizer load_state_dict post-hook and keep the forward pre-hook
registered so the master is rebuilt from the loaded weights.

Document that the FP32 master is not checkpointed, so a resume rounds
it to BF16.

Reject fsdp_defer_gradient_reduction under native DDP: the engine casts
the model to FSDPModule and NativeDDP has no set_is_last_backward.

Tests: resume-order regression (fails on the old code), validator.
…s level

__iter__ reads the witness, which only __init__ set, so a loader built with
object.__new__ raised AttributeError. Six tests in test_blendcorpus_fold_batch_dim
and test_blendcorpus_resume_position do exactly that and failed on this branch.
@saforem2
saforem2 marked this pull request as ready for review November 12, 2026 17:36
Copilot AI balanced review requested due to automatic review settings November 12, 2026 17:36
@saforem2
saforem2 merged commit cd9646e into ezpz Nov 12, 2026
2 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@sourcery-ai

sourcery-ai Bot commented Nov 12, 2026

Copy link
Copy Markdown

Sorry @saforem2, your pull request is larger than the review limit of 150,000 diff characters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants