Repository navigation
[serve][llm] Add a byte-relay OpenAI ingress with no per-token Python objects - #66603
johntaylor-cell wants to merge 2 commits into
Conversation
…objects OpenAiIngress relays every token as its own object on one event loop, which caps it near 13k tokens/s on a 32 vCPU node. ByteRelay stays in the response path but reads each LLMServer replica's own HTTP stream and writes the chunked bytes straight to the client socket. Co-Authored-By: Claude <[email protected]> Signed-off-by: john.taylor <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces ByteRelay, a high-performance OpenAI ingress that streams chunk-framed HTTP data directly from LLMServer replicas to client sockets to avoid per-token Python object overhead. Feedback focuses on addressing a latency and correctness issue where unconditionally holding back the last 5 bytes of every read delays chunk trailing bytes, suggesting instead to only buffer bytes matching a prefix of the terminator. Additionally, it is recommended to increase the backpressure polling interval from 1ms to 10ms to significantly reduce CPU overhead under backpressure.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 48ab291. Configure here.
…p expect Holding back the last 5 bytes of every read delayed each token until the next one arrived; now only a suffix that could start the final chunk waits. The relay no longer forwards Expect or other hop-by-hop headers, skips interim 1xx responses, and polls a slow client's buffer every 10 ms instead of every 1 ms. Co-Authored-By: Claude <[email protected]> Signed-off-by: john.taylor <[email protected]>
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |

OpenAiIngress relays every streamed token through a DeploymentHandle as its own object on one event loop, which caps it near 13k tokens/s on a 32 vCPU node. This PR adds
ByteRelay, an ingress that stays in the response path but reads each LLMServer replica's own HTTP stream and writes the bytes straight to the client socket, with no per-token Python objects.build_byte_relay_apps(llm_config)returns the backend app (LLMServer without LLMRouter) and the relay app; run both withserve.run. It needs direct ingress (RAY_SERVE_THROUGHPUT_OPTIMIZED=1), andrelay_replicasscales the relay tier.One m5.8xlarge, CPU mock engine at 2.3 ms per token, n=2 except OpenAiIngress:
Additional information