Skip to content

Commit

Permalink
Add Scheduler::running_len (#780)
Browse files Browse the repository at this point in the history
  • Loading branch information
EricLBuehler authored Sep 18, 2024
1 parent eadebac commit 2df0044
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion mistralrs-core/src/dummy_paged_attention/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,10 @@ impl Scheduler for PagedAttentionScheduler {
}
}
fn waiting_len(&self) -> usize {
self.waiting.len()
self.waiting.len() + self.swapped_out.len()
}
fn running_len(&self) -> usize {
self.running.len()
}
fn block_tables(&self) -> Option<&BlockTables> {
Some(&self.block_engine.block_tables)
Expand Down
5 changes: 4 additions & 1 deletion mistralrs-core/src/paged_attention/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,10 @@ impl Scheduler for PagedAttentionScheduler {
}
}
fn waiting_len(&self) -> usize {
self.waiting.len()
self.waiting.len() + self.swapped_out.len()
}
fn running_len(&self) -> usize {
self.running.len()
}
fn block_tables(&self) -> Option<&BlockTables> {
Some(&self.block_engine.block_tables)
Expand Down
3 changes: 3 additions & 0 deletions mistralrs-core/src/scheduler/default_scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ impl Scheduler for DefaultScheduler<VecDeque<Sequence>> {
fn waiting_len(&self) -> usize {
self.waiting.len()
}
fn running_len(&self) -> usize {
self.running.len()
}
fn add_seq(&mut self, seq: Sequence) {
if seq.is_running() {
// prefill case
Expand Down
1 change: 1 addition & 0 deletions mistralrs-core/src/scheduler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub enum SchedulerOutput<'a> {
pub trait Scheduler {
fn schedule(&mut self) -> SchedulerOutput<'_>;
fn waiting_len(&self) -> usize;
fn running_len(&self) -> usize;
fn add_seq(&mut self, seq: Sequence);
/// This may do nothing. It depends on the implementation
fn free_finished_sequence_groups(&mut self);
Expand Down

0 comments on commit 2df0044

Please sign in to comment.