[subscriber] add KVCache event subscriber - #256
Conversation
41e3803 to
4e31383
Compare
|
@codex review |
4e31383 to
65c2f9f
Compare
65c2f9f to
c143343
Compare
|
@codex review |
c143343 to
4db5d13
Compare
|
@codex review |
4db5d13 to
c2b1280
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c2b1280d83
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| # kvcm SDK | ||
| kvcm_heartbeat_interval_s: float = 5.0 | ||
| kvcm_request_timeout_s: float = 5.0 | ||
| kvcm_query_type: str = KvcmQueryType.QT_PREFIX_MATCH_WITH_MAMBA |
There was a problem hiding this comment.
Set mamba matching only when mamba groups exist
With the default config, every registration advertises QT_PREFIX_MATCH_WITH_MAMBA; when the engine metadata has only full-attention/default groups, KVCM's GetHostCacheState falls back to this default for unspecified queries and PrefixMatchWithMambaByHost rejects instances that have no mamba-state group. Ordinary full-attention deployments that rely on the registered default therefore get BADARGS/no hosts unless they override this option, so derive the default from the descriptor or default to QT_PREFIX_MATCH when no mamba component is registered.
Useful? React with 👍 / 👎.
| BUILTIN_ATTENTION_TYPE_CATEGORIES: Final[Mapping[str, str]] = MappingProxyType( | ||
| { | ||
| "full_attention": "F", |
There was a problem hiding this comment.
Use KVCM-compatible full group names
When a group-aware model is registered against the KVCM code in this commit's base, full-attention groups are named F0/F1, but kv_cache_manager/manager/meta_searcher.cc classifies full groups only when the location-spec group name starts with full or FULL. For QT_PREFIX_MATCH_WITH_MAMBA, KVCM then sees no full group and rejects host-cache queries even though the locations were reported; use names KVCM recognizes or land the corresponding server-side classifier change with this subscriber.
Useful? React with 👍 / 👎.
| valid_component_ids={ | ||
| component.component_id for component in bootstrap.components | ||
| }, |
There was a problem hiding this comment.
Bypass component filtering for empty bootstraps
When the accepted vLLM bootstrap has an empty components tuple (the metadata contract treats this as a valid default-spec topology), this passes an empty set rather than disabling validation. VllmIncrementalSource treats any non-None set as authoritative, so every BlockStored/BlockRemoved with a missing or any group_idx is dropped even though KVCM registered the fallback default spec; pass None when there are no components or map those events to the default spec.
Useful? React with 👍 / 👎.
| self._adapter = adapter or AbstractEngineAdapter.create( | ||
| config.engine_type, config | ||
| ) |
There was a problem hiding this comment.
Report failed for unsupported engine types
When --engine-type is unsupported (for example a typo), these lines call AbstractEngineAdapter.create() in the lifecycle constructor, which raises KeyError before _state_reporter is constructed and before _graceful_startup()'s _FatalStartupError handler can call report_failed(). The CLI only logs and re-raises, so DashServing never receives the terminal failed state for this unsupported startup; validate engine_type up front or create the adapter after the reporter is available and translate the error into the fatal path.
AGENTS.md reference: subscriber/AGENTS.md:L273-L273
Useful? React with 👍 / 👎.
| }, | ||
| ) | ||
| return effective | ||
| block_size = self._config_int(self._engine_config, "block_size") |
There was a problem hiding this comment.
Do not default missing block size to one
When the engine returns no component metadata and DS_LLM_ENGINE_CONFIG is absent or has an invalid block_size, this silently registers the instance and fallback location spec with block size 1. KVCM stores that block size and the subscriber also folds it into the instance id, so normal deployments using 16/32-token blocks can register/report under a different instance and block geometry than clients query; fail startup or obtain the real engine block size instead of defaulting to 1.
Useful? React with 👍 / 👎.
Summary
subscriber/(managed byuv, independent of the parent Bazel build) that subscribes to inference engine KV cache events and forwards them to the kvcm service.AbstractEngineAdapter: vLLM incremental (ZMQ pub/replay with seq-gap replay via DEALER socket) and snapshot pipelines, plus an SGLang placeholder adapter; the event loop is engine-agnostic.GetWorkerStatus.alive,EngineHealthCoordinatorepoch gating for sends, seq_id-linearized state reporting, idempotentAllBlocksClearedper sendable epoch.StageTimer), unified metrics viasubscriber/metrics/withkvcache_subscriber_prefix, cataloged indocs/metrics.jsonand enforced bytest_metrics_catalog.py.runtime_version/_builder);kv_cache_group_metadata.protoremains the authoritative wire schema.Why
KVCache reuse requires the kvcm service to learn block store/remove events from co-located inference engines in real time. This subscriber decouples that forwarding from the engine and from kvcm availability, with explicit health semantics so DashServing never routes traffic to a node whose events are not being forwarded.
Validation
uv run pytest— 523 passeduv run ruff check subscriber/ tests/— all checks passeduv run mypy subscriber/— no issues in 48 source files