Skip to content

Pr 2352 ci branch #2382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion backends/v3/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ pub(crate) async fn batching_task(
};

let token_budget = max_batch_total_tokens.saturating_sub(batch_max_tokens);
let max_size = max_batch_size.map(|max_size| max_size - batch_size as usize);
let max_size =
max_batch_size.map(|max_size| max_size.saturating_sub(batch_size as usize));

// Try to get a new batch
if let Some((mut new_entries, new_batch, span)) = queue
Expand Down
8 changes: 8 additions & 0 deletions backends/v3/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@ async fn main() -> Result<(), RouterError> {
}
}

if let Some(max_batch_size) = max_batch_size {
if max_batch_size == 0 {
return Err(RouterError::ArgumentValidation(
"`max_batch_size` must be > 0".to_string(),
));
}
}

let (backend, _backend_info) = connect_backend(
max_input_tokens,
max_total_tokens,
Expand Down
7 changes: 7 additions & 0 deletions backends/v3/src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,13 @@ impl State {
}
}

if let Some(max_size) = max_size {
if max_size == 0 {
tracing::debug!("No capacity");
return None;
}
}

// Pad prefill_token_budget to be a multiple of block size
let prefill_token_budget =
((prefill_token_budget + self.block_size - 1) / self.block_size) * self.block_size;
Expand Down
7 changes: 7 additions & 0 deletions router/src/infer/v2/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ impl State {
}
}

if let Some(max_size) = max_size {
if max_size == 0 {
tracing::debug!("No capacity");
return None;
}
}

// Pad prefill_token_budget to be a multiple of block size
let prefill_token_budget =
((prefill_token_budget + self.block_size - 1) / self.block_size) * self.block_size;
Expand Down
4 changes: 2 additions & 2 deletions router/src/infer/v2/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ pub(crate) async fn batching_task(
};

let token_budget = max_batch_total_tokens.saturating_sub(batch_max_tokens);
let max_size = max_batch_size.map(|max_size| max_size - batch_size as usize);

let max_size =
max_batch_size.map(|max_size| max_size.saturating_sub(batch_size as usize));
// Try to get a new batch
if let Some((mut new_entries, new_batch, span)) = queue
.next_batch(min_size, max_size, max_batch_prefill_tokens, token_budget)
Expand Down
Loading