pub struct GradientCheckpoint {
pub graph: ComputationGraphStore,
pub step: u64,
pub loss_cid: Option<String>,
pub optimizer_state: HashMap<String, Vec<u8>>,
pub timestamp: u64,
}Expand description
A serializable snapshot of the gradient computation state.
Contains the full ComputationGraphStore plus training metadata so that
a training run can be interrupted and resumed without recomputing the
forward pass from scratch.
Fields§
§graph: ComputationGraphStoreThe computation graph at the time of checkpointing
step: u64Optimizer step counter
loss_cid: Option<String>CID of the loss tensor (None before the first loss is computed)
optimizer_state: HashMap<String, Vec<u8>>Raw optimizer state blobs, keyed by parameter name
timestamp: u64Unix timestamp (seconds) when this checkpoint was created
Implementations§
Source§impl GradientCheckpoint
impl GradientCheckpoint
Sourcepub fn new(graph: ComputationGraphStore, step: u64) -> Self
pub fn new(graph: ComputationGraphStore, step: u64) -> Self
Create a new checkpoint at the given step.
Sourcepub fn with_loss_cid(self, cid: impl Into<String>) -> Self
pub fn with_loss_cid(self, cid: impl Into<String>) -> Self
Attach the CID of the current loss tensor.
Sourcepub fn set_optimizer_state(&mut self, param: impl Into<String>, state: Vec<u8>)
pub fn set_optimizer_state(&mut self, param: impl Into<String>, state: Vec<u8>)
Store a raw optimizer state blob for the given parameter.
Sourcepub fn save(&self, path: &Path) -> Result<(), GradientError>
pub fn save(&self, path: &Path) -> Result<(), GradientError>
Persist this checkpoint to a file at path.
The file is written as JSON so it is human-inspectable and version-control friendly.
Sourcepub fn load(path: &Path) -> Result<Self, GradientError>
pub fn load(path: &Path) -> Result<Self, GradientError>
Load a checkpoint from the file at path.
Trait Implementations§
Source§impl Debug for GradientCheckpoint
impl Debug for GradientCheckpoint
Source§impl<'de> Deserialize<'de> for GradientCheckpoint
impl<'de> Deserialize<'de> for GradientCheckpoint
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for GradientCheckpoint
impl RefUnwindSafe for GradientCheckpoint
impl Send for GradientCheckpoint
impl Sync for GradientCheckpoint
impl Unpin for GradientCheckpoint
impl UnsafeUnpin for GradientCheckpoint
impl UnwindSafe for GradientCheckpoint
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more