{"record":{"id":"65e7a28c8d7c3413","repo":"jax-ml/jax","slug":"the-unsafe-buffer-pointer-method-was-called-on","errorCode":null,"errorMessage":"The unsafe_buffer_pointer() method was called on {self._error_repr()}.{self._origin_msg()}","messagePattern":"The unsafe_buffer_pointer\\(\\) method was called on (.+?)\\.(.+?)","errorType":"exception","errorClass":"ConcretizationTypeError","httpStatus":null,"severity":"error","filePath":"jax/_src/core.py","lineNumber":1283,"sourceCode":"  @property\n  def is_fully_replicated(self):\n    raise ConcretizationTypeError(self,\n      f\"The is_fully_replicated property was called on {self._error_repr()}.\"\n      f\"{self._origin_msg()}\")\n\n  def on_device_size_in_bytes(self):\n    raise ConcretizationTypeError(self,\n      f\"The on_device_size_in_bytes() method was called on {self._error_repr()}.\"\n      f\"{self._origin_msg()}\")\n\n  @property\n  def traceback(self):\n    raise ConcretizationTypeError(self,\n      f\"The traceback property was called on {self._error_repr()}.\"\n      f\"{self._origin_msg()}\")\n\n  def unsafe_buffer_pointer(self):\n    raise ConcretizationTypeError(self,\n      f\"The unsafe_buffer_pointer() method was called on {self._error_repr()}.\"\n      f\"{self._origin_msg()}\")\n\n_jax.set_tracer_class(Tracer)\n\n# these can be used to set up forwarding of properties and instance methods from\n# Tracer instances to the underlying avals\naval_property = namedtuple(\"aval_property\", [\"fget\"])\naval_method = namedtuple(\"aval_method\", [\"fun\"])\n\npytype_aval_mappings[Tracer] = lambda x: x.aval\ndtypes.register_canonicalize_value_handler(Tracer, None)\n\ndef check_eval_args(args):\n  for arg in args:\n    if isinstance(arg, Tracer):\n      raise escaped_tracer_error(arg)\n","sourceCodeStart":1265,"sourceCodeEnd":1301,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/core.py#L1265-L1301","documentation":"Raised by JAX when unsafe_buffer_pointer() is called on a Tracer (an abstract, not-yet-computed value) during tracing, e.g. inside jit/vmap/grad. The tracer has no concrete memory address because the underlying array data does not exist until the traced computation is compiled and executed.","triggerScenarios":"Calling .unsafe_buffer_pointer() (or passing an array to something that calls it, like some C-extension/CFFI code or custom buffer protocols) on an array that is a Tracer inside jax.jit, vmap, grad, or another transformation.","commonSituations":"Passing jitted arrays into external libraries expecting raw pointers (e.g., custom CUDA kernels, PyTorch interop, NumPy C-API consumers); using .data_ptr()-style APIs inside functions decorated with @jax.jit.","solutions":["Move the pointer access outside the traced function and pass the concrete array instead","Use static_argnums/static_argnames so the offending argument stays concrete","If the value must be concrete inside the trace, hoist the computation: compute pointer after jit returns the compiled result","Replace buffer-pointer logic with JAX-native APIs (e.g., jax.dlpack for interop)"],"exampleFix":"// before\n@jax.jit\ndef f(x):\n    return do_something_with_ptr(x.unsafe_buffer_pointer())\n\n// after\n@jax.jit\ndef f(x):\n    return jnp.sum(x)\ny = f(x)  # concrete now\nptr = y.unsafe_buffer_pointer()","handlingStrategy":"validation","validationCode":"import jax\ndef is_concrete_array(x):\n    return not isinstance(x, jax.core.Tracer) and hasattr(x, 'addressable_data')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never call buffer-pointer APIs inside @jax.jit functions","Pass concrete arrays (post-execution results) to external pointer consumers","Use jax.dlpack or jax.Array.__dlpack__ for cross-library transfer"],"tags":["jax","tracing","tracer","jit","buffer-pointer"],"backgroundTag":"jax-tracer-concretization","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}