Skip to content

Fix test failure if no device parameter - #459

Merged
ev-br merged 9 commits into
data-apis:masterfrom
prady0t:device-fix
Sep 1, 2026
Merged

Fix test failure if no device parameter#459
ev-br merged 9 commits into
data-apis:masterfrom
prady0t:device-fix

Conversation

@prady0t

@prady0t prady0t commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Fixes #458

Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Comment thread array_api_tests/dtype_helpers.py
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
@ev-br

ev-br commented Aug 21, 2026

Copy link
Copy Markdown
Member

I tried testing this PR with MLX since that's the only library which supports DLPack but does not have the .device attribute. Running dlpack tests is blocked on the lack of __array_namespace_info__, thus I think we should come back to this PR after ml-explore/mlx#4334 lands upstream.

Comment thread array_api_tests/dtype_helpers.py Outdated
Comment thread array_api_tests/dtype_helpers.py Outdated
Co-authored-by: Tim Head <betatim@gmail.com>
@prady0t

prady0t commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

@ev-br Care for another look?

Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Comment thread array_api_tests/dtype_helpers.py Outdated
try:
has_device = "device" in inspect.signature(xp.empty).parameters
except (TypeError, ValueError):
has_device = False

@ev-br ev-br Aug 26, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, this is getting messy. IIUC this whole pattern is meant to account for

  • MLX not reacting to inspect.signature (an exception or a non-informative *args, **kwargs signature, depending on the nanobind version)
  • CuPy genuinely missing the device argument
  • PyTorch raising a ValueError in inspect.signature(xp.empty)

However, I don't think this works correctly with e.g. pytorch: inspect.signature raises but the device argument is accepted:

In [10]: torch.empty(3, device="meta")
Out[10]: tensor(..., device='meta', size=(3,))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This problem is still there, is it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meta-comment: I see now that you updated the PR a while ago. Note however that github does not send any notifications on a push, so to even know that you updated it, somebody needs to have been proactively monitoring open PRs across repositories, and taht's not a realistic expectation, for better or worse. So when updating a PR, it makes sense to ping to notify others.

Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Comment thread array_api_tests/dtype_helpers.py
Co-authored-by: Evgeni Burovski <evgeny.burovskiy@gmail.com>

@ev-br ev-br left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now, thanks @prady0t for the patch, @betatim for the review.
Let's give a go

@ev-br
ev-br merged commit b6a9d9f into data-apis:master Sep 1, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test fails if no device parameter.

3 participants