jax-ml/jax · error · AttributeError
{self!r} has no `sharding`.
Error message
{self!r} has no `sharding`. What it means
RefRValue.sharding raises AttributeError when the inner aval carries no sharding information (e.g. an unsharded or non-array aval).
Source
Thrown at jax/_src/state/types.py:548
raise AttributeError(
f"{self!r} has no `shape`."
) from None
@property
def dtype(self):
try:
return self.inner_aval.dtype # pyrefly: ignore[missing-attribute]
except AttributeError:
raise AttributeError(
f"{self!r} has no `dtype`."
) from None
@property
def sharding(self):
try:
return self.inner_aval.sharding # pyrefly: ignore[missing-attribute]
except AttributeError:
raise AttributeError(
f"{self!r} has no `sharding`."
) from None
@property
def manual_axis_type(self):
try:
return self.inner_aval.manual_axis_type # pyrefly: ignore[missing-attribute]
except AttributeError:
raise AttributeError(
f"{self!r} has no `manual_axis_type`."
) from None
@property
def mat(self):
return self.manual_axis_type
@core.aval_property
def at(self):View on GitHub (pinned to 1e1c6a8fc0)
Solutions
- Use getattr(ref, 'sharding', None)
- Check inner_aval type first
- Only inspect sharding on refs known to be sharded
Defensive patterns
Strategy: type-guard
Type guard
def ref_has_sharding(ref):
return hasattr(getattr(ref, "inner_aval", None), "sharding") Prevention
- Use getattr(ref, 'sharding', None)
- Only inspect sharding on sharded refs
When it happens
Trigger: Reading .sharding on a ref whose inner_aval doesn't expose a sharding property.
Common situations: Inspecting sharding in generic code across mixed ref types; refs created outside sharded contexts.
Related errors
- Mapped away dimension of inputs passed to vmap should be sha
- Unmapped values passed to vmap cannot be sharded along the m
- to_dlpack can only pack a dlpack tensor from an array on a s
- __dlpack__ only supported for unsharded arrays.
- unsafe_buffer_pointer() is supported only for unsharded arra
AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27).
Data as JSON: /api/errors/f57c9d636b48b935.
Report an issue: GitHub.