pub struct SpeculativeRunner<'a> {
pub draft: &'a dyn ModelExecutor,
pub target: &'a dyn ModelExecutor,
pub tensor_factory: Arc<dyn TensorFactory>,
pub cfg: SpeculativeDecodingConfig,
}Expand description
Drives one round of speculative decoding against a (draft, target) pair
of ModelExecutors. Owns neither executor — the engine keeps them and
hands references per call.
Usage per decode iteration:
- Caller hands the runner the last sampled token for this request, plus the draft & target KV cache handles.
step()runs N draft decodes, N+1 target decodes (sequentially for now — performance gain lands once the executors grow multi-position decode support), then appliesverify_speculation.- Returns the list of newly accepted tokens plus the updated KV handles for draft and target (caller installs them on the sequence state for the next iteration).
Fields§
§draft: &'a dyn ModelExecutor§target: &'a dyn ModelExecutor§tensor_factory: Arc<dyn TensorFactory>§cfg: SpeculativeDecodingConfigImplementations§
Source§impl<'a> SpeculativeRunner<'a>
impl<'a> SpeculativeRunner<'a>
Sourcepub async fn step(
&self,
last_token: TokenId,
draft_kv: Arc<dyn KvCacheHandle>,
target_kv: Arc<dyn KvCacheHandle>,
rng: &mut (dyn RngCore + Send),
) -> Result<SpeculativeStepOutcome>
pub async fn step( &self, last_token: TokenId, draft_kv: Arc<dyn KvCacheHandle>, target_kv: Arc<dyn KvCacheHandle>, rng: &mut (dyn RngCore + Send), ) -> Result<SpeculativeStepOutcome>
Run one draft+verify cycle. last_token is the token that was sampled
from the previous iteration (or the end of prefill) — it’s the
starting point both executors advance from.
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for SpeculativeRunner<'a>
impl<'a> !UnwindSafe for SpeculativeRunner<'a>
impl<'a> Freeze for SpeculativeRunner<'a>
impl<'a> Send for SpeculativeRunner<'a>
impl<'a> Sync for SpeculativeRunner<'a>
impl<'a> Unpin for SpeculativeRunner<'a>
impl<'a> UnsafeUnpin for SpeculativeRunner<'a>
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
Mutably borrows from an owned value. Read more
impl<T> ErasedDestructor for Twhere
T: 'static,
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> ⓘ
Converts
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> ⓘ
Converts
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