pub struct InferenceQueue { /* private fields */ }Expand description
High-level inference request queue wrapping BoundedQueue<InferenceWorkItem>.
Each call to InferenceQueue::submit returns a std::sync::mpsc::Receiver
through which the caller can retrieve the generated token IDs once inference
completes. Returns None immediately if the queue is full (backpressure).
Implementations§
Source§impl InferenceQueue
impl InferenceQueue
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Create a new inference queue with the given maximum pending-request capacity.
Sourcepub fn submit(
&self,
prompt_tokens: Vec<u32>,
max_tokens: usize,
params: SamplingParams,
) -> Option<Receiver<Vec<u32>>>
pub fn submit( &self, prompt_tokens: Vec<u32>, max_tokens: usize, params: SamplingParams, ) -> Option<Receiver<Vec<u32>>>
Submit an inference request.
Returns a Receiver that will yield the generated token IDs once the
request is processed, or None if the queue is full.
Sourcepub fn queue_depth(&self) -> usize
pub fn queue_depth(&self) -> usize
Number of pending requests currently in the queue.
Sourcepub fn stats(&self) -> QueueStats
pub fn stats(&self) -> QueueStats
Take a statistics snapshot.
Auto Trait Implementations§
impl !Freeze for InferenceQueue
impl RefUnwindSafe for InferenceQueue
impl Send for InferenceQueue
impl Sync for InferenceQueue
impl Unpin for InferenceQueue
impl UnsafeUnpin for InferenceQueue
impl UnwindSafe for InferenceQueue
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> 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