{"record":{"id":"bfdd1fa9ec4a60df","repo":"huggingface/transformers","slug":"invalid-group-type","errorCode":null,"errorMessage":"Invalid group type: {}","messagePattern":"Invalid group type: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/transformers/generation/continuous_batching/cache.py","lineNumber":286,"sourceCode":"        # Block management data structures\n        self.allow_block_sharing = continuous_batching_config.allow_block_sharing\n        self.group_cache_managers: list[CacheAllocator] = []\n        self.num_full_attention_groups = 0\n        self.num_sliding_attention_groups = 0\n        self.max_sliding_window_blocks_per_request = 0\n\n        for i, group_type in enumerate(group_types):\n            if group_type == \"full_attention\":\n                cm = FullAttentionCacheAllocator(i, self.block_size, allow_block_sharing=self.allow_block_sharing)\n                self.num_full_attention_groups += 1\n            elif group_type == \"sliding_attention\":\n                cm = SlidingAttentionCacheAllocator(\n                    i, self.block_size, config.sliding_window, self.sentinel_index, self.write_trash_index\n                )\n                self.num_sliding_attention_groups += 1\n                self.max_sliding_window_blocks_per_request = cm._max_blocks_per_request\n            else:\n                raise ValueError(f\"Invalid group type: {group_type}\")\n            self.group_cache_managers.append(cm)\n\n        # We only use prefix sharing if the whole model has only full attention layers and block sharing is allowed\n        self.use_prefix_sharing = self.allow_block_sharing and group_types == [\"full_attention\"]\n        self._block_manager = BlockManager(num_blocks, self.block_size, tp_on=tp_size > 1)\n        self._total_prefix_length: int = 0  # a counter to measure the impact of prefix sharing, also used in tests\n\n        # For block table support, we lazy init the name of the block table key\n        self._block_table_key = None\n\n    def blocks_needed(self, num_requested_blocks: int, allocated_blocks: int) -> int:\n        \"\"\"Returns the number of physical blocks needed to allocate (num_requested_blocks) blocks to a request that\n        already has (allocated_blocks) blocks. The number of newly allocated blocks needed is predicted by the\n        following rules:\n        - for full attention groups: since there is no sliding window for full attention layers, one requested block is\n            always equivalent to one newly allocated block for EACH full attention group\n        - for sliding window groups: because of the sliding window, the number of blocks allocated to a request is\n            capped. Using the number of already (allocated_blocks) we can compute the number of new blocks to actually","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/generation/continuous_batching/cache.py#L268-L304","documentation":"ValueError raised while building per-group cache allocators from group_layers_by_attn_type(): each layer group's type string must be exactly 'full_attention' or 'sliding_attention'; anything else reaches the else-branch and fails. This indicates an unrecognized layer_type value in the model config (or a naming mismatch with the grouping helper).","triggerScenarios":"A model config whose layers carry layer_type values like 'full', 'attention', 'sliding', or a new attention flavor; custom architectures wired into continuous batching with their own layer_type vocabulary; localized-attention variants not yet supported.","commonSituations":"Supporting new hybrid-attention models; upstream configs that spell types differently than transformers expects.","solutions":["Check config.layer_types (or per-layer layer_type) values and map them to 'full_attention' / 'sliding_attention' before cache construction","If the model has a single attention type with no layer_type attribute, remove the attribute so all layers default to one group","For unsupported attention flavors, fall back to standard generation instead of continuous batching"],"exampleFix":"# before: config.layer_types = ['full', 'sliding', 'full', 'full']\n# after\nconfig.layer_types = ['full_attention', 'sliding_attention', 'full_attention', 'full_attention']","handlingStrategy":"validation","validationCode":"VALID = {'full_attention', 'sliding_attention'}\ntypes = getattr(config, 'layer_types', None) or [getattr(config, 'layer_type', 'full_attention')] * config.num_hidden_layers\nif any(t not in VALID for t in types):\n    raise ValueError(f'unsupported layer_type values: {set(types) - VALID}')","typeGuard":"def layer_types_supported(config) -> bool:\n    VALID = {'full_attention', 'sliding_attention'}\n    types = getattr(config, 'layer_types', None)\n    return types is None or all(t in VALID for t in types)","tryCatchPattern":null,"preventionTips":["Normalize layer_type vocabularies when onboarding new architectures","Remove layer_types entirely for uniform-attention models"],"tags":["continuous-batching","kv-cache","model-config","attention","validation"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}