{"record":{"id":"23d70f3e7e4d4936","repo":"jax-ml/jax","slug":"cannot-resolve-attribute-name-from-attrs","errorCode":null,"errorMessage":"Cannot resolve attribute {name} from: {attrs}","messagePattern":"Cannot resolve attribute (.+?) from: (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"jax/_src/state/types.py","lineNumber":266,"sourceCode":"          raise TypeError(f\"Cannot select {ref}\")\n\n    assert isinstance(xs, Sequence), f\"Select expected sequence, got {xs}\"\n    types = tuple(_type(ref) for ref in xs)\n    if any(types[0] != t for t in types[1:]):\n      raise TypeError(f\"Cannot select from Refs of different types: {types}\")\n    return types[0]\n\n  def undo(self, x: core.AbstractValue) -> Transform:\n    raise NotImplementedError(type(self))\n\n  def pretty_print(self, context: core.JaxprPpContext) -> pp.Doc:\n    del context  # Unused.\n    return pp.text(f\"{{select({self.idx=})}}\")\n\n  def getattr(self, name: str, xs: Sequence[core.AbstractValue]) -> Any:\n    attrs = [getattr(x, name) for x in xs]\n    if any(attrs[0] != attr for attr in attrs[1:]):\n      raise TypeError(f\"Cannot resolve attribute {name} from: {attrs}\")\n    return attrs[0]\n\n\n@dataclasses.dataclass(slots=True)\nclass RefIndexer:\n  \"\"\"An object temporarily generated when doing ``ref.at``.\"\"\"\n  ref_or_view: Any\n\n  def __getitem__(self, slc) -> TransformedRef:\n    if not isinstance(slc, tuple):\n      slc = (slc,)\n    from jax._src.state import indexing\n    indexer = indexing.NDIndexer.from_indices_shape(slc, self.ref_or_view.shape)\n    if (\n        isinstance(self.ref_or_view, TransformedRef)\n        and not self.ref_or_view.multiref\n    ):\n      view = self.ref_or_view","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/state/types.py#L248-L284","documentation":"SelectTransform.getattr raises TypeError when the requested attribute differs across the elements (e.g. shapes differ across refs), so a single consistent value can't be returned.","triggerScenarios":"Accessing an aggregate property like shape or dtype on a multiref whose refs disagree on that attribute.","commonSituations":"Querying .shape on grouped refs after one was reshaped or created with different dimensions.","solutions":["Ensure all refs in the multiref share the attribute value","Query each ref individually instead of the group","Normalize shapes/dtypes at construction time"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"shapes = {r.shape for r in refs}\nassert len(shapes) == 1","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep grouped refs' attributes in sync","Query per-ref when in doubt"],"tags":["jax","multiref","attribute-mismatch"],"backgroundTag":"inconsistent-collection-state","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}