Repository navigation
[Serve][5/5] Enable direct streaming for Ray Serve LLM apps - #62670
eicherseiji wants to merge 115 commits into
Conversation
0ab2c0c to
53b613f
Compare
There was a problem hiding this comment.
Code Review
This pull request implements an "ingress bypass" feature for Ray Serve LLM deployments, enabling HAProxy to route traffic directly to LLMServer replicas using Lua-based custom routing. This involves adding an ingress_bypass configuration, implementing a background load poller for least-connections routing, and updating HAProxy templates to support per-request routing decisions via an internal endpoint. Review feedback highlights several critical improvements: the load poller needs to dynamically handle scaling events, blocking ray.get calls in asynchronous contexts should be replaced with asyncio.gather to prevent event loop stalls, and JSON construction in both Python and Lua should be made more robust to prevent malformed responses or fragile parsing.
| local host = response:match('"host"%s*:%s*"([^"]+)"') | ||
| local port = response:match('"port"%s*:%s*(%d+)') |
There was a problem hiding this comment.
Parsing JSON using regular expressions in Lua is fragile and error-prone. If the JSON structure changes slightly (e.g., whitespace, field order), the routing will fail. While Lua doesn't have a built-in JSON parser, it's better to use a more robust parsing method if available in the HAProxy environment or ensure the response format is strictly controlled and documented.
3491681 to
1e1cfdd
Compare
1e1cfdd to
b85a2b9
Compare
269ac19 to
384d4a1
Compare
2466f8b to
2b140da
Compare
ed80ad7 to
b64e550
Compare
|
🙃 tried to fix DCO |
0efa14b to
ff33f5b
Compare
|
Superseded by #63167. |
Why this is needed
This PR introduces the Ray Serve LLM changes: an ingress request router that can pick a model replica, and a backend ASGI app that the chosen replica can serve directly. This PR is where the OpenAI/vLLM serving path plugs into those new Serve interfaces.
Summary
LLMRouteras the LLM-side ingress request router that serves/internal/routeand returns{"replica_id": ...}for a chosen backend replicaDeploymentHandle._get_request_router()escape hatch soLLMRoutercan reuse Serve's existing in-process replica picker instead of re-implementing replica selection logic__serve_build_asgi_app__, soLLMServercan build the vendored vLLM FastAPI app after async engine startup; Serve resolves it during replica ASGI initialization before lifespan startupbuild_openai_app(...); this prototype validates direct streaming as single-model-only for nowStack: #62667 -> #62680 -> #62668 -> #62669 -> this
Test plan
python -m py_compileon the edited filesgit diff --checkBenchmark Results
Direct streaming, benchmarked at
17a635aa4f887a8afdf931e65a31a74bf507d400; current PR cleanup tip is256599ac14ae7322b2222202e3c8d9a25923ae62. vLLM0.19.0.Workload:
Qwen/Qwen3-0.6B-FP8, 8 H100 replicas, ISL=8000, OSL=50, 4096 requests,request-rate=inf.Benchmark invocation:
cd /home/ray/default/llm-inference-stack/replica-scaling python sweep_concurrency.py \ --backend ray-serve-llm-direct-streaming \ --label qwen-0.6b-fp8-h100-ray-direct-streaming-seiji-prhead-17a635-rr-8k50-c64-128-256 \ --concurrency 64 128 256 \ --isl-osl-pairs 8000:50Equivalent
vllm bench serveworkload shape:App deployment code:
Results: