{"record":{"id":"74e701fd13eb5d18","repo":"vllm-project/vllm","slug":"torch-xpu-memory-xpupluggableallocator-is-not-avai","errorCode":null,"errorMessage":"torch.xpu.memory.XPUPluggableAllocator is not available","messagePattern":"torch\\.xpu\\.memory\\.XPUPluggableAllocator is not available","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"vllm/device_allocator/xpumem.py","lineNumber":77,"sourceCode":"        _to_i64_ptr(src_ptr),\n        n_bytes,\n        kind,\n        device,\n    )\n\n\ndef get_pluggable_allocator(\n    python_malloc_fn: Callable[[HandleType], None],\n    python_free_func: Callable[[int], HandleType],\n) -> Any:\n    if not xpumem_available or xpumem_allocator is None:\n        raise RuntimeError(\"xpumem allocator extension is not available\")\n\n    xpumem_allocator.init_module(python_malloc_fn, python_free_func)\n    mem_mod = _xpu_memory_module()\n    alloc_cls = getattr(mem_mod, \"XPUPluggableAllocator\", None)\n    if alloc_cls is None:\n        raise RuntimeError(\"torch.xpu.memory.XPUPluggableAllocator is not available\")\n\n    lib_name = xpumem_allocator.__file__\n    return alloc_cls(lib_name, \"my_malloc\", \"my_free\")\n\n\ndef create_and_allocate(allocation_handle: HandleType) -> None:\n    if not xpumem_available or xpumem_allocator is None:\n        raise RuntimeError(\"xpumem allocator extension is not available\")\n    xpumem_allocator.python_create_and_allocate(*allocation_handle)\n\n\ndef unmap_and_release(allocation_handle: HandleType) -> None:\n    if not xpumem_available or xpumem_allocator is None:\n        raise RuntimeError(\"xpumem allocator extension is not available\")\n    xpumem_allocator.python_unmap_and_release(*allocation_handle)\n\n\n@contextmanager","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/vllm-project/vllm/blob/c794754062d49a8fdb63ab3c5215b488b865030c/vllm/device_allocator/xpumem.py#L59-L95","documentation":"Raised by get_pluggable_allocator when torch.xpu.memory exists but lacks the XPUPluggableAllocator class. The xpumem extension is present and initialized, but the torch XPU build's memory module does not provide the pluggable-allocator API, so the allocator object cannot be created.","triggerScenarios":"get_pluggable_allocator reaches getattr(mem_mod, \"XPUPluggableAllocator\", None) and gets None — typically a torch-XPU version that predates (or renamed) XPUPluggableAllocator.","commonSituations":"torch too old for the pluggable allocator API; a custom/older Intel torch build; API renamed in a newer torch while vLLM expects the older name.","solutions":["Upgrade torch to the XPU version pinned by your vLLM release (see requirements/xpu.txt).","Downgrade/align if a nightly renamed the class — match the torch/vLLM pair that is known to work.","Confirm with python -c \"import torch; print(hasattr(torch.xpu.memory,'XPUPluggableAllocator'))\" before launching sleep mode on XPU."],"exampleFix":"# before: torch.xpu.memory without XPUPluggableAllocator\n# after: upgrade to the pinned XPU torch\npip install --index-url https://download.pytorch.org/whl/xpu torch==<pinned version>\npython -c \"import torch; print(hasattr(torch.xpu.memory,'XPUPluggableAllocator'))\"  # True","handlingStrategy":"type-guard","validationCode":"import torch\n\nmem = getattr(torch.xpu, \"memory\", None)\nif mem is None or not hasattr(mem, \"XPUPluggableAllocator\"):\n    raise SystemExit(\"torch lacks torch.xpu.memory.XPUPluggableAllocator; upgrade torch-XPU\")","typeGuard":"def pluggable_allocator_available() -> bool:\n    import torch\n    mem = getattr(torch.xpu, \"memory\", None)\n    return mem is not None and hasattr(mem, \"XPUPluggableAllocator\")","tryCatchPattern":"try:\n    alloc = get_pluggable_allocator(malloc, free)\nexcept RuntimeError as e:\n    if \"XPUPluggableAllocator\" in str(e):\n        upgrade_torch_xpu_to_pinned_version()\n    raise","preventionTips":["Check hasattr(torch.xpu.memory, 'XPUPluggableAllocator') in node provisioning scripts.","Keep torch, vllm, and vllm-xpu-kernels versions locked as a tested triple."],"tags":["vllm","xpu","torch","version-mismatch","allocator"],"backgroundTag":null,"analyzedSha":"c794754062d49a8fdb63ab3c5215b488b865030c","analyzedAt":"2026-08-14T21:17:39.825Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}