{"record":{"id":"d8b9f40a41122ce8","repo":"vllm-project/vllm","slug":"the-model-is-an-hybrid-without-a-layers-block-type","errorCode":null,"errorMessage":"The model is an hybrid without a layers_block_type or an attn_type_list, or a layer_types in the hf_config, cannot determine the num of {block_type} layers","messagePattern":"The model is an hybrid without a layers_block_type or an attn_type_list, or a layer_types in the hf_config, cannot determine the num of (.+?) layers","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"vllm/config/model.py","lineNumber":1598,"sourceCode":"            layer_types_value = getattr(self.hf_text_config, \"layer_types\", None)\n            if layer_types_value is not None:\n                if block_type == \"attention\":\n                    return sum(\n                        t == \"full_attention\" for t in layer_types_value[start:end]\n                    )\n                elif block_type == \"linear_attention\":\n                    return sum(\n                        t == \"linear_attention\" for t in layer_types_value[start:end]\n                    )\n                else:\n                    return sum(t == block_type for t in layer_types_value[start:end])\n\n            if (\n                layers_block_type_value is None\n                and attn_type_list is None\n                and layer_types_value is None\n            ):\n                raise ValueError(\n                    \"The model is an hybrid without a layers_block_type or an \"\n                    \"attn_type_list, or a layer_types in the hf_config, \"\n                    f\"cannot determine the num of {block_type} layers\"\n                )\n            raise AssertionError(f\"Unsupported block type: {block_type}\")\n\n    def get_mamba_chunk_size(self) -> int:\n        \"\"\"\n        Returns the mamba chunk size if it exists\n        \"\"\"\n        # used by e.g. Bamba, FalconH1, Granite\n        chunk_size = getattr(self.hf_text_config, \"mamba_chunk_size\", None)\n        if chunk_size is None:\n            # used by e.g. Mamba2, NemotronH, Zamba\n            chunk_size = getattr(self.hf_text_config, \"chunk_size\", None)\n\n        # Since Mamba1 does not have a chunk notion\n        # we use a default chunk size of 2048.","sourceCodeStart":1580,"sourceCodeEnd":1616,"githubUrl":"https://github.com/vllm-project/vllm/blob/c794754062d49a8fdb63ab3c5215b488b865030c/vllm/config/model.py#L1580-L1616","documentation":"Hybrid models (mixing full attention with linear/slab attention) need the per-layer type map to count layers of a given block type. get_num_layers_by_block_type raises when none of layers_block_type, attn_type_list, or layer_types is present in the HF config, so the count cannot be determined.","triggerScenarios":"Calling get_num_layers_by_block_type on a model flagged as hybrid (or a caller like a sampler/scheduler needing the count) whose hf_text_config lacks all three layer-type fields.","commonSituations":"Loading a hybrid architecture (e.g. Zamba-, Bamba-, FalconH1-style or custom SSM hybrids) checkpoint whose config.json omits or renames the layer-type list; converting checkpoints with tooling that drops extra config fields; upstream HF config schema changes between versions.","solutions":["Inspect the checkpoint's config.json and add the correct layer-type list (layer_types / attn_type_list / layers_block_type) matching the released model.","Re-download or re-convert the checkpoint with the same tooling/version the model author used, so hybrid fields survive.","Update vLLM/HF transformers to a version that knows this architecture's config field name."],"exampleFix":"// before: config.json\n{\"architectures\": [\"MyHybridForCausalLM\"], \"num_hidden_layers\": 24}\n// after\n{\"architectures\": [\"MyHybridForCausalLM\"], \"num_hidden_layers\": 24,\n \"layer_types\": [\"attention\", \"linear_attention\"]}","handlingStrategy":"type-guard","validationCode":"def has_layer_types(hf_text_config) -> bool:\n    return any(\n        getattr(hf_text_config, f, None) is not None\n        for f in ('layers_block_type', 'attn_type_list', 'layer_types')\n    )\n# gate hybrid-model paths on this before counting block types","typeGuard":"def is_valid_hybrid_config(cfg) -> bool:\n    return getattr(cfg, 'layer_types', None) is not None or \\\n           getattr(cfg, 'attn_type_list', None) is not None or \\\n           getattr(cfg, 'layers_block_type', None) is not None","tryCatchPattern":"except ValueError as e:\n    if 'cannot determine the num of' in str(e):\n        fail with a clear message telling the user to fix the checkpoint's config.json layer-types field","preventionTips":["Validate hybrid checkpoint configs (layer_types present, length == num_hidden_layers) before serving.","Keep conversion tooling versions aligned with the model author's to preserve hybrid config fields.","Add a checkpoint smoke test that loads ModelConfig in CI for every supported hybrid architecture."],"tags":["hybrid-model","hf-config","config","startup"],"backgroundTag":null,"analyzedSha":"c794754062d49a8fdb63ab3c5215b488b865030c","analyzedAt":"2026-08-14T21:17:39.825Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}