Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

FYI/Clarification for `*_like(arr)` functions using `arr.device`

Open
#1,013 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Active
Tech stack
python
Domain
api

Research direction

Start by reviewing the Array API requirement for *_like(arr) device handling and the reported CuPy, JAX, and torch behavior in the issue. Done means maintainers decide whether the standard needs clarification or a behavior change, with the expected compatibility impact documented.

Written by the indexing model from the issue text.

Description

This may be more of a CuPy question about how comfortable CuPy is with changing behavior and pushing through the change in v15. But it does come from the Array API so just bringing it up here once for awareness.

The standard states that empty_like(arr) should allocate as if empty_like(arr, device=arr.device) was passed. And that is actually what JAX and torch do:

import cupy as cp

arr = cp.arange(1000)  # arr.device == Device(0)
with cp.cuda.Device(1)
    print(cp.empty_like(arr).device)  # Device(1) for cupy, 0 for JAX/torch

CuPy does currently not do this (I half suspect this was missed at the time), CuPy completely relies on context managers right now (to the point that even a NumPy array works there).

CC @leofang

Dominant language
Python
Stars
281
Forks
52
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from data-apis/array-api

All issues in data-apis/array-api

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.