Skip to content

Commit 5c5dedf

Browse files
RecML authorsrecml authors
authored andcommitted
Internal change
PiperOrigin-RevId: 966951288
1 parent 8e8b05b commit 5c5dedf

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

recml/core/utils/keras_utils.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,15 @@ def __init__(
7474
checkpoint_dir: str,
7575
max_to_keep: int = 5,
7676
save_interval_epochs: int = 1,
77+
choose_store_cell: bool = True,
7778
):
7879
"""Initializes a KerasOrbaxCheckpointManager.
7980
8081
Args:
8182
checkpoint_dir: The directory to save checkpoints to.
8283
max_to_keep: The maximum number of checkpoints to keep.
8384
save_interval_epochs: The interval (in epochs) to save checkpoints.
85+
choose_store_cell: Whether to dynamically select the CNS2 store cell.
8486
"""
8587
if keras.backend.backend() != "jax":
8688
raise ValueError(
@@ -92,6 +94,11 @@ def __init__(
9294
options=ocp.CheckpointManagerOptions(
9395
save_interval_steps=save_interval_epochs,
9496
max_to_keep=max_to_keep,
97+
file_options=ocp.options.FileOptions(
98+
cns2_storage_options=ocp.options.Cns2StorageOptions(
99+
choose_store_cell=choose_store_cell,
100+
),
101+
),
95102
),
96103
)
97104

@@ -430,20 +437,27 @@ def __init__(
430437
checkpoint_dir: str,
431438
max_to_keep: int = 5,
432439
save_interval_epochs: int = 1,
440+
choose_store_cell: bool = True,
433441
):
434442
"""Initializes a KerasOrbaxCheckpointManager.
435443
436444
Args:
437445
checkpoint_dir: The directory to save checkpoints to.
438446
max_to_keep: The maximum number of checkpoints to keep.
439447
save_interval_epochs: The interval (in epochs) to save checkpoints.
448+
choose_store_cell: Whether to dynamically select the CNS2 store cell.
440449
"""
441450
super().__init__(
442451
directory=checkpoint_dir,
443452
checkpointers=ocp.AsyncCheckpointer(ocp.PyTreeCheckpointHandler()),
444453
options=ocp.CheckpointManagerOptions(
445454
save_interval_steps=save_interval_epochs,
446455
max_to_keep=max_to_keep,
456+
file_options=ocp.options.FileOptions(
457+
cns2_storage_options=ocp.options.Cns2StorageOptions(
458+
choose_store_cell=choose_store_cell,
459+
),
460+
),
447461
),
448462
)
449463

0 commit comments

Comments
 (0)