Repository navigation
[serve][llm] Add /v1/rerank and /v2/rerank to OpenAiIngress - #68623
Draft
mbartholet wants to merge 1 commit into
Draft
mbartholet wants to merge 1 commit into
mbartholet wants to merge 1 commit into
Conversation
Signed-off-by: Marc Bartholet <[email protected]>
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces support for document reranking endpoints (/v1/rerank and /v2/rerank) powered by vLLM's scoring and reranking handlers. It adds the necessary request and response schemas, updates the FastAPI ingress router, wires the rerank method through the LLM server to the VLLM engine, and includes comprehensive unit, mock, and integration tests. I have no review comments or feedback to provide.
mbartholet
marked this pull request as draft
November 28, 2026 21:27
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
OpenAiIngressserves/v1/score, but not vLLM's rerank API. vLLM serves rerank at/v1/rerank(Jina and Cohere v1 clients) and/v2/rerank(Cohere v2 client), with the same handler as score. Clients that call it, such as the Cohere SDK and the rerankers in LangChain and LlamaIndex, get a 404 from abuild_openai_appdeployment in the default mode today. (Direct-streaming mode already serves vLLM's own rerank routes, so this also brings the two modes to parity.)This PR adds
POST /v1/rerankandPOST /v2/rerank, wired the same way as/v1/score:ingress
rerank()→LLMServer.rerank()→VLLMEngine.rerank()→ vLLM'sServingScores(the existing_oai_serving_scoreshandler)./v2/rerankis a second ingress method,rerank_v2(), that callsrerank(), the same way vLLM's own router does it.RerankRequestandRerankResponsewrap vLLM's models, likeScoreRequestandScoreResponse, so vLLM's rerank options work unchanged, includingtop_n,max_tokens_per_docandtruncate_prompt_tokens.Example, from a
build_openai_appdeployment ofBAAI/bge-reranker-v2-m3:I used an AI coding assistant for parts of the implementation and testing; I reviewed every change and ran the tests myself.
Related issues
None. I found no issue or PR that adds rerank to the default ingress. The only open PR that mentions rerank is #68528 (see the notes). #55914 added
/v1/score; this PR follows the same pattern.Additional information
Notes for reviewers
VLLMEngine.rerank()repeatsscore()with the request and response types swapped. That is the pattern the other endpoints use, and it leavesscore()untouched./v1/rerankand/v2/rerankare vLLM's versioned rerank paths. The unversioned/rerankis left out, as the ingress doesn't serve the unversioned/scoreeither./v1/rerankand/rerankbut not/v2/rerank. If both merge,/v2/rerankwould work in the default mode and return 404 in direct-streaming mode, andtest_rerank_modelwould fail in the direct-streaming release job. Adding"/v2/rerank"to that allowlist fixes both. No textual conflict.RerankRequestandRerankResponseare stubs on the SGLang backend, like the transcription models, so rerank requests to an SGLang deployment return a 500 instead of a 404, as transcription requests do today. The SGLang guide lists/v1/reranknext to score.OpenAiIngressthat already has a method namedreranknow gets it registered at/v1/rerank, and/v2/rerankcalls it with aRerankRequest. A customendpoint_mapentry for these paths still wins if it comes before**DEFAULT_ENDPOINTS.Tests
test_vllm_engine.py(new, realVLLMEnginewith a fake vLLM scoring handler):VLLMEngine.rerank()passes the request to the scoring handler and parses its response. A model without a scoring handler gets a 400 that names rerank, and a bad request from vLLM maps to a 400.test_router.py(mock engine):/v1/rerankand/v2/rerankthrough the HTTP ingress, withtop_n.test_llm_server.py(mock engine): the rerank path throughLLMServer, like the score test.release/llm_tests/serve/test_llm_serve_integration.py:test_rerank_modelwithBAAI/bge-reranker-baseon both paths, next totest_score_model.Test runs (Ray master
5651cbdnightly wheel + vLLM 0.34.0, 1× A40)RerankRequestmissing)test_score_model+test_rerank_modelbge-reranker-v2-m3+Qwen2.5-0.5B-InstructThe 4 unrelated tests:
test_multi_node_placement_groups.py::test_llm_serve_data_parallel_placement_overrideand the 2test_stable_streaming_tpot[0-16-64-True-*]timing tests also fail on unchanged master on this machine.test_builder_ingress.py::test_build_openai_app_with_confighung inserve runon this machine, so I stopped it; the rest of that file passes.The GPU E2E checks, on both paths:
/v2/rerankreturns the same results as/v1/rerank, and the scores match/v1/score;top_ncuts the list, andmax_tokens_per_doctruncates a 12k-token document;