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] Refactor Autoscaler for better customizability. #4008

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

cblmemo
Copy link
Collaborator

@cblmemo cblmemo commented Sep 27, 2024

This PR refactored the inheritance relation of the Autoscalers we have, to minimize the number of functions users needs to override in a customize autoscaler.

TODO: Run all smoke tests.

Tested (run the relevant ones):

  • Code formatting: bash format.sh
  • Any manual or new tests for this PR (please specify below)
  • All smoke tests: pytest tests/test_smoke.py
  • Relevant individual smoke tests: pytest tests/test_smoke.py::test_fill_in_the_name
  • Backward compatibility tests: conda deactivate; bash -i tests/backward_compatibility_tests.sh

@cblmemo cblmemo requested a review from Michaelvll October 1, 2024 23:00
@cblmemo
Copy link
Collaborator Author

cblmemo commented Oct 10, 2024

bump for review @Michaelvll

Copy link
Collaborator

@Michaelvll Michaelvll left a comment

Choose a reason for hiding this comment

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

Thanks for refactoring the autoscaler class @cblmemo! Left several comments.

sky/serve/autoscalers.py Outdated Show resolved Hide resolved
sky/serve/autoscalers.py Outdated Show resolved Hide resolved
sky/serve/autoscalers.py Show resolved Hide resolved
sky/serve/autoscalers.py Outdated Show resolved Hide resolved
sky/serve/autoscalers.py Outdated Show resolved Hide resolved
sky/serve/autoscalers.py Outdated Show resolved Hide resolved

# Case 2. when latest_nonterminal_replicas is less
class HysteresisAutoscaler(Autoscaler):
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is a bit weird calling it HystersisAutoscaler, as Hysteresis is just a technique to avoid keeping scaling up and down.

Also, in what case would this autoscaler ever scale? Is it just when a user updates the number of desired replicas? Or, is this just an internal utility class?
If it is a utility class, it would be good to make it clear in the comment and hide the class by pretending _ to the name.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point! It is indeed an utility class. Changed name to _AutoscalerWithHysteresis. I also change the format from xxxAutoscaler to AutoscalerWithxxx. PTAL!

Comment on lines 149 to 152
def collect_request_information(
self, request_aggregator_info: Dict[str, Any]) -> None:
"""Collect request information from aggregator for autoscaling."""
raise NotImplementedError
Copy link
Collaborator

Choose a reason for hiding this comment

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

For all the APIs a custom autoscaler needs to implement, we should keep them in the same section. We can try tot separate the utilities and APIs using:

# --- APIs for custom autoscaler ---
def api_1():
  pass
def api_2():
  pass
# --- Utilities functions ---
def ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point! Done. PTAL again!

@cblmemo cblmemo requested a review from Michaelvll October 25, 2024 00:15
@cblmemo
Copy link
Collaborator Author

cblmemo commented Dec 21, 2024

@Michaelvll bump on review for this as it is related to #4444

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