~/fba-lab/lab/speedrun/journey/tyler-04

FBALab

Code · architecture · study mode

AboutRoadmapSpeedrun
FBALab

Study mode — no GPU required.

Interactive LLM training & inference lab.

Qwen CAboutContactTermsPrivacyCookiesCommunity

© 2026 FBA Lab

Contact · contact@bubblspace.com · +91 75061 55016

Speedrun›Teaching arc›#2.3 Dataloading Tweaks
Act 1Model Training FundamentalsAct 2AI Systems OptimizationAct 3World-Record Training Optimization
Step 5 of 28Skill: Model Training Fundamentals
← #2.2 Muon Optimizer#2.4 Logit Soft-capping →
TRAINING SIMULATION

Speedrun — #2.3 Dataloading Tweaks

running
◷train_gpt2.py▸DistributedDataLoader◎learner⌁04-data-loading$no GPU
baseline
GPT-2 d12
Starting architecture and training loop.
step 01
train
active
optimize
Speedrun step
Architecture diffs and optimizer changes.
steps 02–05
loss
target
val loss 3.28
Cumulative loss timeline and finale.
step 06
1/4
Blocks
Quick summary

Shard iterator with per-rank cursor; yields contiguous (B,T) token windows.

Full explanation below the code →

fba-lab — train_gpt2.py · DistributedDataLoaderexecuting
// block: DistributedDataLoader · lines 293–338$ study train_gpt2.py --block dataloaderShard iterator with per-rank cursor; yields contiguous (B,T) token windows. ✓
Explanation

Shard iterator with per-rank cursor; yields contiguous (B,T) token windows.

Think about

What changed in how B is passed to the train loader vs step 03?

// architecture

Live diagram

100%
speedrun journey013.28→023.28→033.28→043.28→053.27→063.27Loader batch size tweakAvoid double-counting grad_accum in load…er; cleaner token accounting.Simplified loader initRemove verbose token count print; stream…line startup.val loss11.02 → 3.28 (-7.74)◉ before/afterFineWeb shardsshard_0.binshard_1.binshard_2.binshard_3.binDDP rank cursoroffset = rank × B × Trank 0 ──┬── rank 1next_batch()int32 → CUDACHANGED(B, T)CUDAdevicebefore: B × grad_accumstep 04 changeB only(not B × grad_accum)
← #2.2 Muon Optimizer#2.4 Logit Soft-capping →

What changed vs 03-muon

- f'step:{step + 1}/{args.num_iterations} train_loss:{train_loss.item():.4f} train_time:{approx_time:.0f}ms step_avg:{approx_time / timed_steps:.2f}ms tokens_seen:{tokens_seen:.2e} tokens/sec:{tokens_per_second:.2e}',

What it bought

Learn this step, your way

WatchReadDeep Dive

🎬 Video lesson coming soon

This step's video hasn't been recorded yet. The text lesson and Rune's deep-dives cover the same ground in the meantime.