{"record":{"id":"8983ebae3a260fd7","repo":"vllm-project/vllm","slug":"shape-id-shape-id-requires-pytorch-2-11-0","errorCode":null,"errorMessage":"shape_id='{shape_id}' requires PyTorch >= 2.11.0","messagePattern":"shape_id='(.+?)' requires PyTorch >= 2\\.11\\.0","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"vllm/compilation/decorators.py","lineNumber":425,"sourceCode":"            self,\n            compile_prefix=cls.__name__ if is_encoder else \"\",\n            is_encoder=is_encoder,\n        )\n\n    cls.__init__ = __init__\n\n    def _mark_dynamic_inputs(\n        mod: type[_T], ds_type: DynamicShapesType, *args: Any, **kwargs: Any\n    ) -> None:\n        def mark_dynamic(\n            arg: torch.Tensor, dim_shape_pairs: list[tuple[int, str | None]]\n        ) -> None:\n            if ds_type == DynamicShapesType.UNBACKED:\n                if is_torch_equal_or_newer(\"2.10.0\"):\n                    for dim, shape_id in dim_shape_pairs:\n                        if shape_id is not None:\n                            if not _SUPPORTS_SHAPE_ID:\n                                raise RuntimeError(\n                                    f\"shape_id='{shape_id}' requires PyTorch >= 2.11.0\"\n                                )\n                            torch._dynamo.decorators.mark_unbacked(\n                                arg,\n                                dim,\n                                hint_override=arg.size()[dim],\n                                shape_id=shape_id,\n                            )\n                        else:\n                            torch._dynamo.decorators.mark_unbacked(\n                                arg,\n                                dim,\n                                hint_override=arg.size()[dim],\n                            )\n                else:\n                    # For older versions, we can't use hint_override or shape_id\n                    dims = [dim for dim, _ in dim_shape_pairs]\n                    torch._dynamo.decorators.mark_unbacked(arg, dims)","sourceCodeStart":407,"sourceCodeEnd":443,"githubUrl":"https://github.com/vllm-project/vllm/blob/c794754062d49a8fdb63ab3c5215b488b865030c/vllm/compilation/decorators.py#L407-L443","documentation":"With unbacked dynamic shapes, vLLM can pass a shape_id to torch._dynamo.decorators.mark_unbacked so different tensors sharing a symbolic size get the same shape id. That keyword requires PyTorch 2.11+ (tracked by the _SUPPORTS_SHAPE_ID flag); on older torch (>=2.10) where shape_id exists in vLLM's API but not in PyTorch's mark_unbacked, vLLM raises RuntimeError.","triggerScenarios":"Configuring dynamic_shape_id (supplying shape ids for dims in the decorator / DynamicShapesType.UNBACKED path) while running PyTorch 2.10.x, where is_torch_equal_or_newer('2.10.0') is True but _SUPPORTS_SHAPE_ID is False.","commonSituations":"Newer vLLM features (shape_id-based symbolic size sharing) used on a pinned older PyTorch 2.10 wheel; CI with a frozen torch version while model configs adopt shape ids.","solutions":["Upgrade PyTorch to 2.11.0 or newer.","Or remove shape_id entries from your dynamic-shape configuration so the plain mark_unbacked path is used."],"exampleFix":"# before\n# torch==2.10.x\n@support_torch_compile(dynamic_shape_id={\"hidden_states\": {0: \"tokens\"}})\nclass L(nn.Module): ...\n# after\npip install --upgrade \"torch>=2.11.0\"\n# or drop shape_id:\n@support_torch_compile(mark_unbacked_dims={\"hidden_states\": 0})\nclass L(nn.Module): ...","handlingStrategy":"validation","validationCode":"from vllm.utils import is_torch_equal_or_newer\n\ndef supports_shape_id() -> bool:\n    return is_torch_equal_or_newer('2.11.0')\n# only configure dynamic_shape_id when supports_shape_id() is True","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check torch version before enabling shape_id features","Gate new dynamic-shape config on version probes in tests","Document the minimum torch version in model configs"],"tags":["torch-compile","version-compat","dynamic-shapes","vllm"],"backgroundTag":null,"analyzedSha":"c794754062d49a8fdb63ab3c5215b488b865030c","analyzedAt":"2026-08-14T21:17:39.825Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}