{"record":{"id":"e6e8b81f17b3cadc","repo":"jax-ml/jax","slug":"bitcast-ref-with-dynamic-size-is-not-supported","errorCode":null,"errorMessage":"Bitcast ref with dynamic size is not supported.","messagePattern":"Bitcast ref with dynamic size is not supported\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"jax/_src/state/types.py","lineNumber":354,"sourceCode":"    return self.type.shape\n\n  @property\n  def dtype(self):\n    if not hasattr(self.type, \"dtype\"):\n      raise AttributeError(f\"{self!r} has no `dtype`.\") from None\n    return self.type.dtype\n\n  ndim = property(lambda self: len(self.shape))\n  size = property(lambda self: math.prod(self.shape))\n  T = property(lambda self: self.transpose(tuple(reversed(range(self.ndim)))))\n\n  @property\n  def at(self) -> RefIndexer:\n    return RefIndexer(self)\n\n  def bitcast(self, dtype):\n    if self.is_dynamic_size:\n      raise NotImplementedError(\n          \"Bitcast ref with dynamic size is not supported.\"\n      )\n    dtype = dtypes.dtype(dtype)\n    if self.multiref:\n      return TransformedRef(self, (BitcastTransform(dtype),))\n    return TransformedRef(self.ref, (*self.transforms, BitcastTransform(dtype)))\n\n  def reshape(self, *shape):\n    if self.is_dynamic_size:\n      raise NotImplementedError(\n          \"Reshape ref with dynamic size is not supported.\"\n      )\n    if len(shape) == 1 and isinstance(shape[0], tuple):\n      shape = shape[0]\n    input_shape = tuple(operator.index(s) for s in self.shape)\n    shape = _canonicalize_reshape(input_shape, shape)\n    if self.multiref:\n      return TransformedRef(self, (ReshapeTransform(shape),))","sourceCodeStart":336,"sourceCodeEnd":372,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/state/types.py#L336-L372","documentation":"TransformedRef.bitcast raises NotImplementedError when the ref has a dynamic size (shape containing tracers/int32 symbolic dims), because bitcasting requires static sizes to compute the new shape.","triggerScenarios":"Calling .bitcast(dtype) on a ref created inside a transform with dynamic shapes (e.g. inside remat/pmap or with polymorphic shapes).","commonSituations":"Using bitcast inside dynamically shaped computations; migration from static-shape code to dynamic shapes.","solutions":["Hoist the bitcast outside the dynamic-shape region","Use static shapes for that portion of the computation","Reinterpret bytes manually via get/put with converted values"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"if ref.is_dynamic_size:\n    raise RuntimeError(\"bitcast unsupported here; hoist out of dynamic region\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid bitcast on dynamically shaped refs","Keep bitcasts in static-shape scopes"],"tags":["jax","bitcast","dynamic-shape"],"backgroundTag":"unsupported-dynamic-shape-operation","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}