Skip to content
fn

overwrite_state_storage

void overwrite_state_storage(int & dst, const int & src)

Overwrite an existing state buffer in place from a saved snapshot.

Used by Optimizer::load_state_buffers to restore a checkpoint into the optimizer's live state without reallocating or rebinding any storage objects. dst keeps its identity (pointer, shape, dtype, device) — only the underlying bytes / MLX array are replaced.

See Also

clone_state_storage : produces the snapshots consumed here.

Parameters

dstStorage&
Live optimizer state buffer to update in place.
srcconst Storage&
Snapshot whose contents should be written into dst. Must be on the same device as dst and have the same byte size.

Raises

:runtime_error
If dst and src are on different devices, or if their CPU byte sizes disagree.