{"record":{"id":"fbd11297189b99f2","repo":"jax-ml/jax","slug":"you-can-t-use-two-different-vectorsubcoremeshes","errorCode":null,"errorMessage":"You can't use two different VectorSubcoreMeshes.","messagePattern":"You can't use two different VectorSubcoreMeshes\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/pallas/mosaic/sc_core.py","lineNumber":171,"sourceCode":"\n  @property\n  def size(self) -> int:\n    return self.num_cores * self.num_subcores\n\n  @property\n  def dimension_semantics(self) -> Sequence[tpu_core.DimensionSemantics]:\n    return [\n        tpu_core.GridDimensionSemantics.CORE_PARALLEL,\n        tpu_core.GridDimensionSemantics.SUBCORE_PARALLEL,\n    ]\n\n  def discharges_effect(self, effect):\n    del effect  # Unused.\n    return False\n\n  def check_is_compatible_with(self, other_mesh):\n    if isinstance(other_mesh, VectorSubcoreMesh):\n      raise ValueError(\"You can't use two different VectorSubcoreMeshes.\")\n    elif isinstance(other_mesh, ScalarSubcoreMesh):\n      if (other_mesh.axis_name == self.core_axis_name\n          and other_mesh.num_cores == self.num_cores):\n        return True\n      raise ValueError(f\"{self} should have the same core axis name and number\"\n                       f\" of cores as the ScalarSubcoreMesh {other_mesh}.\")\n    elif isinstance(other_mesh, tpu_core.TensorCoreMesh):\n      if self.core_axis_name == other_mesh.axis_name:\n        raise ValueError(\n            f\"{self} should have a different core axis name from the\"\n            f\" TensorCoreMesh {other_mesh}.\"\n        )\n      if self.subcore_axis_name == other_mesh.axis_name:\n        raise ValueError(\n            f\"{self} should have a different subcore axis name from the\"\n            f\" TensorCoreMesh {other_mesh}.\"\n        )\n      return True","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/pallas/mosaic/sc_core.py#L153-L189","documentation":"Mirror of the scalar case: VectorSubcoreMesh.check_is_compatible_with rejects pairing with another VectorSubcoreMesh. Only one vector subcore mesh may participate, since it fully describes the SparseCore subcore layout.","triggerScenarios":"Calling VectorSubcoreMesh.check_is_compatible_with with another VectorSubcoreMesh instance.","commonSituations":"Two modules each creating their own VectorSubcoreMesh and later combining kernels/meshes.","solutions":["Share a single VectorSubcoreMesh instance","If one side should be scalar, use ScalarSubcoreMesh instead"],"exampleFix":"# before\nvec_a.check_is_compatible_with(vec_b)  # both VectorSubcoreMesh\n# after\nvec_a.check_is_compatible_with(scalar_mesh)  # ScalarSubcoreMesh with matching axis/cores","handlingStrategy":"type-guard","validationCode":"def is_vector_mesh(m): return isinstance(m, pl_mosaic.VectorSubcoreMesh)","typeGuard":"import jax._src.pallas.mosaic.sc_core as sc\ndef is_vector_subcore_mesh(m) -> bool:\n    return isinstance(m, sc.VectorSubcoreMesh)","tryCatchPattern":"null","preventionTips":["Instantiate VectorSubcoreMesh once and pass it around"],"tags":["jax","pallas","tpu","sparsecore","mesh-compat"],"backgroundTag":"mesh-incompatibility","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}