jax-ml/jax · warning · ValueError
Unrecognized {kind=} expected one of {list(_dtype_kinds.keys
Error message
Unrecognized {kind=} expected one of {list(_dtype_kinds.keys())}, or a compatible input for jnp.dtype() What it means
jax.dtypes.isdtype implements the Array API: kind may be a recognized kind string ('bool','signed integer',...), a dtype-like, or tuples thereof. A string that is neither a known kind nor constructible by np.dtype raises ValueError; non-string non-dtype inputs raise TypeError.
Source
Thrown at jax/_src/dtypes.py:672
If ``kind`` is a tuple, then return True if dtype matches any entry of the tuple.
Returns:
True or False
"""
the_dtype = np.dtype(dtype)
kind_tuple: tuple[str | DTypeLike, ...] = (
kind if isinstance(kind, tuple) else (kind,)
)
options: set[DType] = set()
for kind in kind_tuple:
if isinstance(kind, str) and kind in _dtype_kinds:
options.update(_dtype_kinds[kind])
continue
try:
_dtype = np.dtype(kind)
except TypeError as e:
if isinstance(kind, str):
raise ValueError(
f"Unrecognized {kind=} expected one of {list(_dtype_kinds.keys())}, "
"or a compatible input for jnp.dtype()")
raise TypeError(
f"Expected kind to be a dtype, string, or tuple; got {kind=}"
) from e
options.add(_dtype)
return the_dtype in options
def _jax_type(dtype: DType, weak_type: bool) -> JAXType:
"""Return the jax type for a dtype and weak type."""
if weak_type:
if dtype == bool:
return dtype
if dtype in _custom_float_dtypes:
return float
return type(dtype.type(0).item())
return dtypeView on GitHub (pinned to 1e1c6a8fc0)
Solutions
- Use exact Array API kind strings: 'bool', 'signed integer', 'unsigned integer', 'real floating', 'complex floating', 'numeric', 'integral'
- For simple checks prefer jnp.issubdtype(dtype, jnp.integer) / np.dtype comparisons
- Pass dtype-like objects (np.int32, 'int32') instead of ambiguous short names
Example fix
# before isdtype(dtype, kind='int') # after isdtype(dtype, kind='signed integer') # or isdtype(dtype, np.int64)
Defensive patterns
Strategy: type-guard
Validate before calling
valid_kinds = {'bool','signed integer','unsigned integer','integral','real floating','complex floating','numeric'}
if isinstance(kind, str) and kind not in valid_kinds:
kind = {'int': 'signed integer', 'uint': 'unsigned integer',
'float': 'real floating', 'complex': 'complex floating'}.get(kind, kind) Type guard
def is_valid_kind(k) -> bool:
valid = {'bool','signed integer','unsigned integer','integral','real floating','complex floating','numeric'}
return (isinstance(k, tuple) and all(is_valid_kind(x) for x in k)) or k in valid or _is_dtype_like(k) Try / catch
try:
isdtype(dtype, kind)
except ValueError:
isdtype(dtype, 'signed integer') # mapped kind Prevention
- Use exact Array API kind strings
- Prefer jnp.issubdtype for numpy-style checks
When it happens
Trigger: isdtype(dtype, kind='int') — 'int' is not a valid kind (valid: 'signed integer', 'unsigned integer', 'real floating', etc.); or passing an arbitrary object as kind.
Common situations: Users abbreviating kind names ('float' instead of 'real floating', 'int' instead of 'signed integer') when porting numpy-style checks to the Array API.
Related errors
- dtype cannot be None.
- unexpected input: {dtype=}
- Dtype {dtype} is not a valid JAX array type. Only arrays of
- Value '{x}' with dtype {dt} is not a valid JAX array type. O
- JAX only supports number, bool, and string dtypes, got dtype
AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27).
Data as JSON: /api/errors/61eddf5b3f6c3e63.
Report an issue: GitHub.