{"record":{"id":"fa1f1a710d325677","repo":"jax-ml/jax","slug":"cannot-interpret-value-of-type-typ-as-an-abstrac","errorCode":null,"errorMessage":"Cannot interpret value of type {typ} as an abstract array; it does not have a dtype attribute","messagePattern":"Cannot interpret value of type (.+?) as an abstract array; it does not have a dtype attribute","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"jax/_src/core.py","lineNumber":1995,"sourceCode":"  for t in typ.__mro__[1:]:\n    if (aval_fn := pytype_aval_mappings.get(t)):\n      return aval_fn(x)\n  if isinstance(x, AbstractValue):\n    return x\n  if getattr(x, '__jax_array__', None) is not None:\n    raise ValueError(\n        'Triggering __jax_array__() during abstractification is no longer'\n        ' supported. To avoid this error, either explicitly convert your object'\n        ' using jax.numpy.array(), or register your object as a pytree.'\n    )\n  if hasattr(x, 'dtype'):\n    aval = ShapedArray(\n        np.shape(x),\n        dtypes.canonicalize_dtype(x.dtype, allow_extended_dtype=True),\n        weak_type=getattr(x, \"weak_type\", False),\n    )\n    return update_aval_with_sharding(aval, getattr(x, 'sharding', None))\n  raise TypeError(\n      f\"Cannot interpret value of type {typ} as an abstract array; it \"\n      \"does not have a dtype attribute\")\n\n\n# TODO(phawkins): the return type should be AbstractValue.\ndef typeof(x: Any) -> Any:\n  \"\"\"Return the JAX type (i.e. :class:`AbstractValue`) of the input.\n\n  Raises a ``TypeError`` if ``x`` is not a valid JAX type.\n  \"\"\"\n  typ = type(x)\n  if (aval_fn := pytype_aval_mappings.get(typ)):  # fast path\n    return aval_fn(x)\n  for t in typ.__mro__[1:]:\n    if (aval_fn := pytype_aval_mappings.get(t)):\n      return aval_fn(x)\n  if getattr(x, '__jax_array__', None) is not None:\n    raise ValueError(","sourceCodeStart":1977,"sourceCodeEnd":2013,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/core.py#L1977-L2013","documentation":"Raised by JAX's abstractification (get_aval) when a Python object has no registered abstract-value handler, no __jax_array__, and no dtype attribute, so JAX cannot interpret it as an array. It is the generic 'not a valid JAX type' failure at the abstract-value layer.","triggerScenarios":"Passing arbitrary Python objects (strings, dicts, arbitrary class instances, None) where an array is expected inside jit/pmap/vmap/grad; passing unregistered custom objects without dtype.","commonSituations":"Forgetting to convert lists/strings; passing a dict of params without treating it as a pytree; feeding None as an optional argument; passing objects like datetime or paths into traced functions.","solutions":["Convert inputs to jnp.array/np.array before the call","Register the object as a pytree if it is a container of arrays","Mark non-array arguments as static (static_argnums/static_argnames) if they should be treated as constants","Check for None/str values leaking into numerical code paths"],"exampleFix":"// before\njax.jit(fn)(\"hello\", x)\n\n// after\njax.jit(fn, static_argnums=0)(\"hello\", x)\n# or convert: jax.jit(fn)(jnp.array([1.0]), x)","handlingStrategy":"type-guard","validationCode":"import numpy as np, jax.numpy as jnp\ndef is_arraylike(x):\n    return isinstance(x, (int, float, bool, complex, np.ndarray)) or hasattr(x, 'dtype') or hasattr(x, '__jax_array__')\nassert is_arraylike(x), f'cannot pass {type(x)} to jax'","typeGuard":"def is_arraylike(x) -> bool:\n    return isinstance(x, (int, float, bool, complex, np.ndarray)) or hasattr(x, 'dtype') or hasattr(x, '__jax_array__')","tryCatchPattern":null,"preventionTips":["Validate inputs at API boundaries with hasattr(x, 'dtype')","Wrap public functions with a conversion step: x = jnp.asarray(x)","Keep strings/config out of traced signatures; use static args"],"tags":["jax","type-error","abstract-value","tracing","dtype"],"backgroundTag":"jax-invalid-argument-type","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}