jax-ml/jax · error · BufferError
The device specification passed to to_dlpack contains an uns
Error message
The device specification passed to to_dlpack contains an unsupported device type (DLDeviceType: {dl_device_type}) What it means
The dl_device tuple passed to __dlpack__/to_dlpack names a DLPack device type (e.g. kDLCUDA, kDLCPU, kDLMetal) that JAX does not map to any supported backend platform. Per the array API spec, unsupported producers raise BufferError.
Source
Thrown at jax/_src/dlpack.py:145
is mutated, it may lead to undefined behavior when using the associated JAX
array. When JAX eventually supports ``DLManagedTensorVersioned``
(DLPack 1.0), it will be possible to specify that a buffer is read-only.
"""
if not isinstance(x, array.ArrayImpl):
raise TypeError("Argument to to_dlpack must be a jax.Array, "
f"got {type(x)}")
device = None
dl_device_type, local_hardware_id = dl_device if dl_device else (None, None)
if dl_device_type:
try:
dl_device_platform = _DL_DEVICE_TO_PLATFORM[dl_device_type]
backend = xla_bridge.get_backend(dl_device_platform)
device = backend.device_from_local_hardware_id(local_hardware_id)
except KeyError:
# https://data-apis.org/array-api/latest/API_specification/generated/array_api.array.__dlpack__.html
# recommends using BufferError.
raise BufferError(
"The device specification passed to to_dlpack contains an"
f" unsupported device type (DLDeviceType: {dl_device_type})"
) from None
# As new versions are adopted over time, we can maintain some legacy paths
# for compatibility mediated through the max_version parameter.
# TODO(micky774): Deprecate default usage of DLPackManagedTensor when XLA
# supports DLManagedTensorVersioned (DLPack version 1.0) and repurpose the
# current _to_dlpack as a legacy path for (0,5) <= max_version < (1,0).
if max_version is None or max_version >= DLPACK_VERSION:
# Latest
return _to_dlpack(
x, stream=stream,
src_device=src_device,
device=device,
copy=copy
)
elif max_version >= MIN_DLPACK_VERSION:View on GitHub (pinned to 1e1c6a8fc0)
Solutions
- Request a supported device type: CPU or the GPU type JAX was built for (kDLCUDA, or kDLCUDAManaged where supported)
- Pass dl_device=None to let JAX choose the array's native device
- Verify the target platform backend is installed (jax.cuda / jax.rocm)
Example fix
# before jax_arr.__dlpack__(dl_device=(DLDeviceType.kDLOpenCL, 0)) # after jax_arr.__dlpack__() # or dl_device=(DLDeviceType.kDLCUDA, 0)
Defensive patterns
Strategy: fallback
Validate before calling
from jax._src.dlpack import _DL_DEVICE_TO_PLATFORM
if dl_device and dl_device[0] not in _DL_DEVICE_TO_PLATFORM:
dl_device = None # fall back to native device Try / catch
try:
x.__dlpack__(dl_device=dl_device)
except BufferError:
x.__dlpack__() Prevention
- Request only kDLCPU/kDLCUDA (or your installed backend's type)
- Omit dl_device when the consumer can accept the native device
When it happens
Trigger: Calling x.__dlpack__(dl_device=(t, id)) with a DLDeviceType enum value not in JAX's _DL_DEVICE_TO_PLATFORM mapping (e.g. kDLROCM on a build without ROCm, kDLOpenCL, kDLVulkan).
Common situations: PyTorch requesting an OpenCL/Vulkan/Metal device buffer; consumers hard-coding a device enum not supported by the installed JAX backends.
Related errors
- __dlpack__ only supported for unsharded arrays.
- The array passed to from_dlpack must have __dlpack__ and __d
- Array passed to from_dlpack is on unsupported device type (D
- to_dlpack can only pack a dlpack tensor from an array on a s
- Unknown GPU platform for __dlpack__: {platform_version}
AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27).
Data as JSON: /api/errors/eae0f1b7a22d6520.
Report an issue: GitHub.