Skip to main content

Drafter

Struct Drafter 

Source
pub struct Drafter {
    pub g: Geometry,
    pub route: Option<Route>,
    /* private fields */
}

Fields§

§g: Geometry§route: Option<Route>

The sidecar’s router, when it carries one.

Implementations§

Source§

impl Drafter

Source

pub fn beside(main: &Path) -> Option<Result<Self, String>>

The drafter of main’s sidecar, when it has one.

Source

pub fn for_target(main: &CmfModel) -> Option<Result<Self, String>>

The drafter of main’s sidecar when there is one: it must have been converted for this very trunk.

Source

pub fn new(model: Arc<CmfModel>) -> Result<Self, String>

Source

pub fn host_only(&mut self)

Keep every matrix on the host (a parity check, a device that is busy).

Source

pub fn next_position(&self) -> usize

The position the next context row belongs to.

Source

pub fn span(&self) -> (usize, usize)

The positions the context covers: its first, and one past its last (rows that wait to be settled included).

Source

pub fn reset(&mut self)

Source

pub fn truncate(&mut self, pos: usize)

Forget the context from position pos on (a rewind of the target).

Source

pub fn context(&self, layer: usize, kv_head: usize) -> (&[f32], &[f32])

A layer’s keys and values of the positions it holds, for one KV head: rows of head_dim, the last of them the last settled position’s.

Source

pub fn push_context(&mut self, pos: usize, taps: &[f32], pool: Option<&Pool>)

Add the target’s rows of positions pos .. to the context: taps is n rows of the tapped layers’ outputs, joined in the order of Geometry::taps. Rows at positions already held replace them and what follows; a gap starts the context over.

Source

pub fn queue_context(&mut self, pos: usize, taps: &[f32], pool: Option<&Pool>)

push_context put off: the rows wait until a block is about to read them (settle), so a target that decodes a stretch without this drafter pays nothing for them. At most PENDING_ROWS wait; past that the oldest go through the drafter’s matrices a batch at a time.

Source

pub fn settle(&mut self, pool: Option<&Pool>)

Make every waiting row context.

Source

pub fn block( &self, anchor_pos: usize, h: Vec<f32>, pool: Option<&Pool>, ) -> Vec<f32>

One block: the rows [anchor, MASK…] at positions anchor_pos .., from their embeddings h (block rows of hidden). Returns every row after the last norm; row j ≥ 1 drafts the token at anchor_pos + j.

Source

pub fn select( &self, hidden: &[f32], logits: &[f32], anchor: u32, ) -> (Vec<u32>, Vec<u32>)

The drafted tokens of the rows hidden (rows of the block after the anchor’s, after the last norm) from their logits under the target’s head: each row’s top candidates re-scored against the token chosen before it, starting from the anchor. The logits may cover only the head’s first rows (a shortlist of the vocabulary). Returns the chosen tokens and, for reference, every row’s own top token.

Source

pub fn select_with( &self, hp: &[f32], logits: &[f32], anchor: u32, n: usize, ) -> (Vec<u32>, Vec<u32>)

select with the selector’s projection of the rows already made (hp, n rows of selector_rank).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more