ENH: fix is_jax_array under torch.compile - #464
Open
lucascolley wants to merge 1 commit into
Open
Conversation
This fixes errors like the following: ``` E torch._dynamo.exc.UserError: GetAttrVariable(TupleVariable(length=0), dtype) has no type E For more information about this error, see: https://pytorch.org/docs/main/generated/exportdb/index.html#unknown-python-type E E from user code: E File "/Users/lucascolley/ghq/github.com/data-apis/array-api-extra/src/array_api_extra/_lib/_helpers.py", line 612, in inner E res = func(*args, **kwargs) # pyright: ignore[reportCallIssue] E File "/Users/lucascolley/ghq/github.com/data-apis/array-api-extra/tests/main/test_at.py", line 47, in at_op E return meth(y, copy=copy, xp=xp) E File "/Users/lucascolley/ghq/github.com/data-apis/array-api-extra/src/array_api_extra/_at.py", line 374, in add E return self._op(_AtOp.ADD, operator.iadd, operator.add, y, copy=copy, xp=xp) # pyright: ignore[reportUnknownArgumentType] E File "/Users/lucascolley/ghq/github.com/data-apis/array-api-extra/src/array_api_extra/_at.py", line 289, in _op E (_compat.is_dask_array(idx) or _compat.is_jax_array(idx)) E File "/Users/lucascolley/ghq/github.com/data-apis/array-api-extra/.pixi/envs/tests-backends/lib/python3.14/site-packages/array_api_compat/common/_helpers.py", line 253, in is_jax_array E or _is_jax_zero_gradient_array(x) E File "/Users/lucascolley/ghq/github.com/data-apis/array-api-extra/.pixi/envs/tests-backends/lib/python3.14/site-packages/array_api_compat/common/_helpers.py", line 84, in _is_jax_zero_gradient_array E cls = cast(Hashable, type(dtype)) ```
Member
|
Is there an MWE, ideally as a test or as an example for the added comment? attrs on empty tuples is a tad cryptic, and I'm not sure how to trigger it---or check if the whole _is_zero_grad_array can be removed, as the comment above indicates will be possible "at some point". |
Member
Author
|
calling |
Member
|
Great. Add an otherwise failing code snippet to the comment? |
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.
This fixes errors like the following:
cc @crusaderky for vis