Fix ZeRO-3 optimizer initialization validation (#7844)
Overview
This PR addresses issue #7844 by adding a validation check to ensure the ZeRO-3 optimizer is correctly initialized before training begins.
Changes
- Added a check for the
.stepattribute on the optimizer specifically for ZeRO-Stage 3 configurations. - This prevents the engine from entering a deadlock state during the first training step when JIT kernels fail to compile or toolchain mismatches occur.
Related Issue
Fixes #7844
@sfc-gh-truwase Thanks for the clarification!
-
Added backward to optimizer validation.
-
Updated validation to check self.optimizer.backward instead of self.backward.
-
Redundant hasattr check for the ZeRO-3 epilogue has been removed.
Please let me know if anything else needs adjustment.
@amadhan882 can you please address the formatting issues?
@amadhan882 can you please address the formatting issues?
Thanks for the feedback. I am currently reviewing the changes to resolve the formatting issues and will push the updated commits shortly.
@amadhan882 can you please address the formatting issues?
Thanks for the feedback. I am currently reviewing the changes to resolve the formatting issues and will push the updated commits shortly.
I saw a lot formatting changes, I met the same when using opencode to change the code. The reason is edit tool call will change formatting. If you are using opencode or cc, ask your agent to use sed instead of edit tool call to modify the code, which will solve this issue.