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
impl Drafter
Sourcepub fn beside(main: &Path) -> Option<Result<Self, String>>
pub fn beside(main: &Path) -> Option<Result<Self, String>>
The drafter of main’s sidecar, when it has one.
Sourcepub fn for_target(main: &CmfModel) -> Option<Result<Self, String>>
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.
pub fn new(model: Arc<CmfModel>) -> Result<Self, String>
Sourcepub fn host_only(&mut self)
pub fn host_only(&mut self)
Keep every matrix on the host (a parity check, a device that is busy).
Sourcepub fn next_position(&self) -> usize
pub fn next_position(&self) -> usize
The position the next context row belongs to.
Sourcepub fn span(&self) -> (usize, usize)
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).
pub fn reset(&mut self)
Sourcepub fn truncate(&mut self, pos: usize)
pub fn truncate(&mut self, pos: usize)
Forget the context from position pos on (a rewind of the target).
Sourcepub fn context(&self, layer: usize, kv_head: usize) -> (&[f32], &[f32])
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.
Sourcepub fn push_context(&mut self, pos: usize, taps: &[f32], pool: Option<&Pool>)
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.
Sourcepub fn queue_context(&mut self, pos: usize, taps: &[f32], pool: Option<&Pool>)
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.
Sourcepub fn block(
&self,
anchor_pos: usize,
h: Vec<f32>,
pool: Option<&Pool>,
) -> Vec<f32>
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.
Sourcepub fn select(
&self,
hidden: &[f32],
logits: &[f32],
anchor: u32,
) -> (Vec<u32>, Vec<u32>)
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.