Skip to content

Commit 0a5066a

Browse files
fix(nnx): support non-indexed opt_state paths in gpt3 paxml conversion
1 parent 7b0e353 commit 0a5066a

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/maxtext/checkpoint_conversion/standalone_scripts/convert_gpt3_ckpt_from_paxml.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ def init_state_fn():
213213
state_map = {
214214
"['optimizer']['step'].value": ("step", None),
215215
"['optimizer']['opt_state'][0]['count'].value": ("opt_states_0.no_prefix_0.count", None),
216+
"['optimizer']['opt_state']['count'].value": ("opt_states_0.no_prefix_0.count", None),
216217
}
217218
else:
218219
state_map = {
@@ -237,10 +238,18 @@ def get_layer_prefix(keystr_pax):
237238
f"opt_states_0.{prefix_pax_opt_state}.m{keystr_pax}",
238239
transform_fn,
239240
)
241+
state_map[f"['optimizer']['opt_state']['mu']{keystr_maxtext}.value"] = (
242+
f"opt_states_0.{prefix_pax_opt_state}.m{keystr_pax}",
243+
transform_fn,
244+
)
240245
state_map[f"['optimizer']['opt_state'][0]['nu']{keystr_maxtext}.value"] = (
241246
f"opt_states_0.{prefix_pax_opt_state}.v{keystr_pax}",
242247
transform_fn,
243248
)
249+
state_map[f"['optimizer']['opt_state']['nu']{keystr_maxtext}.value"] = (
250+
f"opt_states_0.{prefix_pax_opt_state}.v{keystr_pax}",
251+
transform_fn,
252+
)
244253
else:
245254
state_map[f".params['params']{keystr_maxtext}"] = (f"mdl_vars{keystr_pax}", transform_fn)
246255
state_map[f".opt_state.mu['params']{keystr_maxtext}"] = (

0 commit comments

Comments
 (0)