Repository navigation
Modal: bypass input queueing with a 64-concurrency direct server - #234
Merged
Merged
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
5 tasks done
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.
Summary
Modal's ordinary web endpoint routes each request through the Function input plane, adding substantial queueing time to Kev's GPU execution. The existing opt-in Flash path bypasses that plane, but uses a deprecated API and targets only 32 concurrent requests per container.
Register
KEV_FLASH=1through the supportedapp.server()API instead, withtarget_concurrency=64. The server routes HTTP directly to the existing Uvicorn/FastAPI app; Kev still owns bearer authentication, batching, CUDA graphs and response construction. Model code, the checkpoint pin and the deployment image are unchanged.KEV_REGIONselects the routing/compute regions, and direct mode retains at least one warm container so it does not return 503 while waking from zero.Measured benefit and rejected alternatives
The paired report uses
jaredpalmer/kev-4b, one H100 per variant, four CPUs,us-east, an in-region kept-alive client, bearer auth and six-question requests. Each level measuresmax(128, clients × 8)requests after warm-up.Warm single-request median falls 58%; direct's scaling target doubles from 32 to 64. This is not a claim of 2× throughput or halved tail latency: p99 at 64 clients was 4.50 s versus 3.98 s, and 128 clients still queue. CUDA graph capture can occur during load, and repeated pilots vary.
Raising the ordinary web limit to 128 regressed throughput at 64 clients: 43.82 → 37.07 requests/s with target 32; the target-64 pilot regressed 56.07 → 35.97. Keep the regular endpoint at 64/32 and preserve scale-to-zero rather than shipping either regression.
Direct mode stays opt-in (
KEV_FLASH=1 KEV_REGION=us-east) because it keeps a paid GPU warm. No production deployment, model-quality change or inference refactor is included. Modal currently reports $5.89 for the temporary pilots; all temporary containers are stopped.Test plan
kev-verify: 482 passed, 26 skipped, one existing Starlette deprecation warning.uv run --extra serve python -m pytest tests/test_skill_scripts.py tests/test_conventions.py -q: 44 passed, including scale-to-zero, direct registration, region requirements, bearer-secret preservation and minimum-container behavior./v1/modelsaliases and TypeSafe SDK behavior.git diff --check, Python compilation andthermonuclear-code-reviewself-review: no structural blocker; runtime files remain below 1,000 lines.Reproduce the paired run with
uv run --extra serve modal run scripts/modal_http_bench.py --out runs/modal-http-4b-h100 --levels 1,32,64,128; setKEV_HTTP_TARGET=64to retry the rejected target-64 variant.Link to Devin session: https://app.devin.ai/sessions/d60ffea0b58946a9a30f8c7a5ebe1291
Open in Devin Desktop: https://app.devin.ai/desktop/session/d60ffea0b58946a9a30f8c7a5ebe1291?variant=devin
Requested by: @jaredpalmer