Add grad_accum: effective batch 256 on small GPUs via micro-batching
TrainConfig.grad_accum (default 1, behaviour unchanged) splits the batch into batch_size // grad_accum loader micro-batches; train_probe accumulates their gradients before each optimiser step (clip and fp16 unscale at window boundaries, scheduler steps per update). The Stage-A ladder's largest points need ~15+ GiB activations at batch 256, which no longer fits a 16 GB RTX 4060 Ti; accumulation keeps the spec's uniform effective batch while micro-batches stay under ~8 GiB. Tests: first-update gradient of accum=3 matches full-batch exactly; loader micro-batch sizing; suite green (52 passed).
This commit is contained in:
@@ -73,6 +73,11 @@ class TrainConfig:
|
||||
"""Training semantics (GATE ZERO §5.1; restated in the torch model spec §5)."""
|
||||
|
||||
batch_size: int = 256
|
||||
# Effective optimiser batch stays ``batch_size``; the loaders emit
|
||||
# micro-batches of ``batch_size // grad_accum`` and gradients are
|
||||
# accumulated over ``grad_accum`` of them before each step, so small
|
||||
# GPUs (16 GB) can honour the spec's batch 256.
|
||||
grad_accum: int = 1
|
||||
lr: float = 3e-4
|
||||
weight_decay: float = 0.01
|
||||
max_epochs: int = 40
|
||||
|
||||
Reference in New Issue
Block a user