{"record":{"id":"a55ca3850f8ed1ce","repo":"jax-ml/jax","slug":"you-can-t-use-two-different-scalarsubcoremeshes","errorCode":null,"errorMessage":"You can't use two different ScalarSubcoreMeshes.","messagePattern":"You can't use two different ScalarSubcoreMeshes\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/pallas/mosaic/sc_core.py","lineNumber":86,"sourceCode":"  @property\n  def shape(self):\n    return collections.OrderedDict({self.axis_name: self.num_cores})\n\n  @property\n  def size(self) -> int:\n    return self.num_cores\n\n  @property\n  def dimension_semantics(self) -> Sequence[tpu_core.DimensionSemantics]:\n    return [tpu_core.GridDimensionSemantics.CORE_PARALLEL]\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, ScalarSubcoreMesh):\n      raise ValueError(\"You can't use two different ScalarSubcoreMeshes.\")\n    elif isinstance(other_mesh, VectorSubcoreMesh):\n      if (self.axis_name == other_mesh.core_axis_name\n          and self.num_cores == other_mesh.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 VectorSubcoreMesh {other_mesh}.\")\n    elif isinstance(other_mesh, tpu_core.TensorCoreMesh):\n      if self.axis_name == other_mesh.axis_name:\n        raise ValueError(\n            f\"{self} should have a different axis name from the TensorCoreMesh\"\n            f\" {other_mesh}.\"\n        )\n      return True\n    return super().check_is_compatible_with(other_mesh)\n\n  @property\n  def supported_memory_spaces(self) -> Sequence[Any]:\n    return [","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/pallas/mosaic/sc_core.py#L68-L104","documentation":"Raised by ScalarSubcoreMesh.check_is_compatible_with when a Pallas Mosaic SparseCore kernel's mesh is combined with another ScalarSubcoreMesh. The mesh compatibility API rejects using two distinct scalar subcore meshes in the same computation, because there is only one scalar subcore per SparseCore.","triggerScenarios":"Calling check_is_compatible_with on a ScalarSubcoreMesh with another ScalarSubcoreMesh instance; e.g. combining SparseCore pallas grids/meshes where both sides are scalar subcore meshes.","commonSituations":"Building a multi-mesh Pallas TPU kernel (mixing TensorCore and SparseCore meshes) and accidentally passing two scalar subcore meshes; refactoring mesh setup and duplicating ScalarSubcoreMesh creation.","solutions":["Use a single shared ScalarSubcoreMesh instance for all participants","If you meant to express per-core parallelism, use VectorSubcoreMesh on the other side","Check the mesh types you pass to check_is_compatible_with before combining"],"exampleFix":"# before\nmesh_a = pl_mosaic.ScalarSubcoreMesh(...)\nmesh_b = pl_mosaic.ScalarSubcoreMesh(...)\nmesh_a.check_is_compatible_with(mesh_b)  # raises\n# after\nmesh_a = pl_mosaic.ScalarSubcoreMesh(...)\nmesh_a.check_is_compatible_with(vector_mesh)  # VectorSubcoreMesh with matching axis/cores","handlingStrategy":"type-guard","validationCode":"def is_scalar_mesh(m): return isinstance(m, pl_mosaic.ScalarSubcoreMesh)","typeGuard":"import jax._src.pallas.mosaic.sc_core as sc\ndef is_scalar_subcore_mesh(m) -> bool:\n    return isinstance(m, sc.ScalarSubcoreMesh)","tryCatchPattern":"try:\n    a.check_is_compatible_with(b)\nexcept ValueError as e:\n    raise ConfigError(f'Mesh mismatch: {e}') from e","preventionTips":["Create one module-level mesh instance and reuse it","Assert mesh types before combining kernels"],"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"}