fix: metric deferral + optimizer optimization - #151
Conversation
Signed-off-by: Dogac Eldenk <dogacel@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b9f890d801
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| self.fp32_params, | ||
| lr=lr, | ||
| weight_decay=weight_decay, | ||
| fused=True, |
There was a problem hiding this comment.
Avoid forcing fused AdamW for CPU-offloaded training
When fsdp_cpu_offload is enabled, apply_fsdp2(..., cpu_offload=True) installs CPUOffloadPolicy, so this optimizer's fp32 master parameters can be CPU tensors. Forcing fused=True makes AdamW require fused-supported accelerator tensors and raises on the first optimizer step instead of falling back to the single/foreach implementation, regressing CPU-offloaded training from working to failing; let PyTorch choose the backend or gate this on all master params being on a fused-supported device.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Avoid forcing fused AdamW for CPU-offloaded training
When
fsdp_cpu_offloadis enabled,apply_fsdp2(..., cpu_offload=True)installsCPUOffloadPolicy, so this optimizer's fp32 master parameters can be CPU tensors. Forcingfused=Truemakes AdamW require fused-supported accelerator tensors and raises on the first optimizer step instead of falling back to the single/foreach implementation, regressing CPU-offloaded training from working to failing; let PyTorch choose the backend or gate this on all master params being on a fused-supported device.Useful? React with 👍 / 👎.
Should I disable if fsdp_cpu_offload then?
Speedup is near 5-10%, because saved computation is already mostly overlapped. However those optimizations ensure we have more room to overlap in the future.
.item()calls produced by metrics.torch._foreach_copy_-> %50 faster optimizer stepsFinal profiler result:
Before: