Mixed precision: 2026 의 bf16 디폴트
가중치 fp32, forward/backward 중 activation + gradient 는 bf16, optimizer step 위한 master 가중치는 fp32. TrainingArguments 의 bf16=True 가 다 핸들. 지원 하드웨어 (Ampere+) 에선 거의 품질 비용 X + 약 2x 속도.
Gradient accumulation: 무료 가상 batch size
GPU 가 4 example fit 하는데 레시피가 batch=64 원하면 per_device_train_batch_size=4 + gradient_accumulation_steps=16. Optimizer 가 16 microbatch 누적해 64-example gradient 봄. 비용: optimizer step 당 16x compute. 이득: 어떤 GPU 든 어떤 레시피든 학습 가능, 그저 느릴 뿐.
메모리 트릭 셋 더
gradient_checkpointing=True— backward 중 activation 저장 X, 재계산. ~50% 메모리 감소, ~30% 속도 비용.optim="adamw_8bit"(bitsandbytes) — 8-bit Adam state. 큰 모델 학습할 때 많이 절약.torch.compile(model)— PyTorch 2.x 의 graph compiler. stable shape 면 1.2-1.5x 속도; dynamic shape 엔 가끔 해로움.