Table of Contents

Method HibernateAsync

Namespace
LMKit.Inference
Assembly
LM-Kit.NET.dll

HibernateAsync(string)

Schedules hibernation of the inference context on a background thread and returns a task representing its completion.

Task HibernateAsync(string filePath = null)

Parameters

filePath string

Destination file path for the serialized state. When null or empty, a unique file is generated inside the directory configured by ContextHibernationDirectory, which itself defaults to the system temp folder (GetTempPath()) when not set.

Returns

Task

A task that completes once the context has been hibernated to disk.

Remarks

Hibernation serializes the full KV-cache and associated context state to disk and frees the in-memory handle. The state is rehydrated transparently on the next operation that requires the context, preserving the conversation or inference session without any caller action.

Callers may ignore the returned task for fire-and-forget semantics, or await it to block until the hibernation has finished. If a prior hibernation is already pending or in flight, the same task is returned (requests are coalesced).

The background worker defers execution until every active usage lock on the underlying context has been released, so calling this method while the context is in use is safe.

Share