Skip to content

Unsigned integer underflow in max_batch_size #2352

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

Closed

Conversation

maxdebayser
Copy link
Contributor

Passing --max-batch-size to the launcher actually had no effect because after a few requests the max_size passed to State::next_batch would underflow becoming a large positive number.

In the scheduler, as soon as the cached batch size reached the max_batch_size the max_size passed to next_batch becomes 0. Since the only check in that funcion is

if Some(batch_requests.len()) == max_size {
    break;
}

and it's called after the batch_requests.len() has become 1, it doesn't do anything to prevent more than 0 requests from being batched.

Now we have cached batch in the server that is larger than max_batch_size and max_size - batch_size as usize underflows.

Passing --max-batch-size to the launcher actually had no effect
because after a few requests the max_size passed to State::next_batch
would underflow becoming a largo positive number.

In the scheduler, as soon as the cached batch size reached the
max_batch_size the max_size passed to next_batch becomes 0.
Since the only check in that funcion is
```
if Some(batch_requests.len()) == max_size {
    break;
}
```
and it's called after the `batch_requests.len()` has
become 1, it doesn't do anything to prevent more than 0
requests from being batched.

Now we have cached batch in the server that is large than
max_batch_size and `max_size - batch_size as usize`
underflows.

Signed-off-by: Max de Bayser <mbayser@br.ibm.com>
@drbh drbh mentioned this pull request Aug 8, 2024
@drbh
Copy link
Collaborator

drbh commented Aug 8, 2024

@maxdebayser thank you for pointing out this bug and the contribution!

I've opened #2382 to run CI and included a couple small changes to extend the fix to the v3 backend. All of your commits have been included in that PR, and will close this one once the other one is merged.

Thank you 🙏

@maxdebayser
Copy link
Contributor Author

Thanks @drbh , I'll close this PR then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants