pub struct ContinuousBatchScheduler {
pub max_concurrent: usize,
pub max_queue_size: usize,
/* private fields */
}Expand description
Continuous-batch scheduler.
Manages request lifecycle from submission through generation to completion, interleaving multiple requests at the token level.
Fields§
§max_concurrent: usizeMaximum number of requests decoding simultaneously.
max_queue_size: usizeMaximum number of requests that may wait in the queue.
Implementations§
Source§impl ContinuousBatchScheduler
impl ContinuousBatchScheduler
Sourcepub fn new(max_concurrent: usize, max_queue_size: usize) -> Self
pub fn new(max_concurrent: usize, max_queue_size: usize) -> Self
Create a new scheduler.
max_concurrent — at most this many requests decode in parallel.
max_queue_size — queue rejects new submissions beyond this count.
Sourcepub fn submit(
&mut self,
prompt_tokens: Vec<u32>,
params: SamplingParams,
max_tokens: usize,
) -> Result<u64, SchedulerError>
pub fn submit( &mut self, prompt_tokens: Vec<u32>, params: SamplingParams, max_tokens: usize, ) -> Result<u64, SchedulerError>
Submit a request with Normal priority.
Returns the assigned request ID, or SchedulerError::QueueFull if the
waiting queue is already at capacity.
Sourcepub fn submit_with_priority(
&mut self,
prompt_tokens: Vec<u32>,
params: SamplingParams,
max_tokens: usize,
priority: RequestPriority,
) -> Result<u64, SchedulerError>
pub fn submit_with_priority( &mut self, prompt_tokens: Vec<u32>, params: SamplingParams, max_tokens: usize, priority: RequestPriority, ) -> Result<u64, SchedulerError>
Submit a request with an explicit priority.
Sourcepub fn step(&mut self, engine: &mut InferenceEngine<'_>)
pub fn step(&mut self, engine: &mut InferenceEngine<'_>)
Advance one iteration of the batch.
- Promotes waiting requests into the active set until
max_concurrentslots are full (or the queue is drained). - Steps every active request by generating one token.
- Moves finished requests to the completed list.
Sourcepub fn run_to_completion(&mut self, engine: &mut InferenceEngine<'_>)
pub fn run_to_completion(&mut self, engine: &mut InferenceEngine<'_>)
Run all pending and active requests to completion, blocking until the scheduler is idle.
Sourcepub fn get_result(&self, id: u64) -> Option<&BatchRequest>
pub fn get_result(&self, id: u64) -> Option<&BatchRequest>
Look up a completed (or failed) request by ID.
Returns None if the request is still waiting/decoding or does not exist.
Sourcepub fn queue_depth(&self) -> usize
pub fn queue_depth(&self) -> usize
Number of requests currently waiting in the queue.
Sourcepub fn active_count(&self) -> usize
pub fn active_count(&self) -> usize
Number of requests currently being decoded.
Sourcepub fn completed_count(&self) -> usize
pub fn completed_count(&self) -> usize
Number of completed (or failed) requests.
Sourcepub fn throughput_stats(&self) -> SchedulerStats
pub fn throughput_stats(&self) -> SchedulerStats
Snapshot of current throughput statistics.
Sourcepub fn drain_completed(&mut self) -> Vec<BatchRequest>
pub fn drain_completed(&mut self) -> Vec<BatchRequest>
Remove and return all completed requests, clearing the completed list.
Auto Trait Implementations§
impl Freeze for ContinuousBatchScheduler
impl RefUnwindSafe for ContinuousBatchScheduler
impl Send for ContinuousBatchScheduler
impl Sync for ContinuousBatchScheduler
impl Unpin for ContinuousBatchScheduler
impl UnsafeUnpin for ContinuousBatchScheduler
impl UnwindSafe for ContinuousBatchScheduler
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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>
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>
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