Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise a runtime error when trying to convert the jax.Array wrapped by jax.core.Token to a numpy array, as it is an internal implementation detail and the buffer has XLA token shape. #67308

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions third_party/xla/xla/python/py_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,13 @@ StatusOr<nb::object> PyHostValue::AsNumPyArray(
if (ifrt_array->IsDeleted()) {
return InvalidArgument("DeviceArray has been deleted.");
}
// The only `jax.Array` with token-shape buffer is the one wrapped by
// `jax.core.Token`. Since it is an internal implementation detail, we
// don't support converting it to a numpy array.
if (ifrt_array->dtype().kind() == ifrt::DType::kToken) {
return InvalidArgument(
"Cannot convert a token-shape buffer to a numpy array.");
}
auto* arr = llvm::dyn_cast_or_null<ifrt::PjRtCompatibleArray>(ifrt_array);
if (arr != nullptr) {
auto* pjrt_buffer = arr->pjrt_buffers().front().get();
Expand Down
2 changes: 1 addition & 1 deletion third_party/xla/xla/python/xla_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

# Just an internal arbitrary increasing number to help with backward-compatible
# changes. In JAX, reference this via jax._src.lib.xla_extension_version.
_version = 263
_version = 264

# Version number for MLIR:Python components.
mlir_api_version = 56
Expand Down
Loading