Fix test failure if no device parameter - #459
Open
prady0t wants to merge 8 commits into
Open
Conversation
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
ev-br
reviewed
Aug 20, 2026
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Member
|
I tried testing this PR with MLX since that's the only library which supports DLPack but does not have the |
3 tasks
betatim
reviewed
Aug 21, 2026
betatim
reviewed
Aug 21, 2026
Co-authored-by: Tim Head <betatim@gmail.com>
Contributor
Author
|
@ev-br Care for another look? |
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
ev-br
reviewed
Aug 26, 2026
| try: | ||
| has_device = "device" in inspect.signature(xp.empty).parameters | ||
| except (TypeError, ValueError): | ||
| has_device = False |
Member
There was a problem hiding this comment.
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, **kwargssignature, depending on thenanobindversion) - CuPy genuinely missing the
deviceargument - 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,))
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #458