{"record":{"id":"4fc4344143fe6abc","repo":"jax-ml/jax","slug":"can-t-make-a-peer-reference-into-a-multicast-refer","errorCode":null,"errorMessage":"Can't make a peer reference into a multicast reference.","messagePattern":"Can't make a peer reference into a multicast reference\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/pallas/mosaic_gpu/core.py","lineNumber":1117,"sourceCode":"\ndef multicast_ref(\n    ref: _Ref,\n    collective_axes: Hashable | tuple[Hashable, ...],\n) -> pallas_core.TransformedRef:\n  \"\"\"Return a multicast reference for cross-device operations.\n\n  Args:\n    ref: The reference to transform.\n    collective_axes: The JAX mesh axes indicating the devices to operate on.\n  \"\"\"\n  if not isinstance(collective_axes, tuple):\n    collective_axes = (collective_axes,)\n  if not isinstance(ref, pallas_core.TransformedRef):\n    if not isinstance(jax_core.typeof(ref), state_types.AbstractRef):\n      raise TypeError(\"ref must be a reference\")\n    ref = pallas_core.TransformedRef(ref, transforms=())\n  if any(isinstance(t, PeerMemRef) for t in ref.transforms):\n    raise ValueError(\"Can't make a peer reference into a multicast reference.\")\n  return pallas_core.TransformedRef(\n      ref.ref, (*ref.transforms, MulticastRef(collective_axes)),\n  )\n\n\ndef transpose_ref(\n    ref: pallas_core.TransformedRef | Any,\n    permutation: tuple[int, ...],\n) -> pallas_core.TransformedRef:\n  assert hasattr(ref, \"memory_space\")\n  if ref.memory_space == MemorySpace.TMEM:\n    raise ValueError(\"Can't transpose a TMEM reference.\")\n  return ref.transpose(permutation)\n\n\n@tree_util.register_dataclass\n@dataclasses.dataclass(frozen=True)\nclass ExtractAliasedRef(state_types.Transform):","sourceCodeStart":1099,"sourceCodeEnd":1135,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/pallas/mosaic_gpu/core.py#L1099-L1135","documentation":"multicast_ref refuses references that already carry a PeerMemRef transform: a reference cannot target one specific peer device and simultaneously multicast across a collective axis.","triggerScenarios":"Calling multicast_ref(remote_ref(...)) — composing peer and multicast transforms on the same reference during a collective store.","commonSituations":"TPU collective kernels mixing remote (single-device) and multicast (multi-device) stores on the same output reference.","solutions":["Use separate references for peer stores and multicast stores","Create the multicast ref from the underlying ref before wrapping with remote_ref on a different ref","Restructure the store sequence so transforms are never composed"],"exampleFix":"// before\np = remote_ref(out_ref, 1)\nm = multicast_ref(p, 'dev')\n\n// after\nm = multicast_ref(out_ref, 'dev')","handlingStrategy":"validation","validationCode":"assert not any(isinstance(t, PeerMemRef) for t in ref.transforms), 'already a peer ref'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use distinct refs for multicast vs peer stores"],"tags":["jax","pallas","mosaic-gpu","multicast","peer-memory"],"backgroundTag":"conflicting-reference-transforms","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}