Skip to content
Open
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 src/array_api_compat/common/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ def _is_jax_zero_gradient_array(x: object) -> TypeGuard[_ZeroGradientArray]:
dtype = x.dtype # type: ignore[attr-defined]
except AttributeError:
return False

torch = sys.modules.get("torch")
if torch is not None and torch.compiler.is_compiling():
# Under torch.compile tracing, `type(dtype)` can't be modeled by Dynamo
# for objects it hasn't fully specialized (e.g. attrs on empty tuples).
return False

cls = cast(Hashable, type(dtype))
if not _issubclass_fast(cls, "numpy.dtypes", "VoidDType"):
return False
Expand Down
Loading