[tinker] Forward samples with aiohttp instead of httpx - #12
Closed
avigyabb wants to merge 1 commit into
Closed
Conversation
httpcore's connection pool rescans every pooled connection and queued request on each event, so the forwarding client's per-request CPU grew with the number of in-flight samples: 14ms at 512, 27ms at 2048, 38ms at 4096 (a standalone benchmark against an instant fake router; profile shows 27.5M is_idle calls for 512 requests). At 2048 in flight the API server needed 119s to forward 2048 instant requests. aiohttp's connector is flat at 0.34ms per request. - SkyRLTrainInferenceForwardingClient uses one aiohttp session: connector limit = forwarding_inference_max_connections (0 = unlimited), sock_read = forwarding_inference_timeout_sec, no total deadline so requests queued behind the engine never hit the old 300s pool timeout, 60s connect timeout (a saturated router takes tens of seconds to accept), Happy Eyeballs off (a wave of cancelled connects left uvloop "File descriptor N is used by transport" errors from aiohappyeyeballs). - Connect-phase errors and 5xx rejections from the router (TransientInferenceError) are retried once after refreshing the proxy URL; read failures stay final since vLLM may still be executing the request. - forwarding_inference_timeout_sec default 300s -> 2048s: with unlimited connections a large rollout burst waits inside vLLM's queue and 128x128 bursts exceed 300s there. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Avi Basnet <avigyabb@stanford.edu>
This was referenced Sep 4, 2026
avigyabb
commented
Sep 4, 2026
| f"vLLM /v1/completions returned non-JSON ({response.status_code}, " | ||
| f"content-type={response.headers.get('content-type')!r}): {response.text[:512]}" | ||
| ) from e | ||
| async with self._get_session().post(url, json=payload, headers=headers) as response: |
Owner
Author
There was a problem hiding this comment.
this runs in the uvicorn event loop via FastAPI asample()
avigyabb
marked this pull request as ready for review
September 4, 2026 00:58
Owner
Author
|
Moved upstream: NovaSky-AI#2161 |
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.
Stack 2/7.
Why. httpcore's connection pool rescans every pooled connection and queued request on each event, so the forwarding client's per-request CPU grows with the number of in-flight samples: 14 ms at 512, 27 ms at 2048, 38 ms at 4096 (standalone benchmark against an instant fake router; the profile shows 27.5M
is_idlecalls for 512 requests). At 2048 in flight the API server needed 119 s to forward 2048 instant requests. aiohttp's connector is flat at 0.34 ms.Change.
SkyRLTrainInferenceForwardingClientuses one aiohttp session:forwarding_inference_max_connections(0 = unlimited);sock_read=forwarding_inference_timeout_sec; no total deadline, so requests queued behind the engine never hit the old 300 s pool timeout;File descriptor N is used by transporterrors from aiohappyeyeballs'sock_connect, failing unrelated forwards;TransientInferenceError) are retried once after refreshing the proxy URL; read failures stay final (fix(tinker): bound inference forwarding retries NovaSky-AI/SkyRL#2118 stance) since vLLM may still be executing the request;forwarding_inference_timeout_secdefault 300 s -> 2048 s: with unlimited connections a large burst waits inside vLLM's queue and 128x128 bursts exceed 300 s there.Results (same harness and SDK-shaped client, upstream
mainvs this stack): 2048 small results unlimited connections 71.6 s / 29 per s -> 2.7 s / 747 per s; 32768 with 5 s engine queueing 218 s with 530 failures -> 89 s, 0 failures.Note: unlimited outbound connections cannot exceed ~28k (one source IP's ephemeral ports); set
--forwarding-inference-max-connectionsnear engine capacity for very large bursts.Stack
🤖 Generated with Claude Code