[rollout, vllm] feat: KV-cache-aware request load balancer#7115
Draft
touch869 wants to merge 15 commits into
Draft
[rollout, vllm] feat: KV-cache-aware request load balancer#7115touch869 wants to merge 15 commits into
touch869 wants to merge 15 commits into
Conversation
…contract - Split flat router.py into a router/ package mirroring engine/base.py. - RequestLoadBalancer Protocol declares the __init__(servers, config) contract. - LoadBalancerRegistry registers strategies via decorator; get_router_handle dispatches. - Move GlobalRequestLoadBalancer to global_balancer.py; fix zip subscript typo. - Add RolloutConfig.router_config field. - Expose get_rollout_config() on the vLLM server for external routers.
- Register the kvcaware strategy via the decorator. - Add the KVCAwareBalancer orchestration shell. - Add the kvcaware subsystem skeleton: config, strategies, collectors, store interfaces, types, logging. - Package imports cleanly and the strategy registers; no working balancer constructed yet.
- Add KVCacheStore / MetricsStore / StickySessionStore singletons. - Wire DataStore top-level sub-store imports (C2 left them as a cut). - Add xxhash chained prefix-hash utils (get_prefix_hashes / compute_hash). - Add store unit tests (sticky+incr delegation, prefix-chain match). Store layer is now import-clean and DataStore constructs; no collector/strategy impl yet.
- Add concrete transports: Callback / HTTP (httpx) / ZMQ (pyzmq). - Add decoders: basic (Inflight, Sticky) + vllm (KV, Metrics, KVCacheEvent). - Wire transport/__init__ eager re-exports (C2 left them as a cut). - get_collector factory now resolves all four collector names. Collectors import-clean and drive DataStore; ut/cpu tests green (22 passed). st/gpu tests (real vLLM) deferred to the NPU/GPU container.
- Add KVCacheAwareStrategy (load + cache + sticky-shortcut scoring). - Register it in StrategyRegistry via strategies/__init__ side-effect import (C2 left the registry empty). - route() now ranks real replicas against store metrics. Strategy layer complete; balancer can now resolve the kvcaware strategy. ut/cpu tests green (81 passed).
- Wire the balancer end-to-end: orchestration tests (unit/sticky/ray-integration), kvcaware.yaml Hydra group, test_config compose tests, ci_test.sh, top-level conftest. - Add e2e tests (router + mooncake) driving run_infer.sh over a real vLLM agent loop. - Fix get_router_handle struct-mode bug: mutating full_determinism on a Hydra-composed router_config node raised ConfigKeyError; materialize the node to a plain dict first (production-only — ut used non-struct configs and missed it). - Add the generic (GPU) example: parallel_infer.py (MooncakeStoreConnector, kv-events, oc.select-derived fields), run_infer.sh, agent configs, READMEs. - Simplify kvcaware/ comments: drop stale FQN/migration-history/external-doc references, trim verbose docstrings; license headers consistent across the package. Verified on the GPU container (vllm 0.21): ci_test ut 233 / st-cpu 5 / st-gpu 11 / e2e 2, all PASS.
…lter + slow_cut config fields - Add SlowCut enum (prefix-load-aware / least-inflight) to kvcaware.types; export from types. - Add memory_overload_filter (bool, default True) and slow_cut (SlowCut, default prefix-load-aware) to KVCAwareStrategyConfig, with yaml-str→SlowCut coercion + validation in __post_init__ (mirrors the Layer pattern). - plot_metrics.py: refactor into an OOP panel design (LogParser + Panel hierarchy — FieldPanel / MFUPanel(SlidingPanel) / EvictPanel(CumulativePanel); the extract/transform/ derive/draw/summarize hooks absorb the per-metric free functions).
touch869
requested review from
ArronHZG,
PeterSH6,
chenhaiq,
eric-haibin-lin,
tongyx361,
vermouth1992 and
wuxibin89
as code owners
July 22, 2026 09:29
|
yyyyrf seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Collaborator
|
There are too many changes in this pr. Can we try breaking it into smaller ones? |
…plot walltime subtitle - per-request observability: turn tracking, prompt-length, route latency, load panels + dispatch plots (plot_metrics.py) - plot_metrics walltime subtitle: run walltime (first→last log timestamp across ALL lines, incl. vLLM warmup/teardown that the signal window excludes) as a centered figure subtitle; _fmt_walltime helper - kv-event hardening: surface kv-event decode errors; match vLLM replay protocol (zmq transport + kv decoder)
touch869
marked this pull request as draft
July 24, 2026 07:05
[rollout] feat: add capacity tokens method to router
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.
What does this PR do?
Add a KV-cache-aware request load balancer as a new routing option for verl's rollout servers, migrated from the standalone
uni-agentLLM router. The new balancer routes each request by combining prefix-cache hit rates (GPU/CPU/SSD tiers) with live load metrics (KV-cache usage, running/waiting requests), and preserves sticky sessions for multi-turn conversations with overload-aware fallback.It is fully opt-in: when no
routerconfig is provided (orrouter.type: default), the existingGlobalRequestLoadBalancerbehavior is unchanged.Depends on #6712.
Related issues/PRs:
Checklist Before Starting
[{modules}] {type}: {description}(This will be checked by the CI)[rollout, vllm] feat: KV-cache-aware request load balancerTest
Import, config-parsing, strategy-construction, and
LLMServerManagerintegration smoke tests pass:pytest tests/workers/rollout/test_kvc_aware_balancer.py::TestKVCAwareBalancerImport -v # 4 passedEnd-to-end validation on a real vLLM rollout (throughput / cache-hit comparison vs. the default balancer):
API and Usage Example
API change (backward compatible):
LLMServerClient._acquire_server()gains an optionalprompt_ids: list[int] = Noneparameter, forwarded to the balancer for content-aware routing. Existing callers are unaffected. A new optionalroutersection is added under the rollout config.Design & Code Changes
The router is a self-contained package under
verl/workers/rollout/llm_router/that satisfies the same balancer interface asGlobalRequestLoadBalancer(acquire_server/release_server/add_servers/remove_servers/get_all_servers/get_status).verl/workers/rollout/llm_router/:balancer.py—KVCAwareBalancerorchestration shell (wrapped withray.remoteat init).strategies/—kvc_awarescoring, weightedrouting,sticky_session,load_score, registry.collectors/—RouteDataProvider+ vLLM metrics/KV decoders over HTTP-polling and ZMQ transports.store/— KV-cache hit and metrics stores.config/+configs/— Hydra/OmegaConf config parsing and default YAMLs.verl/workers/rollout/llm_server.py:LLMServerManager._init_global_load_balancer()selects the balancer byrouter.type(kvc_awarevsdefault), keeping the default path unchanged.LLMServerClient._acquire_server()/generate()threadprompt_idsthrough for cache-aware routing.tests/workers/rollout/test_kvc_aware_balancer.py.README.md, config example, and a repo-level quickstart.Checklist Before Submitting
Important
Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review.
pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=alwaysci-requestchannel in theverlSlack workspace.recipesubmodule, please also update the reference to the submodule commit viagit submodule update --remoteorcd recipe && git pull origin main.