nshuster's picture
summary as repo readme
bd12cae verified
|
Raw
History Blame Contribute Delete
5.67 kB

Gemma-4-31B × Augmental SFT — Run Summary (2026-07-17/18)

Full-parameter SFT of google/gemma-4-31B (base) on Heralax/Augmental-Dataset (7,831 rows of visual-novel multi-character roleplay). 8× H200, DeepSpeed ZeRO-3, bf16, axolotl.

Results

Checkpoint eval_loss eval_ppl Where
base (step 0) 1.753 5.77
epoch 1 (step 240) 1.572 4.81 out/epoch1-checkpoint-240 + HF -ep1
epoch 2 (step 480) 1.521 (best) 4.58 out/checkpoint-480 + HF -ep2
epoch 3 (step 720, final) 1.707 5.51 out/checkpoint-720 + HF -ep3
  • 720 steps in 1h08m49s (~5.2–5.8 s/step, ~29.3k real tokens/step, ~17–22% MFU)
  • Epoch 3 overfits (train loss 0.42 vs eval 1.71) — expected/accepted for style-soak; ep2 is the best held-out model, ep3 the strongest style imitator.
  • Peak VRAM ~74/141 GiB per GPU; grad norms spiked during warmup (up to 1927 pre-clip) then settled.

Prompt format (no chat template — screenplay style)

Scenario: {setup}

{Speaker A}: *action* "dialogue"
{Speaker B}: *action* "dialogue"
{target speaker}:

Model writes one turn for the trailing speaker tag and stops at <eos>. Prompt is masked in training (train_on_inputs: false); only completions + <eos> are trained. Verified against the real tokenizer: single <bos> (id 2), trained <eos> (id 1), no double-BOS.

Problems hit & fixes (in order)

  1. Checkpoint size vs 500 GB volume quota. Full ZeRO-3 checkpoints are ~434 GB (fp32 Adam m+v 248 + fp32 master weights 124 + bf16 model 62); quota had ~426 GB free. → save_only_model: true (weights-only, ~62 GB/ckpt). Note: df on the volume shows the whole 378 TB MooseFS pool, not your quota — the 500 GB limit is enforced externally by RunPod.
  2. Crash: No module named 'torchvision'Gemma4Processor import failure. Gemma-4 is a VLM; its processor needs torchvision, which axolotl[deepspeed,flash-attn] doesn't pull in. → uv pip install torchvision (added to setup_pod.sh + Dockerfile).
  3. Crash: FlashAttention forward only supports head dimension at most 256. Structural: Gemma-4 is hybrid-attention — 50 sliding layers (head_dim 256) + 10 global layers (global_head_dim 512, attention_k_eq_v: true). FA2 hard-caps at 256; flash-attn-4 is beta-only. → attn_implementation: sdpa.
  4. save_total_limit: 2 would have pruned the epoch-1 checkpoint at the final save. Avoided a restart by renaming checkpoint-240 → epoch1-checkpoint-240 after its save completed (the Trainer's pruner only globs checkpoint-*). yaml now says 3 for future runs.
  5. HF cache confusion: pod presets HF_HUB_CACHE=/workspace/data/huggingface-cache/hub, which overrides the script's HF_HOME=/workspace/hf. Model was already fully cached there (62.6 GB) — no re-download ever needed. Launch commands pin HF_HUB_CACHE explicitly.

What I'd change next run (ranked by impact)

  1. sample_packing: true — avg sample is ~917 tokens in a 4096 window → ~75% of compute was padding. Packing ≈ 2× compute win. Must smoke-test with SDPA (axolotl packing has historically preferred flash-attention var-len kernels).
  2. Tune ZeRO-3 comms — fetched zero3_bf16.json uses stage3_max_live_parameters: 0 / max_reuse_distance: 0 (maximally re-gathers). ~70 GiB/GPU sat idle; raising these cuts all-gather traffic. Est. 10–25%.
  3. micro_batch_size: 4, accum 1 (same global 32) — fewer accumulation passes. Est. 10–20%.
  4. Bake the env into a Docker image (see Dockerfile/start.sh) — venv on the network fuse mount made every 8-rank launch pay ~9 min of imports; local-disk venv cuts startup to ~2 min, and skips the 30-min flash-attn compile forever. Drop flash-attn from extras (SDPA is in use).
  5. Checkpoint to local NVMe then async-copy to the volume — each 62 GB save blocked training ~3 min writing to MooseFS.
  6. 1-GPU smoke test before the 8-rank launch (load model + one forward) — would have caught crashes #2 and #3 in ~3 min instead of ~25 min of failed distributed launches.
  7. Consider lr ~2–3e-6 if targeting best held-out (warmup grad spikes + fast ep2→ep3 overfit suggest 5e-6 is hot for full-FT), or stop at 2 epochs.
  8. Optional/speculative: torch.compile, flash-attn-4 beta (Hopper supports it; 5–15% maybe).

Files in this bundle

File What
RUN_SUMMARY.md this document
setup_pod.sh pod bootstrap (idempotent; now installs torchvision)
augmental-fullsft.yaml axolotl config (final: sdpa, save_only_model, limit 3)
prep_augmental.py dataset → axolotl input_output JSONL converter
Dockerfile + start.sh bake-the-env image for instant pod startup (RunPod notes inside)
zero3_bf16.json DeepSpeed config used
README-ep{1,2,3}.md HF model cards as published
train.log full training log (final successful run)
setup_pod.run.log environment build log

Artifacts on the pod volume (/workspace, ~500 GB quota)

  • out/epoch1-checkpoint-240, out/checkpoint-480, out/checkpoint-720 — ~62 GB each
  • out/ root also holds a duplicate final save (= checkpoint-720); delete one pair member to reclaim 62 GB
  • data/huggingface-cache — base model cache (62.6 GB, re-downloadable)
  • All three checkpoints are also on HF (public): nshuster/gemma4-31b-augmental-sft-ep{1,2,3}