Skip to content

[serve.llm] Score API Integration for Serve LLM - #55914

Merged
kouroshHakha merged 9 commits into
ray-project:masterfrom
hao-aaron:ahao/serve-llm-score
Aug 27, 2025
Merged

kouroshHakha merged 9 commits into
ray-project:masterfrom
hao-aaron:ahao/serve-llm-score

Conversation

@hao-aaron

Copy link
Copy Markdown
Contributor

Why are these changes needed?

adds endpoint for the serve api which already exists in vLLM as described here: https://docs.vllm.ai/en/v0.10.0/serving/openai_compatible_server.html#score-api_1

Related issue number

Closes #55388

Checks

Notes:
Score endpoint is only supported by vllm v0, must set "VLLM_USE_V1": "0" in the env_vars. Unsure of how to document this

@nrghosh
nrghosh requested review from eicherseiji and nrghosh August 25, 2025 23:44
@nrghosh

nrghosh commented Aug 25, 2025

Copy link
Copy Markdown
Contributor

/gemini review

@eicherseiji eicherseiji left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Test? :)

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request successfully integrates the vLLM Score API by adding a new /v1/score endpoint. The changes are well-structured and follow existing patterns in the codebase. I've provided a few suggestions to improve documentation clarity, type safety, and correctness. Specifically, I've recommended updating the documentation with a critical usage note, enhancing a validation method to be more explicit, and correcting a type hint in a method signature to include the new request type.

Comment thread doc/source/serve/llm/index.md Resolved
Comment on lines +229 to +232
def _validate_openai_serving_scores(self):
assert hasattr(
self._oai_serving_scores, "create_score"
), "oai_serving_scores must have a create_score attribute"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To make this validation more robust and to allow removing the type: ignore in the score method, it's a good practice to explicitly check if self._oai_serving_scores is not None before checking for the attribute. This improves type safety and follows the pattern in _validate_openai_serving_models.

Suggested change
def _validate_openai_serving_scores(self):
assert hasattr(
self._oai_serving_scores, "create_score"
), "oai_serving_scores must have a create_score attribute"
def _validate_openai_serving_scores(self):
assert self._oai_serving_scores is not None, "oai_serving_scores is not initialized"
assert hasattr(
self._oai_serving_scores, "create_score"
), "oai_serving_scores must have a create_score attribute"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Following existing format for validation function, none of the other ones include None checking

@nrghosh nrghosh left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

see gemini comments + add testing please 👌🏽
unit tests are where the "VLLM_USE_V1": "0" dependency will be noted as well

@eicherseiji eicherseiji changed the title Score API Integration for Serve LLM [serve.llm] Score API Integration for Serve LLM Aug 26, 2025
@nrghosh nrghosh added alpha go add ONLY when ready to merge, run all tests and removed alpha labels Aug 26, 2025
@hao-aaron
hao-aaron marked this pull request as ready for review August 26, 2025 20:53
@hao-aaron
hao-aaron requested review from a team as code owners August 26, 2025 20:53

@nrghosh nrghosh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks good, thanks for adding the tests / version check

async def score(self, body: ScoreRequest) -> Response:
"""Create scores for the provided text pairs.

Note: This is vLLM specific endpoint. vLLM v1 does not support score, must use v0.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is the V1 incompatibility documented somewhere? (I was not able to easily verify this)

In parallel, @ahao-anyscale can you add a link to an issue requesting /score support in V1?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1 to creating issue -- and include the other custom APIs as well if they are not supported in V1. Separately, could be a good idea to create some serve issues/tickets to add support as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

When I try to run BAAI/bge-reranker-v2-m3 with v1, i get NotImplementedError: VLLM_USE_V1=1 is not supported with ['XLMRobertaForSequenceClassification', 'TransformersForCausalLM']. I wasn't able to find any concrete documentation about the score API itself.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It appears that v1 just doesn't work with many scoring models but not all of them. I'll get rid of the checks.
https://docs.vllm.ai/en/v0.9.2/models/supported_models.html#sentence-pair-scoring

@nrghosh
nrghosh requested a review from kouroshHakha August 26, 2025 21:49

@kouroshHakha kouroshHakha left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LG. Just one nit.


def _create_raw_request(
self,
request: Union[CompletionRequest, ChatCompletionRequest, EmbeddingRequest],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we need to start using overload decorator for this function

self,
*,
body: Union[CompletionRequest, ChatCompletionRequest, EmbeddingRequest],
body: Union[

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

similarly let's use overload decorator for this method to avoid listing all the possible combinations of types

Signed-off-by: ahao-anyscale <[email protected]>
@kouroshHakha
kouroshHakha enabled auto-merge (squash) August 27, 2025 00:28
@ray-gardener ray-gardener Bot added serve Ray Serve Related Issue llm community-contribution Contributed by the community labels Aug 27, 2025

@eicherseiji eicherseiji left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great work, @ahao-anyscale !

@github-actions
github-actions Bot disabled auto-merge August 27, 2025 16:51

@angelinalg angelinalg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

just one nit

@kouroshHakha
kouroshHakha enabled auto-merge (squash) August 27, 2025 22:52
@kouroshHakha
kouroshHakha merged commit b975ed0 into ray-project:master Aug 27, 2025
tohtana pushed a commit to tohtana/ray that referenced this pull request Aug 29, 2025
Signed-off-by: ahao-anyscale <[email protected]>
Co-authored-by: Nikhil G <[email protected]>
Co-authored-by: angelinalg <[email protected]>
Signed-off-by: Masahiro Tanaka <[email protected]>
gangsf pushed a commit to gangsf/ray that referenced this pull request Sep 2, 2025
Signed-off-by: ahao-anyscale <[email protected]>
Co-authored-by: Nikhil G <[email protected]>
Co-authored-by: angelinalg <[email protected]>
Signed-off-by: Gang Zhao <[email protected]>
sampan-s-nayak pushed a commit to sampan-s-nayak/ray that referenced this pull request Sep 8, 2025
Signed-off-by: ahao-anyscale <[email protected]>
Co-authored-by: Nikhil G <[email protected]>
Co-authored-by: angelinalg <[email protected]>
Signed-off-by: sampan <[email protected]>
jugalshah291 pushed a commit to jugalshah291/ray_fork that referenced this pull request Sep 11, 2025
Signed-off-by: ahao-anyscale <[email protected]>
Co-authored-by: Nikhil G <[email protected]>
Co-authored-by: angelinalg <[email protected]>
Signed-off-by: jugalshah291 <[email protected]>
dstrodtman pushed a commit that referenced this pull request Oct 6, 2025
Signed-off-by: ahao-anyscale <[email protected]>
Co-authored-by: Nikhil G <[email protected]>
Co-authored-by: angelinalg <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
landscapepainter pushed a commit to landscapepainter/ray that referenced this pull request Nov 17, 2025
Signed-off-by: ahao-anyscale <[email protected]>
Co-authored-by: Nikhil G <[email protected]>
Co-authored-by: angelinalg <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community go add ONLY when ready to merge, run all tests llm serve Ray Serve Related Issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Serve][LLM] Add score API in addition to existing chat/completions etc.

6 participants