Fix bug in Adagrad optimizer initialization (#8976)
ZeRO rebuilt Adagrad from a flat list of FP32 partitions instead of
parameter-group dictionaries. It combined every partition into one
optimizer group, using the constructor defaults.
This caused two problems:
• Multi-group crashes: ZeRO still referenced the original group IDs, but
the rebuilt optimizer only had group 0, causing ` IndexError ` during
gradient processing or optimizer stepping.
• Lost per-group settings: custom learning rates, weight decay, and
other options were replaced by global defaults. Even a single-group
configuration could silently produce incorrect updates if it used
group-specific overrides.
With this fix, now it use parameter-group dictionaries with the custom
learning rates, weight decay and etc. In zero 3, the param group were
created temporarily for initialization and then were cleared.
---------
Signed-off-by: Hongwei Chen <hongweichenmail@gmail.com>
Co-authored-by: pengdurice <pengduhit@gmail.com>