Add multi-turn cache affinity for sampling - #16
Open
kailash109 wants to merge 5 commits into
Open
Conversation
Let clients preserve rollout locality across turns while keeping legacy per-request routing unchanged, with local and Modal validation coverage. Co-authored-by: Cursor <cursoragent@cursor.com>
Allow the same two-replica harness to validate larger models and context windows without editing its source. Co-authored-by: Cursor <cursoragent@cursor.com>
Make the benchmark GPU configurable and allow CUDA graphs for representative long-generation timing runs. Co-authored-by: Cursor <cursoragent@cursor.com>
Require every configured GPU replica to be live and healthy before measuring routing behavior. Co-authored-by: Cursor <cursoragent@cursor.com>
Ignore EOS in validation runs so cache-routing timing compares identical decode token counts. Co-authored-by: Cursor <cursoragent@cursor.com>
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
cache_affinity_keythat keeps turns from one trajectory on the same Modal replica and DP rankignore_eos8x H100 fixed-length validation
Eight one-H100 replicas running Qwen3-8B with CUDA graphs, 4 trajectories, 8 turns, 4,096-token initial prompts, exactly 512 generated tokens per request, and a 16K context. Both arms perform exactly 32 requests and decode 16,384 tokens. The harness verifies all eight distinct replicas and their SGLang backends are healthy before measurement.
Across each trajectory, generated history grows the reusable prefix by 3,584 tokens:
Modal run: https://modal.com/apps/modal-labs/kailash-dev/ap-IibK6PzfrLcclpQV6ZKlfO
The equal-work result is decode-bound: decoding 512 tokens takes approximately 4.4s on Qwen3-8B/H100, while avoiding repeated prefill saves approximately 0.27s per warm request on average.
Test plan
uv run pytest tests/inference/test_sampling.py tests/control_plane/test_sampling.py tests/control_plane/test_http.pyuv run ruff check src/lilo/control_plane/http.py src/lilo/inference/sampling.py tests/control_plane/test_http.py tests/control_plane/test_sampling.py tests/inference/test_sampling.py scripts/validate_multiturn_cache_affinity.py scripts/validate_multiturn_cache_affinity_modal.pykailash-dev