pub struct ModelWarmup {
pub num_warmup_tokens: usize,
pub warmup_prompt: String,
}Expand description
Runs a small number of dummy inference passes on a freshly-initialised
InferenceEngine to prime internal allocation caches and JIT paths
before the first real request arrives.
Fields§
§num_warmup_tokens: usizeNumber of tokens to generate during the warmup pass.
warmup_prompt: StringPrompt text fed to the engine during warmup.
Implementations§
Source§impl ModelWarmup
impl ModelWarmup
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a warmup helper with sensible defaults (32 tokens, generic prompt).
Sourcepub fn with_tokens(self, n: usize) -> Self
pub fn with_tokens(self, n: usize) -> Self
Override the number of warmup tokens.
Sourcepub fn with_prompt(self, p: &str) -> Self
pub fn with_prompt(self, p: &str) -> Self
Override the warmup prompt text.
Sourcepub fn run(
&self,
engine: &mut InferenceEngine<'_>,
params: &SamplingParams,
) -> u64
pub fn run( &self, engine: &mut InferenceEngine<'_>, params: &SamplingParams, ) -> u64
Execute the warmup passes on engine using params.
Generates up to ModelWarmup::num_warmup_tokens tokens from a small
synthetic token sequence and discards the output. Returns the elapsed
wall-clock time in milliseconds.
Errors from the engine are logged as warnings but do not propagate — warmup failure is non-fatal.
Sourcepub fn needs_warmup(_engine: &InferenceEngine<'_>) -> bool
pub fn needs_warmup(_engine: &InferenceEngine<'_>) -> bool
Heuristic: should this engine be warmed up?
The current implementation always returns true — callers are
responsible for deciding when to apply warmup (e.g. once after initial
load, or after a cache miss).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ModelWarmup
impl RefUnwindSafe for ModelWarmup
impl Send for ModelWarmup
impl Sync for ModelWarmup
impl Unpin for ModelWarmup
impl UnsafeUnpin for ModelWarmup
impl UnwindSafe for ModelWarmup
Blanket Implementations§
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
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