{"record":{"id":"89854235ab4f5f25","repo":"jax-ml/jax","slug":"the-name-method-is-not-available-on-self-err","errorCode":null,"errorMessage":"The '{name}' method is not available on {self._error_repr()}.{self._origin_msg()}","messagePattern":"The '(.+?)' method is not available on (.+?)\\.(.+?)","errorType":"exception","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"jax/_src/core.py","lineNumber":1178,"sourceCode":"  def __setitem__(self, key, value):\n    if not hasattr(self.aval, \"_setitem\"):\n      raise TypeError(f\"Value of type {type(self)} is not indexable.\")\n    return self.aval._setitem(self, key, value)\n\n  # NumPy also only looks up special methods on classes.\n  def __array_module__(self, types):\n    if not hasattr(self.aval, \"_array_module\"):\n      raise TypeError(f\"Value of type {type(self)} is not compatible with the Array API.\")\n    return self.aval._array_module(self, types)\n\n  def __getattr__(self, name):\n    # if the aval property raises an AttributeError, gets caught here\n    assert not config.enable_checks.value or name != \"aval\"\n\n    # These must raise AttributeError in the base class for backward compatibility.\n    # TODO(jakevdp): can we change this and make them raise NotImplementedError instead?\n    if name in [\"block_until_ready\", \"copy_to_host_async\"]:\n      raise AttributeError(\n        f\"The '{name}' method is not available on {self._error_repr()}.\"\n        f\"{self._origin_msg()}\")\n\n    if name == 'sharding':\n      raise AttributeError(\n        f\"The 'sharding' attribute is not available on {self._error_repr()}. \"\n        \"To query sharding information on tracers, use `jax.typeof(x)`.\")\n\n    try:\n      attr = getattr(self.aval, name)\n    except AttributeError as err:\n      raise AttributeError(\n          f\"{self.__class__.__name__} has no attribute {name}\"\n      ) from err\n    else:\n      t = type(attr)\n      if t is aval_property:\n        return attr.fget(self)","sourceCodeStart":1160,"sourceCodeEnd":1196,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/core.py#L1160-L1196","documentation":"Raised by JAXTracer.__getattr__ when code calls block_until_ready() or copy_to_host_async() on a JAX Tracer. These methods exist on concrete, dispatched jax.Array objects (which are backed by device buffers) but are meaningless for abstract tracer values recorded during jit/grad/vmap tracing, so attribute lookup is blocked with an AttributeError for backward compatibility.","triggerScenarios":"Calling x.block_until_ready() or x.copy_to_host_async() on a value produced inside a jax.jit/jax.grad/jax.vmap/scan/cond traced function; timing helpers or async-machinery shims applied uniformly to 'array-like' objects that turn out to be tracers; decorators that force synchronization on all returned arrays.","commonSituations":"Profiling/timing utility code that calls block_until_ready() on every array it sees, executed on traced intermediates; wrapping jitted functions with generic 'sync after op' plumbing; custom __getattr__ forwarding layers that surface these names on tracers.","solutions":["Only call block_until_ready()/copy_to_host_async() on concrete outputs after the transformation has run, never inside traced code.","Guard with isinstance(x, jax.Array) (or type(x) is not a Tracer) before calling sync methods in generic helpers.","For timing jitted code, time the returned concrete array: y = f(x); y.block_until_ready().","Use jax.debug.print / jax.block_until_ready() top-level helpers rather than method calls on possibly-traced values."],"exampleFix":"# before\n@jax.jit\ndef f(x):\n    y = x * 2\n    y.block_until_ready()   # AttributeError on Tracer\n    return y\n\n# after\n@jax.jit\ndef f(x):\n    return x * 2\ny = f(x)\ny.block_until_ready()       # concrete jax.Array: fine","handlingStrategy":"type-guard","validationCode":"import jax\ndef sync_if_concrete(x):\n    if isinstance(x, jax.Array) and not isinstance(x, jax.core.Tracer):\n        x.block_until_ready()\n    return x","typeGuard":"import jax\ndef is_syncable_array(x) -> bool:\n    return isinstance(x, jax.Array) and not isinstance(x, jax.core.Tracer)","tryCatchPattern":null,"preventionTips":["Only call block_until_ready()/copy_to_host_async() on outputs after jit returns.","In generic helpers, guard sync calls with isinstance(x, jax.Array) and a tracer check.","Time jitted code by syncing the returned concrete array, not intermediates.","Keep async plumbing out of traced function bodies."],"tags":["jax","tracer","block-until-ready","async","attribute-access"],"backgroundTag":"method-missing-on-duck-typed-object","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}