Repository navigation
Fix ZeRO-3 checkpoint conversion with --debug - #8530
vineethsaivs wants to merge 1 commit into
Conversation
|
Could a maintainer approve CI for this PR? The focused regression tests and repository lint checks pass locally. |
alanhuangyoo
left a comment
There was a problem hiding this comment.
Ran your test on CPU both ways: master dies at the same AttributeError: 'list' object has no attribute 'shape', passes on this branch.
One thing worth adding to the description: the avail_numel line you removed wasn't only crashing. It replaced the correct group sum from the top of the function with fp32_flat_groups[0].numel(), and avail_numel is what the offset != avail_numel check at the end compares against, so with --debug that check was looking at the wrong number too.
The zero-2 debug block at :317 already prints shapes per group, so this just brings stage 3 in line.
|
Good catch, added to the description: the shadowed |
|
Correcting myself: that reassignment never actually ran. The |
|
You're right, the print dies first so that line never ran. My mistake, thanks for checking. |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused fix matches ZeRO-3 data structures and is covered by an end-to-end converter test.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes ZeRO-3 checkpoint conversion crashes when debug logging handles optimizer groups.
Changes:
- Log each rank’s optimizer-group shapes correctly.
- Preserve the existing valid
avail_numelcalculation. - Add a CLI regression test for debug export.
| File | Description |
|---|---|
deepspeed/utils/zero_to_fp32.py |
Corrects ZeRO-3 debug handling. |
tests/unit/checkpoint/test_convert_checkpoint.py |
Adds debug-export regression coverage. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
This looks right to me. avail_numel is already defined at the top of the function and the check at the end uses it, so dropping the reassignment is safe. |
|
Thanks for checking it. |
Print individual group shapes and reuse the existing total element count. Signed-off-by: Vineeth Sai <vineethsai4444@gmail.com>
11559ae to
937b377
Compare
The checkpoint converter crashes with
--debugon ZeRO-3 checkpoints._zero3_merge_trainable_paramsreceives each rank's optimizer groups as a list and the debug block treats it as a tensor, reading.shapeand.numel()off the list. Print the per-group shapes instead, the way the ZeRO-2 debug block above it already does, and drop theavail_numelreassignment: it recomputed, wrongly, a value the top of the function already has.Tests:
DS_ACCELERATOR=cpu python -m pytest tests/unit/checkpoint/test_convert_checkpoint.py -k 'not TestCheckpointConvert' -q. Debug export fails before. Five converter tests pass after. A separate real ZeRO-3 Adam step with two parameter groups, checkpoint save and debug export produces matching weights. Changed-file pre-commit passes. Apple M2 Pro CPU, PyTorch 2.10, one-rank Gloo; no GPU run.