Skip to content

Commit

Permalink
update validation
Browse files Browse the repository at this point in the history
  • Loading branch information
aniketmaurya committed Dec 12, 2024
1 parent b47bc10 commit 1fa71ab
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/litserve/loops.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,11 +725,18 @@ def pre_setup(self, lit_api: LitAPI, spec: Optional[LitSpec]):
"Continuous batching loop requires streaming to be enabled. Please set LitServe(..., stream=True)"
)

if lit_api.max_batch_size <= 1:
raise ValueError(
"Continuous batching loop requires max_batch_size to be greater than 1. "
"Please set LitServe(..., max_batch_size=2)"
)
if not hasattr(lit_api, "step") and not hasattr(lit_api, "predict"):
raise ValueError("""Using the default step method with Continuous batching loop requires the lit_api to
have a `predict` method which accepts decoded request inputs and a list of generated_sequence.
Please implement the has_finished method in the lit_api.
class ExampleAPI(LitAPI):
...
def predict(self, inputs, generated_sequence):
# implement predict logic
# return list of new tokens
...
""")

if not hasattr(lit_api, "step") and not hasattr(lit_api, "has_finished"):
raise ValueError("""Using the default step method with Continuous batching loop
Expand Down

0 comments on commit 1fa71ab

Please sign in to comment.