@@ -351,7 +351,7 @@ def _build_linen_state(self, num_steps):
351351 def _invoke_maybe_save (self , state , pure_nnx ):
352352 """Call maybe_save_checkpoint with save_checkpoint patched, return {step, state} captured."""
353353 # checkpoint_period=1 keeps force_ckpt_save False regardless of actual_step.
354- config = SimpleNamespace (pure_nnx = pure_nnx , checkpoint_period = 1 , async_checkpointing = False )
354+ config = SimpleNamespace (pure_nnx = pure_nnx , checkpoint_period = 1 , async_checkpointing = False , enable_diloco = False )
355355 mgr = mock .MagicMock ()
356356 mgr .reached_preemption .return_value = False
357357
@@ -417,7 +417,7 @@ def test_maybe_save_checkpoint_skips_if_already_saved(self):
417417 state = self ._build_nnx_state (self .N_STEPS )
418418 actual_step = self .N_STEPS - 1
419419
420- config = SimpleNamespace (pure_nnx = True , checkpoint_period = 1 , async_checkpointing = False )
420+ config = SimpleNamespace (pure_nnx = True , checkpoint_period = 1 , async_checkpointing = False , enable_diloco = False )
421421 mgr = mock .MagicMock ()
422422 mgr .reached_preemption .return_value = False
423423 # Mock latest_step to return the same actual_step
@@ -436,7 +436,7 @@ def test_maybe_save_checkpoint_saves_if_not_already_saved(self):
436436 state = self ._build_nnx_state (self .N_STEPS )
437437 actual_step = self .N_STEPS - 1
438438
439- config = SimpleNamespace (pure_nnx = True , checkpoint_period = 1 , async_checkpointing = False )
439+ config = SimpleNamespace (pure_nnx = True , checkpoint_period = 1 , async_checkpointing = False , enable_diloco = False )
440440 mgr = mock .MagicMock ()
441441 mgr .reached_preemption .return_value = False
442442 # Mock latest_step to return a different step (or None)
@@ -460,9 +460,7 @@ def _nnx_pure(self):
460460 return {
461461 "model" : {
462462 "decoder" : {"norm" : {"scale" : jnp .ones ((3 ,))}},
463- "dropout" : {
464- "rngs" : {"default" : {"key" : jnp .ones ((2 ,), dtype = jnp .uint32 )}}
465- }, # NNX-only
463+ "dropout" : {"rngs" : {"default" : {"key" : jnp .ones ((2 ,), dtype = jnp .uint32 )}}}, # NNX-only
466464 },
467465 "optimizer" : {
468466 "step" : jnp .asarray (7 , dtype = jnp .uint32 ),
@@ -481,9 +479,7 @@ def test_to_linen_layout(self):
481479 linen = train_state_nnx .to_linen_checkpoint_dict (self ._nnx_pure ())
482480 self .assertEqual (set (linen .keys ()), {"params" , "step" , "opt_state" })
483481 self .assertIn ("params" , linen ["params" ]) # params/params/ collection wrap
484- self .assertNotIn (
485- "dropout" , linen ["params" ]["params" ]
486- ) # NNX-only rngs/dropout stripped
482+ self .assertNotIn ("dropout" , linen ["params" ]["params" ]) # NNX-only rngs/dropout stripped
487483 self .assertEqual (linen ["step" ].dtype , jnp .int32 ) # Linen step is int32
488484 # opt_state is a list with None for the EmptyState slot, mu/nu wrapped under params.
489485 self .assertIsInstance (linen ["opt_state" ], list )
@@ -493,19 +489,11 @@ def test_to_linen_layout(self):
493489
494490 def test_round_trip_preserves_values (self ):
495491 nnx_pure = self ._nnx_pure ()
496- back = train_state_nnx .from_linen_checkpoint_dict (
497- train_state_nnx .to_linen_checkpoint_dict (nnx_pure )
498- )
492+ back = train_state_nnx .from_linen_checkpoint_dict (train_state_nnx .to_linen_checkpoint_dict (nnx_pure ))
499493 self .assertEqual (set (back .keys ()), {"model" , "optimizer" })
500- self .assertEqual (
501- back ["optimizer" ]["step" ].dtype , jnp .uint32
502- ) # NNX step back to uint32
503- self .assertEqual (
504- set (back ["optimizer" ]["opt_state" ].keys ()), {0 , 2 }
505- ) # int-keyed dict, EmptyState dropped
506- self .assertNotIn (
507- "params" , back ["optimizer" ]["opt_state" ][0 ]["mu" ]
508- ) # mu/nu unwrapped
494+ self .assertEqual (back ["optimizer" ]["step" ].dtype , jnp .uint32 ) # NNX step back to uint32
495+ self .assertEqual (set (back ["optimizer" ]["opt_state" ].keys ()), {0 , 2 }) # int-keyed dict, EmptyState dropped
496+ self .assertNotIn ("params" , back ["optimizer" ]["opt_state" ][0 ]["mu" ]) # mu/nu unwrapped
509497 self .assertTrue (
510498 jnp .array_equal (
511499 nnx_pure ["model" ]["decoder" ]["norm" ]["scale" ],
0 commit comments