{"record":{"id":"d4448b38196b5fa5","repo":"vllm-project/vllm","slug":"group-count-mismatch-tracker-has-len-self-alloca","errorCode":null,"errorMessage":"Group count mismatch: tracker has {len(self.allocated_block_ids)} groups, update has {len(new_block_ids)}","messagePattern":"Group count mismatch: tracker has (.+?) groups, update has (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"vllm/distributed/kv_transfer/kv_connector/v1/mooncake/store/data.py","lineNumber":343,"sourceCode":"    prefill_end_tokens: int = 0\n\n    def reset(self) -> None:\n        self.token_len = 0\n        self.allocated_block_ids = ()\n        self.num_saved_tokens = 0\n        self.token_ids = None\n        self.has_pending_offload = False\n        self.prefill_end_tokens = 0\n\n    def update(\n        self,\n        new_block_ids: tuple[list[int], ...] | list[int],\n    ) -> None:\n        # Backward-compat: accept a single list (broadcast to single group).\n        if isinstance(new_block_ids, list):\n            new_block_ids = (new_block_ids,)\n        if len(new_block_ids) != len(self.allocated_block_ids):\n            raise ValueError(\n                f\"Group count mismatch: tracker has \"\n                f\"{len(self.allocated_block_ids)} groups, update has \"\n                f\"{len(new_block_ids)}\"\n            )\n        for existing, new in zip(self.allocated_block_ids, new_block_ids, strict=True):\n            if new:\n                existing.extend(new)\n\n\n@dataclass\nclass ReqMeta:\n    \"\"\"Per-request metadata for store put/get operations.\"\"\"\n\n    req_id: str\n    token_len_chunk: int\n    block_ids: tuple[list[int], ...]\n    block_hashes: list[BlockHash]\n","sourceCodeStart":325,"sourceCodeEnd":361,"githubUrl":"https://github.com/vllm-project/vllm/blob/c794754062d49a8fdb63ab3c5215b488b865030c/vllm/distributed/kv_transfer/kv_connector/v1/mooncake/store/data.py#L325-L361","documentation":"RequestTracker.update() accepts a tuple with one block-id list per KV cache group and must match the number of groups the tracker was initialized with (len(self.allocated_block_ids)). A plain list is broadcast to a single group for backward compat, so the mismatch almost always means the scheduler handed back a different group count than the tracker was built with.","triggerScenarios":"A model whose kv_cache_config.kv_cache_groups count differs from what the store tracker allocated (e.g. hybrid models where mamba groups appear/disappear, or a config change between init and update), or a caller passing a tuple with the wrong arity.","commonSituations":"Version drift between the scheduler's group layout and the store connector's per-request tracker; manually invoking update() in tests/driver code with a list-of-lists sized differently than the tracker's groups.","solutions":["Recreate the tracker/request state whenever kv_cache_config changes — do not reuse trackers across configs","If calling update() yourself, build the argument as tuple of len(tracker.allocated_block_ids) empty-or-new lists","Check that the model topology (number of KV cache groups) is identical at connector init time and at scheduling time; report a bug if vLLM itself produced the mismatch"],"exampleFix":"# before\ntracker.update(([new_ids], [new_ids]))  # tracker has 1 group -> ValueError\n\n# after\ntracker.update([new_ids])              # list broadcast to the single group\n# or match arity: tracker.update(([new_ids_0], [new_ids_1]))  # 2 groups","handlingStrategy":"validation","validationCode":"if isinstance(new_block_ids, list):\n    new_block_ids = (new_block_ids,)\nassert len(new_block_ids) == len(tracker.allocated_block_ids), (\n    f\"expected {len(tracker.allocated_block_ids)} groups\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat trackers as config-scoped: rebuild them whenever the KV group layout changes","Pass tuples sized to the tracker's group count","Add an assertion in driver code that calls update() directly"],"tags":["mooncake","kv-transfer","internal-invariant","scheduler"],"backgroundTag":null,"analyzedSha":"c794754062d49a8fdb63ab3c5215b488b865030c","analyzedAt":"2026-08-14T21:17:39.825Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}