{"record":{"id":"a8f70248c76de3d0","repo":"jax-ml/jax","slug":"the-global-shards-property-was-called-on-self-er","errorCode":null,"errorMessage":"The global_shards property was called on {self._error_repr()}.{self._origin_msg()}","messagePattern":"The global_shards property was called on (.+?)\\.(.+?)","errorType":"exception","errorClass":"ConcretizationTypeError","httpStatus":null,"severity":"error","filePath":"jax/_src/core.py","lineNumber":1250,"sourceCode":"  # Methods that are only valid for materialized arrays\n  def addressable_data(self, index):\n    raise ConcretizationTypeError(self,\n      f\"The addressable_data() method was called on {self._error_repr()}.\"\n      f\"{self._origin_msg()}\")\n\n  def delete(self):\n    raise ConcretizationTypeError(self,\n      f\"The delete() method was called on {self._error_repr()}.\"\n      f\"{self._origin_msg()}\")\n\n  def devices(self):\n    raise ConcretizationTypeError(self,\n      f\"The devices() method was called on {self._error_repr()}.\"\n      f\"{self._origin_msg()}\")\n\n  @property\n  def global_shards(self):\n    raise ConcretizationTypeError(self,\n      f\"The global_shards property was called on {self._error_repr()}.\"\n      f\"{self._origin_msg()}\")\n\n  def is_deleted(self):\n    raise ConcretizationTypeError(self,\n      f\"The is_deleted() method was called on {self._error_repr()}.\"\n      f\"{self._origin_msg()}\")\n\n  @property\n  def is_fully_addressable(self):\n    raise ConcretizationTypeError(self,\n      f\"The is_fully_addressable property was called on {self._error_repr()}.\"\n      f\"{self._origin_msg()}\")\n\n  @property\n  def is_fully_replicated(self):\n    raise ConcretizationTypeError(self,\n      f\"The is_fully_replicated property was called on {self._error_repr()}.\"","sourceCodeStart":1232,"sourceCodeEnd":1268,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/core.py#L1232-L1268","documentation":"ConcretizationTypeError raised when the Tracer.global_shards property is accessed. global_shards exposes per-shard metadata (Array committed buffers) only for materialized jax.Arrays; a tracer has no shard layout data attached, so the property stub raises during tracing.","triggerScenarios":"Reading `x.global_shards` on a traced value inside jit/pjit/grad/vmap/scan/remat or a custom rule; also via logging/printing that touches the property.","commonSituations":"Debugging SPMD/pjit sharding by printing global_shards, then leaving the print inside a traced function; monitoring sharding state inside a training loop that is jitted; refactoring sharding-inspection helpers into code paths later wrapped by vmap.","solutions":["Access global_shards outside the traced region, on the concrete arrays returned/accepted by jit.","Use jax.typeof(x) / x.sharding via aval information for sharding inspection under tracing (per the guidance in the adjacent code).","If shard info drives control flow, hoist it out: compute sharding before jit and pass it as a static parameter.","Strip debug prints of shard state from traced functions before production."],"exampleFix":"// before\n@jax.jit\ndef f(x):\n    print(x.global_shards)  # ConcretizationTypeError\n    return x * 2\n\n// after\n@jax.jit\ndef f(x):\n    return x * 2\n# outside: y = f(x); print(y.global_shards)","handlingStrategy":"type-guard","validationCode":"import jax\n\ndef get_global_shards(x):\n    if isinstance(x, jax.core.Tracer):\n        raise ValueError('inspect global_shards on concrete arrays, outside transforms')\n    return x.global_shards","typeGuard":"import jax\nfrom jax.core import Tracer\n\ndef shard_info_available(x) -> bool:\n    return isinstance(x, jax.Array) and not isinstance(x, Tracer)","tryCatchPattern":"from jax.errors import ConcretizationTypeError\ntry:\n    shards = x.global_shards\nexcept ConcretizationTypeError:\n    shards = ()  # traced; inspect after the transform returns","preventionTips":["Print/inspect shard layout only on jit inputs and outputs.","Strip debug prints from traced functions before committing.","Use jax.debug.print with static metadata instead of property access under tracing."],"tags":["jax","concretization","tracer","sharding","global-shards"],"backgroundTag":"jax-tracer-concretization-error","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}