pub trait BackendSession<B: BackendProvider> {
type PrefillInput;
type DecodeInput;
type Output;
type Completion: Completion<Error = B::Error>;
// Required methods
fn capabilities(&self) -> SessionCapabilities;
fn prefill(
&mut self,
backend: &B,
input: Self::PrefillInput,
) -> Result<Submission<Self::Output, Self::Completion>, B::Error>;
fn decode(
&mut self,
backend: &B,
input: Self::DecodeInput,
) -> Result<Submission<Self::Output, Self::Completion>, B::Error>;
fn observe_output(
&self,
backend: &B,
output: &Self::Output,
) -> Result<ObservationSet, B::Error>;
}Expand description
Prefill/decode interface for an already selected backend session.
The session owns its prepared executable and cache. The contract intentionally models language-model submissions rather than primitive tensor operations. Input, output, cache and completion stay opaque.
Required Associated Types§
Sourcetype PrefillInput
type PrefillInput
Backend-owned prefill input.
Sourcetype DecodeInput
type DecodeInput
Backend-owned decode input.
Sourcetype Completion: Completion<Error = B::Error>
type Completion: Completion<Error = B::Error>
Exact completion type.
Required Methods§
Sourcefn capabilities(&self) -> SessionCapabilities
fn capabilities(&self) -> SessionCapabilities
Reports capabilities of this exact realized session.
Sourcefn prefill(
&mut self,
backend: &B,
input: Self::PrefillInput,
) -> Result<Submission<Self::Output, Self::Completion>, B::Error>
fn prefill( &mut self, backend: &B, input: Self::PrefillInput, ) -> Result<Submission<Self::Output, Self::Completion>, B::Error>
Submits prompt prefill against this session.
Sourcefn decode(
&mut self,
backend: &B,
input: Self::DecodeInput,
) -> Result<Submission<Self::Output, Self::Completion>, B::Error>
fn decode( &mut self, backend: &B, input: Self::DecodeInput, ) -> Result<Submission<Self::Output, Self::Completion>, B::Error>
Submits one or more cached decode positions against this session.
Sourcefn observe_output(
&self,
backend: &B,
output: &Self::Output,
) -> Result<ObservationSet, B::Error>
fn observe_output( &self, backend: &B, output: &Self::Output, ) -> Result<ObservationSet, B::Error>
Materializes an already completed opaque output into portable records.
Calling this method is an explicit synchronization and host-transfer boundary. Ordinary inference does not invoke it.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".