{"record":{"id":"c9a06ea0b4ead8cb","repo":"vllm-project/vllm","slug":"xpumem-allocator-extension-is-not-available","errorCode":null,"errorMessage":"xpumem allocator extension is not available","messagePattern":"xpumem allocator extension is not available","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"vllm/device_allocator/xpumem.py","lineNumber":71,"sourceCode":"        # torch custom-op `int` arguments are signed int64.\n        # data_ptr() may return a uint64 value above 2^63-1, so normalize it.\n        return ptr if ptr < (1 << 63) else ptr - (1 << 64)\n\n    torch.ops._C.xpu_memcpy_sync(\n        _to_i64_ptr(dst_ptr),\n        _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:","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/vllm-project/vllm/blob/c794754062d49a8fdb63ab3c5215b488b865030c/vllm/device_allocator/xpumem.py#L53-L89","documentation":"Raised by get_pluggable_allocator in xpumem.py when the vllm_xpu_kernels.xpumem_allocator extension is unavailable (import failed at module load, leaving xpumem_available False). This extension supplies the my_malloc/my_free native functions the pluggable XPU allocator needs, so without it the allocator cannot be constructed.","triggerScenarios":"Any call to get_pluggable_allocator (XPU sleep-mode memory pool setup) when vllm_xpu_kernels is not installed or does not expose xpumem_allocator.","commonSituations":"vLLM XPU deployment where the companion vllm-xpu-kernels wheel was not installed or is an old version without xpumem; a broken extension import (missing native .so) that was silently swallowed by the except ImportError at module top.","solutions":["Install/upgrade the vllm-xpu-kernels package matching your vLLM and torch-XPU versions.","Verify the import directly (python -c \"from vllm_xpu_kernels import xpumem_allocator; print(xpumem_allocator.__file__)\") and fix any underlying .so/loader errors it reports.","If the extension is genuinely unavailable in your build, avoid XPU sleep mode."],"exampleFix":"# before: vllm_xpu_kernels missing -> RuntimeError\n# after\npip install vllm-xpu-kernels>=<version required by your vllm>\npython -c \"from vllm_xpu_kernels import xpumem_allocator as a; print(a.__file__)\"","handlingStrategy":"type-guard","validationCode":"try:\n    from vllm_xpu_kernels import xpumem_allocator  # noqa: F401\nexcept ImportError:\n    raise SystemExit(\"vllm-xpu-kernels with xpumem_allocator is required for XPU sleep mode\")","typeGuard":"def xpumem_extension_available() -> bool:\n    try:\n        from vllm_xpu_kernels import xpumem_allocator  # noqa: F401\n        return True\n    except ImportError:\n        return False","tryCatchPattern":"try:\n    alloc = get_pluggable_allocator(malloc, free)\nexcept RuntimeError as e:\n    if \"xpumem allocator extension\" in str(e):\n        install_vllm_xpu_kernels_and_restart()\n    raise","preventionTips":["Ship vllm-xpu-kernels in the same image as XPU vLLM; pin matching versions.","Fail fast at startup with an import probe instead of hitting the error deep in allocation."],"tags":["vllm","xpu","extension","vllm-xpu-kernels","sleep-mode"],"backgroundTag":null,"analyzedSha":"c794754062d49a8fdb63ab3c5215b488b865030c","analyzedAt":"2026-08-14T21:17:39.825Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}