Skip to main content

restore_cache_checkpoint

Function restore_cache_checkpoint 

Source
pub fn restore_cache_checkpoint(
    e: &Engine,
    cfg: &ModelConfig,
    source: Option<&Cache>,
    target: &mut Cache,
    snap: &CacheSnapshot,
) -> Result<(), Box<dyn Error>>
Expand description

Restore a cache checkpoint through each layer’s owning engine.

source = None is an in-place rewind: the target already owns the append-only KV bytes and only its lengths plus recurrent state move back to the snapshot. Some(source) restores into a freshly allocated larger cache: checkpoint-valid KV rows are copied from the parked cache, while recurrent state always comes from the checkpoint’s owned device copies.

This cannot use Cache::rollback(e, ...) under cross-device PP: a single primary engine is not the owner of every stage’s cache buffers. The rare rewind/grow boundary synchronizes open PP contexts before publishing the restored cache to the next request.