Checkpointing
PhiJAX stores complete functional training state for exact resumption and also supports model-only restoration for transfer learning.
ModelCheckpoint callback
ModelCheckpoint delegates storage to CheckpointIO; the default backend uses Orbax. A Trainer accepts only one
checkpoint callback. The callback opens its backend when fitting starts and closes it during teardown. Custom backends
must support repeated open() and close() calls and must be able to reopen for later tasks.
The callback owns retention through save_top_k, as in Lightning. The backend never deletes checkpoints on its own.
| Configuration | Retained ranked checkpoints |
|---|---|
monitor=None, save_top_k=1 (default) |
The latest checkpoint |
monitor=None, save_top_k=-1 |
Every checkpoint |
monitor=None, save_top_k=0 |
None; periodic saves are skipped |
monitor="train/loss", save_top_k=k |
The best k by the metric and mode |
monitor="step", mode="max", save_top_k=k |
The latest k checkpoints |
Without monitor, only -1, 0, and 1 are valid, as in Lightning. step is always available as a monitor.
save_last=True keeps the terminal state outside the ranking. The next terminal checkpoint replaces it. Public
best_model_path, best_model_score, and last_model_path attributes expose the resolved results. Without monitor,
best_model_path points to the latest ranked checkpoint and best_model_score is None. Checkpoints also persist
callback state, including ranking and learning-rate bookkeeping.
A checkpoint leaves storage only after the next checkpoint write has committed. An interrupted asynchronous write therefore never removes the only valid checkpoint.
ModelCheckpoint
[source]
ModelCheckpoint(
checkpoint_io: CheckpointIO,
*,
every_n_steps: int | None = None,
save_last: bool = True,
save_on_exception: bool = False,
monitor: str | None = None,
mode: MonitorMode = "min",
save_top_k: int = 1,
)
Bases: Callback
Save functional training states at a configured interval and at fit completion.
The callback owns checkpoint scheduling and retention, following Lightning's ModelCheckpoint. Its
checkpoint_io backend only stores, restores, and deletes checkpoints, so alternative storage implementations can
be supplied without changing trainer orchestration.
Retention:
- With
monitor, the callback keeps the bestsave_top_kcheckpoints ranked by that metric.stepis always available as a monitor, somonitor="step", mode="max"keeps the latestsave_top_kcheckpoints. - Without
monitor,save_top_k=1keeps only the latest checkpoint,-1keeps every checkpoint, and0skips periodic saves. - The terminal checkpoint written by
save_lastorsave_on_exceptionis never removed by ranking. The next terminal checkpoint replaces it.
A checkpoint leaves storage only after the next checkpoint write has committed, so an interrupted asynchronous write never removes the only valid checkpoint.
Attributes:
| Name | Type | Description |
|---|---|---|
best_model_path |
Path | None
|
Path of the best retained checkpoint, or of the latest one without |
best_model_score |
float | None
|
Best retained monitored value, or |
last_model_path |
Path | None
|
Path of the terminal checkpoint, when available. |
Initialize checkpoint lifecycle policy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
checkpoint_io
|
CheckpointIO
|
Storage backend used for checkpoint operations. |
required |
every_n_steps
|
int | None
|
Positive periodic save interval, or |
None
|
save_last
|
bool
|
Whether to save the final state passed to :meth: |
True
|
save_on_exception
|
bool
|
Whether to save the last valid state from :meth: |
False
|
monitor
|
str | None
|
Optional scalar metric used to rank checkpoints. |
None
|
mode
|
MonitorMode
|
|
'min'
|
save_top_k
|
int
|
Number of ranked checkpoints to keep. |
1
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If checkpoint scheduling or monitoring options are invalid. |
connect
[source]
Connect checkpoint persistence to Trainer callback state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trainer
|
Any
|
Owning Trainer. |
required |
on_fit_start
[source]
Open checkpoint resources and drop tracked steps that are no longer stored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
TrainerContext
|
Initial trainer context. |
required |
on_train_batch_end
[source]
Save the state when the completed optimizer step matches the configured interval.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
TrainerContext
|
Post-update trainer state, step, and metrics. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Always |
on_train_metrics
[source]
Evaluate periodic checkpoint policy after all metrics are available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
TrainerContext
|
Complete post-update metric context. |
required |
on_fit_end
[source]
Save the terminal state when save_last is enabled.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
TrainerContext
|
Final trainer state, step, and metrics. |
required |
on_exception
[source]
Save the most recent valid state when save_on_exception is set or the fit received SIGTERM.
SIGTERM usually means a cluster scheduler is preempting the job, so the last completed step is always saved
for a later resume.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exception
|
BaseException
|
Exception or interruption terminating the fit call. |
required |
context
|
CallbackContext
|
Most recent internally consistent trainer context. |
required |
teardown
[source]
Wait for asynchronous writes, remove displaced checkpoints, and release stage resources.
close
[source]
Wait for pending writes and release checkpoint backend resources idempotently.
state_dict
[source]
Return checkpoint ranking and path state.
Returns:
| Type | Description |
|---|---|
Mapping[str, Any]
|
JSON-compatible persistent callback state. |
load_state_dict
[source]
Restore checkpoint ranking and path state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
Mapping[str, Any]
|
Persistent state returned by :meth: |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the saved state is malformed. |
Checkpoint IO protocol
CheckpointIO
[source]
Bases: Protocol
Describe the storage operations required by :class:ModelCheckpoint.
Backends must allow open() after close(). Both methods must be idempotent so each Trainer task can own its
resources independently.
latest_step
property
Return the latest committed checkpoint step.
Returns:
| Type | Description |
|---|---|
int | None
|
Latest checkpoint step, or |
steps
property
Return committed checkpoint steps in ascending order.
Returns:
| Type | Description |
|---|---|
tuple[int, ...]
|
Ordered checkpoint steps. |
save
[source]
save(
state: Any,
step: int,
metrics: Mapping[str, float] | None = None,
*,
force: bool = False,
callback_states: Mapping[str, Mapping[str, Any]]
| None = None,
) -> bool
Submit a checkpoint to storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
Any
|
Functional state to persist. |
required |
step
|
int
|
Unique checkpoint step. |
required |
metrics
|
Mapping[str, float] | None
|
Optional host scalar metrics. |
None
|
force
|
bool
|
Whether to bypass backend scheduling policies. |
False
|
callback_states
|
Mapping[str, Mapping[str, Any]] | None
|
Optional JSON-compatible callback states. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
Whether the backend initiated a save. |
checkpoint_path
[source]
Return a user-facing path for one checkpoint step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step
|
int
|
Committed checkpoint step. |
required |
Returns:
| Type | Description |
|---|---|
Path | None
|
Checkpoint path, or |
delete
[source]
Delete one committed checkpoint.
Deleting a step that is not stored must be a no-op.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step
|
int
|
Checkpoint step to remove. |
required |
restore
[source]
Restore a complete state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
Any
|
State defining the expected restore structure. |
required |
step
|
int | None
|
Checkpoint step, or |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
Restored complete state. |
restore_model_state
[source]
Restore only the model state, without optimizer, balancer, or run state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
Any
|
Model-state PyTree defining the expected structure, dtypes, and sharding. |
required |
step
|
int | None
|
Checkpoint step, or |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
Restored model state. |
restore_input_statistics
[source]
Read the stored model-input normalization statistics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step
|
int | None
|
Checkpoint step, or |
None
|
Returns:
| Type | Description |
|---|---|
InputStatistics | None
|
Stored statistics, or |
Raises:
| Type | Description |
|---|---|
LegacyCheckpointError
|
If the checkpoint predates stored input statistics. |
restore_input_periods
[source]
Read the stored physical periods of periodic input axes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step
|
int | None
|
Checkpoint step, or |
None
|
Returns:
| Type | Description |
|---|---|
ResolvedInputPeriods | None
|
Stored |
Raises:
| Type | Description |
|---|---|
LegacyCheckpointError
|
If the checkpoint predates stored input periods. |
restore_callback_states
[source]
Restore callback state metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step
|
int | None
|
Checkpoint step, or |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Mapping[str, Any]]
|
Stable callback identifier mapping. |
wait_until_finished
[source]
Wait until pending checkpoint writes have committed.
close
[source]
Wait for pending writes and release checkpoint backend resources idempotently.
Orbax implementation
OrbaxCheckpointIO
[source]
Manage lazily opened asynchronous full-state checkpoints with Orbax.
The backend never deletes checkpoints on its own. :class:~phijax.callbacks.ModelCheckpoint owns retention through
save_top_k, as Lightning's checkpoint callback does.
Initialize an Orbax checkpoint manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
str | Path
|
Checkpoint-root directory. |
required |
enable_async_checkpointing
|
bool
|
Whether saves may finish in a background thread. |
True
|
latest_step
property
Return the latest committed checkpoint step.
Returns:
| Type | Description |
|---|---|
int | None
|
Latest step, or |
steps
property
Return committed checkpoint steps in ascending order.
Returns:
| Type | Description |
|---|---|
tuple[int, ...]
|
Ordered committed steps. |
save
[source]
save(
state: TrainState,
step: int,
metrics: Mapping[str, float] | None = None,
*,
force: bool = False,
callback_states: Mapping[str, Mapping[str, Any]]
| None = None,
) -> bool
Submit a complete training state for checkpointing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
TrainState
|
Full functional training state. |
required |
step
|
int
|
Unique checkpoint step. |
required |
metrics
|
Mapping[str, float] | None
|
Optional host scalar metrics used by Orbax retention policies. |
None
|
force
|
bool
|
Whether to save independently of manager policies. |
False
|
callback_states
|
Mapping[str, Mapping[str, Any]] | None
|
Optional callback states restored before fit-start hooks. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
Whether Orbax initiated a save. |
checkpoint_path
[source]
Return the filesystem path associated with a checkpoint step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step
|
int
|
Committed checkpoint step. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Expected Orbax step directory. |
delete
[source]
Delete one committed checkpoint and wait for completion.
Deleting a step that is not stored is a no-op.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step
|
int
|
Checkpoint step to remove. |
required |
restore
[source]
Restore a complete state for exact training resumption.
The restored input_statistics and input_periods come from the checkpoint, whatever the template holds.
Checkpoints written before PhiJAX stored them (schema 2) keep the template's values and emit a warning.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
TrainState
|
Abstract or concrete state defining the expected structure and sharding. |
required |
step
|
int | None
|
Checkpoint step, or |
None
|
Returns:
| Type | Description |
|---|---|
TrainState
|
Restored model, optimizer, balancer, PRNG, step, precision, input-statistics, and input-period state. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If no requested checkpoint exists. |
restore_input_statistics
[source]
Read only the stored input statistics as host NumPy arrays.
Use this to give a transfer-learning DataModule the source model's statistics, or a per-axis mix, from
:meth:~phijax.data.PhiDataModule.input_statistics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step
|
int | None
|
Checkpoint step, or |
None
|
Returns:
| Type | Description |
|---|---|
InputStatistics | None
|
Stored |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If no requested checkpoint exists. |
ValueError
|
If the checkpoint manifest is absent or incompatible with this runtime. |
LegacyCheckpointError
|
If the checkpoint predates stored input statistics. |
restore_input_periods
[source]
Read the stored physical periods of periodic input axes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step
|
int | None
|
Checkpoint step, or |
None
|
Returns:
| Type | Description |
|---|---|
ResolvedInputPeriods | None
|
Stored |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If no requested checkpoint exists. |
ValueError
|
If the checkpoint manifest is absent or incompatible with this runtime. |
LegacyCheckpointError
|
If the checkpoint predates stored input periods. |
restore_model_state
[source]
Restore only the model state, without reading optimizer, balancer, or run state.
Prediction and weights-only transfer use this, so the template needs no optimizer or balancer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
Any
|
Model-state PyTree defining the expected structure, dtypes, and sharding. Abstract
|
required |
step
|
int | None
|
Checkpoint step, or |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
Restored model state with the structure and sharding of |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If no requested checkpoint exists. |
ValueError
|
If the manifest is incompatible, or the stored model state differs from |
restore_callback_states
[source]
Restore JSON-compatible callback states from checkpoint metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step
|
int | None
|
Checkpoint step, or |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Mapping[str, Any]]
|
Stable callback identifier mapping. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If no requested checkpoint exists. |
ValueError
|
If callback metadata is malformed. |
wait_until_finished
[source]
Block until all asynchronous checkpoint writes have committed.
__enter__
[source]
Enter a checkpoint-manager context.
Returns:
| Type | Description |
|---|---|
OrbaxCheckpointIO
|
This checkpoint manager. |
__exit__
[source]
Close the manager when leaving a context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exception_type
|
Any
|
Active exception type, if any. |
required |
exception
|
Any
|
Active exception instance, if any. |
required |
traceback
|
Any
|
Active traceback, if any. |
required |
With asynchronous saving, teardown waits for pending writes and closes Orbax before Trainer.fit() returns. The
backend reopens when the same Trainer starts another fit or restore task. Applications do not need to call
Trainer.close().
Configure saving
Save the state at a fixed interval and keep the latest three checkpoints:
from phijax.callbacks import ModelCheckpoint
from phijax.training import OrbaxCheckpointIO
checkpoint_io = OrbaxCheckpointIO(output_directory / "checkpoints", enable_async_checkpointing=True)
checkpoint_callback = ModelCheckpoint(
checkpoint_io,
every_n_steps=5_000,
monitor="step",
mode="max",
save_top_k=3,
save_last=True,
)
Omit monitor, mode, and save_top_k to keep only the latest checkpoint.
Monitor any scalar metric available after module and callback metric collection to keep the best checkpoints:
checkpoint_callback = ModelCheckpoint(
checkpoint_io,
every_n_steps=1_000,
monitor="train/loss",
mode="min",
save_top_k=3,
save_last=True,
)
Equal scores do not displace an already retained checkpoint. When a better checkpoint enters a full top-k set, the
deterministic worst entry is removed through the backend. The checkpoint at last_model_path is never removed by
top-k ranking. Callback state is stored under stable callback identifiers and restored before fit-start hooks.
Resuming with a different set of callbacks follows Lightning:
- Callbacks without stored state, such as callbacks added since the checkpoint was written, start fresh.
- Stored state for a callback the Trainer no longer has is skipped with a
UserWarning. Stateless callbacks, such as progress bars, store no state and never trigger the warning. - A callback that rejects its stored state raises instead of applying a partial restoration.
Identifiers combine the callback class with its position among callbacks of the same class. Keep callbacks of the same class in the same order when resuming.
Restore behavior
restore_checkpoint
[source]
restore_checkpoint(
target: TrainState,
ckpt_path: str | Path | None,
*,
weights_only: bool = False,
step: int | None = None,
) -> TrainState
Optionally restore full training state or model weights from a checkpoint root.
A missing path is the fresh-training case and returns target unchanged. Full restoration resumes model,
optimizer, balancer, PRNG, precision, and step state. Weights-only restoration supports transfer learning while
retaining every non-model field from target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
TrainState
|
Fresh state providing the expected checkpoint structure. |
required |
ckpt_path
|
str | Path | None
|
Orbax checkpoint-root directory, or |
required |
weights_only
|
bool
|
Whether to restore only |
False
|
step
|
int | None
|
Specific checkpoint step, or |
None
|
Returns:
| Type | Description |
|---|---|
TrainState
|
Unchanged fresh state, fully resumed state, or weights-initialized fresh state. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If restoration options are supplied without a path, the path is empty, or |
FileNotFoundError
|
If the requested checkpoint does not exist. |
| Mode | Restored state | Input statistics |
|---|---|---|
| Full resume | Model, optimizer, balancer, all PRNG streams, step, and precision fields | Checkpoint |
weights_only=True |
Model state only; the template's optimizer and balancer may differ | Target |
ckpt_path=None |
Target is returned unchanged | Target |
Training accepts ckpt_path=None for fresh initialization. Standalone prediction requires a checkpoint root. An
explicit step chooses an exact committed step; None selects the latest.
Trainer.fit(..., ckpt_path=...) restores the full state by default. Set weights_only=True to load only model
weights, or set ckpt_path="last" to use the latest checkpoint from the configured callback; while none exists, fit()
warns and starts fresh. Prediction needs weights, so predict(..., ckpt_path="last") raises instead.
Trainer.predict(module, ckpt_path=...) builds the module's model with the checkpoint's input statistics and periods
and restores only its model state. Use restore_checkpoint() directly only when managing state outside the Trainer.
Model weights only
A weights-only restore reads only model_state. The optimizer, balancer, and run state never leave the checkpoint, so
Trainer.fit(..., weights_only=True) works after switching, for example, from Adam to SGD. The model itself must match:
a different structure, shape, or dtype raises ValueError.
To load trained weights outside the Trainer, pass a model-state template to
load_model_state():
from dataclasses import replace
from phijax.training import load_model_state
# `state` is a fresh TrainState for the same model; only its `model_state` is replaced.
state = replace(state, model_state=load_model_state("runs/source/checkpoints", state.model_state))
The template sets where the restored arrays live. Concrete arrays keep their sharding; abstract
jax.ShapeDtypeStruct leaves need a sharding, or the result holds NumPy arrays.
load_model_state
[source]
Read the model state stored in a checkpoint without restoring optimizer, balancer, or run state.
Use this to load trained weights outside the Trainer, for example into a fresh state with another optimizer:
replace(state, model_state=load_model_state(path, state.model_state)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ckpt_path
|
str | Path
|
Orbax checkpoint-root directory. |
required |
target
|
Any
|
Model-state PyTree defining the expected structure, dtypes, and sharding. Abstract
|
required |
step
|
int | None
|
Checkpoint step, or |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
Restored model state with the structure and sharding of |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the requested checkpoint does not exist. |
ValueError
|
If the manifest is incompatible, or the stored model state differs from |
Input normalization statistics
TrainState stores the statistics returned by
PhiDataModule.input_statistics() as
InputStatistics, so checkpoints keep the normalization the model was trained with.
The statistics are never differentiated or updated by the optimizer. TrainState.input_periods records the
physical periods the model applies with the same rules, except that periods configured in
periodic_features_kwargs always win; see periodic features.
| Task | Statistics used |
|---|---|
Trainer.fit() without a checkpoint |
Current DataModule |
Trainer.fit() full resume |
Checkpoint; the module is rebound before training starts |
Trainer.fit(..., weights_only=True) |
Current DataModule (the transfer target) |
Trainer.predict(..., ckpt_path=...) |
Checkpoint; the module is built or rebound for them |
Transfer learning uses the target statistics by default. To start from the source model's statistics, or to mix them
per coordinate, return load_input_statistics() from the target DataModule:
from phijax.data import input_statistics
from phijax.training import load_input_statistics
# Subclass the application's existing DataModule and override only its statistics.
class TransferDataModule(ApplicationDataModule):
def input_statistics(self):
source = load_input_statistics("runs/source/checkpoints")
# Coordinates are ordered `[x, y, t]`: keep the source spatial statistics, normalize time with target data.
mean, std = input_statistics(self.normalization_pools())
mean[:-1], std[:-1] = source.mean[:-1], source.std[:-1]
return mean, std
InputStatistics
[source]
Bases: NamedTuple
Hold per-coordinate model-input normalization statistics.
The Trainer stores the statistics in :class:phijax.training.TrainState so checkpoints restore the normalization
a model was trained with. A NamedTuple keeps tuple unpacking, mean, std = statistics, working.
Attributes:
| Name | Type | Description |
|---|---|---|
mean |
Any
|
Per-coordinate mean with shape |
std |
Any
|
Per-coordinate standard deviation with shape |
load_input_statistics
[source]
load_input_statistics(
ckpt_path: str | Path, *, step: int | None = None
) -> InputStatistics | None
Read the input statistics stored in a checkpoint without restoring the training state.
Weights-only restoration (transfer learning) uses the current DataModule's statistics. To start from the source
model's statistics instead, or to mix them per axis, return this function's result from
:meth:~phijax.data.PhiDataModule.input_statistics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ckpt_path
|
str | Path
|
Orbax checkpoint-root directory. |
required |
step
|
int | None
|
Checkpoint step, or |
None
|
Returns:
| Type | Description |
|---|---|
InputStatistics | None
|
Stored statistics as host |
InputStatistics | None
|
normalization. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the requested checkpoint does not exist. |
ValueError
|
If the checkpoint manifest is absent or incompatible with this runtime. |
LegacyCheckpointError
|
If the checkpoint was written before PhiJAX stored input statistics. |
LegacyCheckpointError
[source]
Bases: LookupError
Report that a checkpoint predates stored input statistics and periods.
Checkpoints written by PhiJAX 0.2.0b5 and earlier (schema 2) store neither, so "none stored" cannot be told apart
from a model trained without normalization or periodic features. Take the values from the training DataModule
instead. Custom :class:~phijax.callbacks.CheckpointIO backends raise this error for the same case.
Checkpoint schema
PhiJAX 0.2 checkpoints use schema version 3, which adds TrainState.input_statistics. Schema-2 checkpoints, written by
PhiJAX 0.2.0b5 and earlier, still restore. They do not contain statistics, so the restored state keeps the template's
statistics, which the Trainer takes from the current DataModule, and PhiJAX emits a UserWarning. Reading their inputs
alone raises LegacyCheckpointError, because "none stored" cannot be told
apart from a model trained without normalization. Trainer.predict(module, ckpt_path=...) then sets up the fit stage
of datamodule and uses its statistics and periods, with a warning; a FitResult keeps its module's values. PhiJAX 0.1
checkpoints remain readable by 0.1; 0.2 rejects them rather than partially restoring incompatible state.
Each manifest also stores an identifier of the model-state structure, which model-only restores check. Checkpoints written before PhiJAX 0.2.0b6 lack it; Orbax still rejects a model whose stored shapes differ.