{"record":{"id":"8aa75ea33062ed0c","repo":"jax-ml/jax","slug":"dlpack-is-only-supported-for-devices-addressable-b","errorCode":null,"errorMessage":"DLPack is only supported for devices addressable by the current process.","messagePattern":"DLPack is only supported for devices addressable by the current process\\.","errorType":"exception","errorClass":"xla::XlaRuntimeError","httpStatus":null,"severity":"error","filePath":"jaxlib/dlpack.cc","lineNumber":368,"sourceCode":"                    }));\n  if (!capsule.ptr()) {\n    throw nb::python_error();\n  }\n  return capsule;\n}\n\nabsl::StatusOr<nb::object> DLPackManagedTensorToBuffer(\n    const nb::capsule& tensor, ifrt::Device* ifrt_device,\n    nb_class_ptr<PyClient> client, std::optional<std::intptr_t> stream,\n    std::optional<bool> copy, std::optional<DLDeviceType> dl_device_type) {\n  ifrt::PjRtDevice* device =\n      xla::ifrt::dyn_cast_or_null<ifrt::PjRtDevice>(ifrt_device);\n  if (device == nullptr) {\n    throw xla::XlaRuntimeError(\n        \"DLPack is supported for PjRt-compatible backends only.\");\n  }\n  if (!device->IsAddressable()) {\n    throw xla::XlaRuntimeError(\n        \"DLPack is only supported for devices addressable by the current \"\n        \"process.\");\n  }\n  if (std::string_view(tensor.name()) != kDlTensorCapsuleName) {\n    return xla::InvalidArgument(\n        \"DLPack tensor must be a capsule with name \\\"dltensor\\\", got \\\"%s\\\". \"\n        \"Note that a DLPack tensor may be consumed at most once.\",\n        std::string_view(tensor.name()));\n  }\n  DLManagedTensor* dlmt = static_cast<DLManagedTensor*>(tensor.data());\n  if (dlmt->dl_tensor.ndim < 0) {\n    return xla::InvalidArgument(\n        \"Number of dimensions in DLManagedTensor must be nonnegative, got %d\",\n        dlmt->dl_tensor.ndim);\n  }\n  absl::Span<int64_t const> dimensions(\n      reinterpret_cast<int64_t*>(dlmt->dl_tensor.shape), dlmt->dl_tensor.ndim);\n  TF_ASSIGN_OR_RETURN(xla::PrimitiveType element_type,","sourceCodeStart":350,"sourceCodeEnd":386,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jaxlib/dlpack.cc#L350-L386","documentation":"DLPack import needs to write the tensor data onto the target device; only devices addressable by the current process (i.e. local) can be written to, so remote/virtual devices are rejected.","triggerScenarios":"jax.dlpack.from_dlpack(tensor, device=d) where d is a non-addressable device — e.g. a remote device in multi-process jax, or another process's device.","commonSituations":"Multi-host/multi-process jax runs where the device list includes remote devices and the caller picked devices[1] which lives on another node.","solutions":["Select an addressable local device (jax.local_devices()[0])","In multi-process setups, import the DLPack tensor on the process that owns the data"],"exampleFix":"# before\njax.dlpack.from_dlpack(t, device=jax.devices()[3])\n# after\njax.dlpack.from_dlpack(t, device=jax.local_devices()[0])","handlingStrategy":"validation","validationCode":"import jax\nlocal = set(id(d) for d in jax.local_devices())\nassert id(dev) in local, 'device not addressable by this process'","typeGuard":"def is_local(d) -> bool:\n    import jax\n    return d in jax.local_devices()","tryCatchPattern":null,"preventionTips":["Always import DLPack tensors onto jax.local_devices()[0]","In multi-host runs, import on the host that owns the data"],"tags":["jax","dlpack","device","multi-process"],"backgroundTag":"device-not-addressable","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}