Skip to content

Make SGLangApiClient an async worker handle over httpx - #1853

Open
fzyzcjy wants to merge 1 commit into
tom/refactor-miles/op3-14from
tom/refactor-miles/op3-9
Open

Make SGLangApiClient an async worker handle over httpx#1853
fzyzcjy wants to merge 1 commit into
tom/refactor-miles/op3-14from
tom/refactor-miles/op3-9

Conversation

@fzyzcjy

@fzyzcjy fzyzcjy commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Part of #1837

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@fzyzcjy
fzyzcjy force-pushed the tom/refactor-miles/op3-14 branch from b0bbe7b to abd40de Compare August 3, 2026 23:44
@fzyzcjy
fzyzcjy force-pushed the tom/refactor-miles/op3-9 branch 2 times, most recently from 448c30f to b9946a1 Compare August 4, 2026 00:39
@fzyzcjy
fzyzcjy force-pushed the tom/refactor-miles/op3-14 branch from 5069435 to 35a8595 Compare August 4, 2026 06:57
@fzyzcjy
fzyzcjy force-pushed the tom/refactor-miles/op3-9 branch from b9946a1 to e10f4c5 Compare August 4, 2026 06:57
@fzyzcjy
fzyzcjy force-pushed the tom/refactor-miles/op3-14 branch from 35a8595 to 92bf2e8 Compare August 10, 2026 06:06
@fzyzcjy
fzyzcjy force-pushed the tom/refactor-miles/op3-9 branch 2 times, most recently from b893f39 to cf39835 Compare August 10, 2026 16:07
@fzyzcjy
fzyzcjy force-pushed the tom/refactor-miles/op3-14 branch from aed4cf1 to deb8fc0 Compare August 10, 2026 16:34
@fzyzcjy
fzyzcjy force-pushed the tom/refactor-miles/op3-9 branch from cf39835 to 015cd40 Compare August 10, 2026 16:34
@fzyzcjy
fzyzcjy force-pushed the tom/refactor-miles/op3-14 branch from deb8fc0 to 4c07458 Compare August 12, 2026 02:48
@fzyzcjy
fzyzcjy force-pushed the tom/refactor-miles/op3-9 branch 2 times, most recently from 49a506d to b95089c Compare August 12, 2026 14:31
@fzyzcjy
fzyzcjy force-pushed the tom/refactor-miles/op3-14 branch from 4c07458 to 7e38f8b Compare August 12, 2026 14:31
@fzyzcjy
fzyzcjy force-pushed the tom/refactor-miles/op3-9 branch from b95089c to a8e3e02 Compare August 12, 2026 23:56
@fzyzcjy
fzyzcjy force-pushed the tom/refactor-miles/op3-14 branch from 6965269 to 3703550 Compare August 13, 2026 06:01
@fzyzcjy
fzyzcjy force-pushed the tom/refactor-miles/op3-9 branch from a8e3e02 to 16da4ad Compare August 13, 2026 06:01
The rollout process is async, and the requests-based client forced every
caller onto a thread. Turn the client and the router client into
async-only handles: every method is `async def` and goes through a
per-event-loop `httpx.AsyncClient`, so hundreds of in-flight requests
cost no threads.

`httpx.AsyncClient` is loop-affine while `SGLangApiClient` is a frozen,
cross-process-serializable dataclass, so the client cannot own one; it is
cached in a module-level dict keyed by the running loop.

`SGLangEngine`'s methods are Ray actor entry points and stay synchronous:
each shell now drives its coroutine on the shared background loop via
`async_utils.run`.
@fzyzcjy
fzyzcjy force-pushed the tom/refactor-miles/op3-9 branch from 16da4ad to c8fa640 Compare August 14, 2026 04:45

@guapisolo guapisolo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved for the #2176 safe-merge checkpoint: #1861 removes the Ray actor boundary that made HTTPStatusError unserializable, and the fix remains present through the checked chain tip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants