pub struct DraftModelSpeculator { /* private fields */ }Expand description
Implementations§
Source§impl DraftModelSpeculator
impl DraftModelSpeculator
Sourcepub fn keeps_host_kv(&self) -> bool
pub fn keeps_host_kv(&self) -> bool
True when this drafter’s KV really lives in the host caches it owns.
A backend that keeps KV on the device leaves these at zero, and a drafter cannot roll back rows it cannot see. Callers check this after one warm-up rather than discovering it as a wrong accept rate.
Sourcepub fn synced_len(&self) -> usize
pub fn synced_len(&self) -> usize
How many tokens of history this drafter’s KV currently holds. Exposed so a caller can assert the drafter kept up.
Sourcepub fn new(
decoder: Decoder,
target_config: &ModelConfig,
sampling: SamplingParams,
seed: u64,
max_draft: usize,
min_prob: f32,
) -> Result<Self, VocabMismatch>
pub fn new( decoder: Decoder, target_config: &ModelConfig, sampling: SamplingParams, seed: u64, max_draft: usize, min_prob: f32, ) -> Result<Self, VocabMismatch>
Fails when the two checkpoints cannot be compared token for
token. See VocabMismatch.
Trait Implementations§
Source§impl Drafter for DraftModelSpeculator
impl Drafter for DraftModelSpeculator
Source§fn propose(
&mut self,
history: &[usize],
_target_hidden: &[f32],
max_len: usize,
) -> DraftBlock
fn propose( &mut self, history: &[usize], _target_hidden: &[f32], max_len: usize, ) -> DraftBlock
Proposes at most
max_len tokens to follow history.
target_hidden is the target model’s final-layer hidden state
for history’s last token, or empty when none is available yet
(which a drafter that needs it must handle by proposing
nothing).
Takes &mut self because a drafter that is itself a model
carries KV state across calls, and hiding that behind interior
mutability would put a runtime borrow check on the hot path to
buy nothing. A stateless drafter simply ignores it.Auto Trait Implementations§
impl !Freeze for DraftModelSpeculator
impl RefUnwindSafe for DraftModelSpeculator
impl Send for DraftModelSpeculator
impl Sync for DraftModelSpeculator
impl Unpin for DraftModelSpeculator
impl UnsafeUnpin for DraftModelSpeculator
impl UnwindSafe for DraftModelSpeculator
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
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