Skip to content
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

[Serve] Make max_batch_size and batch_wait_timeout_s reconfigurable #36881

Merged
merged 18 commits into from
Jun 28, 2023

Conversation

shrekris-anyscale
Copy link
Contributor

Why are these changes needed?

The @serve.batch decorator has two parameters: max_batch_size and batch_wait_timeout_s. These parameters can be set in the decorator. However, they cannot be reconfigured after the Serve application starts.

This change adds two setter methods: set_max_batch_size and set_batch_wait_timeout_s. Users can reconfigure their @serve.batch parameters using these methods:

@serve.batch(max_batch_size=1, batch_wait_timeout_s=0.1)
def batch_handler(self, request_list):
    ...

self.batch_handler.set_max_batch_size(5)
self.batch_handler.set_batch_wait_timeout_s(0.5)

Related issue number

Closes #36844

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
      • This change adds unit tests to test_batching.py.

Signed-off-by: Shreyas Krishnaswamy <shrekris@anyscale.com>
Signed-off-by: Shreyas Krishnaswamy <shrekris@anyscale.com>
Signed-off-by: Shreyas Krishnaswamy <shrekris@anyscale.com>
Signed-off-by: Shreyas Krishnaswamy <shrekris@anyscale.com>
Signed-off-by: Shreyas Krishnaswamy <shrekris@anyscale.com>
Signed-off-by: Shreyas Krishnaswamy <shrekris@anyscale.com>
Signed-off-by: Shreyas Krishnaswamy <shrekris@anyscale.com>
Signed-off-by: Shreyas Krishnaswamy <shrekris@anyscale.com>
Signed-off-by: Shreyas Krishnaswamy <shrekris@anyscale.com>
@shrekris-anyscale
Copy link
Contributor Author

@edoakes the code changes are ready for review. I'm planning on adding doc changes to this PR soon.

Signed-off-by: Shreyas Krishnaswamy <shrekris@anyscale.com>
Signed-off-by: Shreyas Krishnaswamy <shrekris@anyscale.com>
Signed-off-by: Shreyas Krishnaswamy <shrekris@anyscale.com>
@shrekris-anyscale
Copy link
Contributor Author

@edoakes I've added documentation. This PR is ready for review end-to-end.

@shrekris-anyscale shrekris-anyscale changed the title [WIP] [Serve] Make max_batch_size and batch_wait_timeout_s reconfigurable [Serve] Make max_batch_size and batch_wait_timeout_s reconfigurable Jun 27, 2023
python/ray/serve/batching.py Outdated Show resolved Hide resolved
Copy link
Contributor

@edoakes edoakes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shrekris-anyscale can you add a sentence to the @serve.batch docstring mentioning the setters?

shrekris-anyscale and others added 2 commits June 27, 2023 15:54
Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Signed-off-by: shrekris-anyscale <92341594+shrekris-anyscale@users.noreply.github.com>
Signed-off-by: Shreyas Krishnaswamy <shrekris@anyscale.com>
@shrekris-anyscale
Copy link
Contributor Author

@edoakes Thanks, I updated the docstring. Please take a look.

python/ray/serve/batching.py Outdated Show resolved Hide resolved
shrekris-anyscale and others added 3 commits June 28, 2023 10:07
Co-authored-by: angelinalg <122562471+angelinalg@users.noreply.github.com>
Signed-off-by: shrekris-anyscale <92341594+shrekris-anyscale@users.noreply.github.com>
Signed-off-by: Shreyas Krishnaswamy <shrekris@anyscale.com>
@edoakes edoakes merged commit 39195ff into ray-project:master Jun 28, 2023
arvind-chandra pushed a commit to lmco/ray that referenced this pull request Aug 31, 2023
…le (ray-project#36881)

The `@serve.batch` decorator has two parameters: `max_batch_size` and `batch_wait_timeout_s`. These parameters can be set in the decorator. However, they cannot be reconfigured after the Serve application starts.

This change adds two setter methods: `set_max_batch_size` and `set_batch_wait_timeout_s`. Users can reconfigure their `@serve.batch` parameters using these methods:

```python
@serve.batch(max_batch_size=1, batch_wait_timeout_s=0.1)
def batch_handler(self, request_list):
    ...

self.batch_handler.set_max_batch_size(5)
self.batch_handler.set_batch_wait_timeout_s(0.5)
```

Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Co-authored-by: angelinalg <122562471+angelinalg@users.noreply.github.com>
Signed-off-by: e428265 <arvind.chandramouli@lmco.com>
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.

[Serve] Let users modify max_batch_size and batch_wait_timeout_s in @serve.batch dynamically
3 participants