Repository navigation
ezpz: AGPT-2B throughput recovery on Sunspot (TT vs MDS) - #74
Merged
Merged
Conversation
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.
… replicated launcher
…T memory breakdown
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.
…es and three seeds
saforem2
force-pushed
the
ezpz
branch
3 times, most recently
from
November 5, 2026 14:36
fff19c4 to
10bd786
Compare
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.
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.
|
Sorry @saforem2, your pull request is larger than the review limit of 150,000 diff characters |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
torch.compiletakes TT native DDP/ZeRO-1 from75.84to79.42-80.20model TFLOP/s/tile. At two sequences per rank per update, TT is2.3-2.6%faster than the MDS SophiaG control in the same allocation (2.2852vs2.344-2.347 s/update,12482111).EZPZ_XPU_ATTN_CAUSAL_BLOCKS=4) gives2.0788 s/update,88.17TFLOP/s/tile,10.5%faster than its same-job control (12482301).12482374-12482376): three seeds,400updates from random init. Paired difference from default is at most0.013in any window; seed-to-seed spread is0.018-0.034.7.8-9.5%faster per update in every pair. It stays opt-in until it runs multi-node and past400updates.89.76vs89.99TFLOP/s/tile (8dscnx65config). The lower November 2 MDS rate came from accumulation2and theBF16_Optimizerpath.4a72fa1bfgives88.00on a cold first launch vs92.6-95.1on later launches (July:93.75). Cause still open.12482619,24tiles): MDS2.2046/2.2056 s/update; TT FP32 storage2.3023(4.4%slower); TT BF16 storage2.1387(3.0%faster); TT BF16 storage + block-causal1.9200(12.9%faster,95.46TFLOP/s/tile).z2rrt02w: hidden4096, sequence4096, accumulation16), TT is26%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.BENCH_DDP_ZERO1_PARAMS=bfloat16) with block-causal:8.082/8.087 s/update(108.9TFLOP/s/tile) vs8.956-9.463 sfor FP32 storage (12482585),0.9%behind MDS (8.008 s), peak memory20.3vs41.8 GiB.12482597-12482599, three seeds,400updates): at most0.072per window against0.053-0.104seed spread; over the last10updates BF16 is higher in all three seeds by0.004-0.008.2.5-6.2%faster at accumulation2. Opt-in.12482631-12482633): every seed/window inside the0.048-0.087seed spread, mean-0.007over updates301-400, final windows mixed in sign.11.7-18.6%faster at one node.24tiles for2000updates (12482684-12482686): every window inside the default seed spread, mean-0.004over updates1601-2000, final10-update windows2.803/2.812/2.830vs2.801/2.821/2.826.15.1-16.4%faster.What's in it
agpt/xpu_block_causal_attention.pyand theEZPZ_XPU_ATTN_CAUSAL_BLOCKSroute inXPUScaledDotProductAttention. Off by default.zero1.py, accumulated DDP, theddp-bf16-losscompilearm withblocks-losscompile.native_ddp_zero1_param_dtype(BF16 model storage, FP32 master shard), off by default;tests/test_zero1.pycovers it.mds-4096x10flavor,agpt_mds_shape_benchmark_adamw,agpt_2b_loss_ab.benchmark_agpt_replicated_{tt,mds,matrix}.sh,benchmark_mds_historical_shape.sh, withBENCH_SEQ,BENCH_SEQS_PER_RANK,BENCH_SEED,BENCH_TT_CONFIG.summarize_xpu_trace.py(same kernel buckets for TT and MDS traces);MDS_PROFILE=1inbenchmark_mds_historical_shape.sh.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.2026-11-01-*-evidence.json, about36klines, mostlytiming-evidence.json).docs/journal.mdentries for each step.Open
z2rrt02wshape: TT's block-causal path is0.54 s/updateslower than IPEX xetla.2000-update loss A/B. Whether to make them the default is open.Merge state
ezpzis merged in (b175a7c86). Conflicts resolved:docs/journal.md: this branch's November 2-4 entries on top, then allezpzentries. The duplicate November 1 handoff entry keeps theezpzversion, which includes jobs12481905/12481906.2026-11-01-handoff-audit.md: theezpzversion. It supersedes this branch's copy, whose only extra text was in-progress status for12481904/12481905.2026-10-31-replicated-comparison.md: takes theezpzheading,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 inda9ceb8f;test_bf16_master_rebuilt_from_weights_loaded_after_optimizer_statefails on the old code.validate_native_ddprejectsfsdp_defer_gradient_reduction.Default-path behavior changes (no flag)
blendcorpus_builder.py: withemit_positions=Falseand 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.module.prefix. Native-DDP checkpoints saved before this PR fail to load (DCP reports missing keys).Shard(0)with a warning.w13all-gathers about 6x its size at 12 ranks.