Demo data: three made-up repos and three people, recorded by the real Trail hooks.About TrailGitHub
153 lines · 2.7 KBRaw

claude session 285791a1-5658-4fdc-992c-f9a75f8c525f

User

The 7B LoRA fine-tune keeps blowing up around step 400. Logs are in logs/run-17.log. Fix it.

Assistant (thinking)

run-17: grad_norm jumps from 1.2 to 48.7 at step 380, NaN by 400. Warmup ends at step 100, so we're at full LR 3e-4 for ~300 steps before it blows up. LR too hot for r=64 LoRA on this data, and warmup too short. Try 2e-4 first, it's the smaller change.

Tool call: Bash

{
 "command": "python train.py --lr 2e-4 --run run-18",
 "description": "Retry with lower LR"
}

Tool result

step 520 loss 2.33 grad_norm 31.0
step 540 loss nan
DIVERGED

Assistant (thinking)

2e-4 only delays it (diverges at 540). The short warmup is the bigger issue. Go to 1e-4 AND warmup 500. Rejected: switching to Adafactor, too big a change for this fix.

Tool call: Bash

{
 "command": "python train.py --lr 1e-4 --warmup 500 --run run-19",
 "description": "Lower LR and longer warmup"
}

Tool result

step 1000 loss 1.79 grad_norm 0.9
eval_loss 1.82
DONE

Tool call: Edit

{
 "file_path": "/home/dev/code/ml-pipeline/train.py",
 "old_string": "LR = 3e-4",
 "new_string": "LR = 1e-4  # 3e-4 and 2e-4 diverged (run-17, run-18)"
}

Tool result

The file train.py has been updated.

Tool call: Edit

{
 "file_path": "/home/dev/code/ml-pipeline/train.py",
 "old_string": "WARMUP_STEPS = 100",
 "new_string": "WARMUP_STEPS = 500"
}

Tool result

The file train.py has been updated.

Assistant

Fixed: LR 3e-4 to 1e-4 and warmup 100 to 500. run-19 is stable to step 1000 with eval loss 1.82 (baseline 2.31). 2e-4 alone still diverged at step 540 (run-18).

Tool call: Bash

{
 "command": "git commit -am \"Lower LR and lengthen warmup to stop divergence\"",
 "description": "Commit"
}

Tool result

[main 60e503f] Lower LR and lengthen warmup to stop divergence

User

Add gradient clipping too, as a safety net.

Assistant (thinking)

run-19 is stable but grad_norm briefly hit 6.0 near step 700. Clip at 1.0 is the usual choice for LoRA; 0.3 slowed learning in run-12 last week.

Tool call: Edit

{
 "file_path": "/home/dev/code/ml-pipeline/train.py",
 "old_string": "GRAD_CLIP = None",
 "new_string": "GRAD_CLIP = 1.0"
}

Tool result

The file train.py has been updated.

Tool call: Bash

{
 "command": "python train.py --run run-20",
 "description": ""
}

Tool result

step 1000 loss 1.78 grad_norm 0.7 clipped 3x
eval_loss 1.81
DONE

Assistant

Added clipping at 1.0. run-20: eval loss 1.81, clipping fired 3 times.

Tool call: Bash

{
 "command": "git commit -am \"Clip gradients at 1.0\"",
 "description": "Commit"
}