jax-ml/jax · error · ValueError

{self} should have the same core axis name and number of cor

Error message

{self} should have the same core axis name and number of cores as the VectorSubcoreMesh {other_mesh}.

What it means

ScalarSubcoreMesh.check_is_compatible_with raises this when paired with a VectorSubcoreMesh whose core_axis_name or num_cores do not match the scalar mesh's axis_name/num_cores. Both meshes must describe the same set of SparseCores for the kernel to be well-formed.

Source

Thrown at jax/_src/pallas/mosaic/sc_core.py:91

  def size(self) -> int:
    return self.num_cores

  @property
  def dimension_semantics(self) -> Sequence[tpu_core.DimensionSemantics]:
    return [tpu_core.GridDimensionSemantics.CORE_PARALLEL]

  def discharges_effect(self, effect):
    del effect  # Unused.
    return False

  def check_is_compatible_with(self, other_mesh):
    if isinstance(other_mesh, ScalarSubcoreMesh):
      raise ValueError("You can't use two different ScalarSubcoreMeshes.")
    elif isinstance(other_mesh, VectorSubcoreMesh):
      if (self.axis_name == other_mesh.core_axis_name
          and self.num_cores == other_mesh.num_cores):
        return True
      raise ValueError(f"{self} should have the same core axis name and number"
                       f" of cores as the VectorSubcoreMesh {other_mesh}.")
    elif isinstance(other_mesh, tpu_core.TensorCoreMesh):
      if self.axis_name == other_mesh.axis_name:
        raise ValueError(
            f"{self} should have a different axis name from the TensorCoreMesh"
            f" {other_mesh}."
        )
      return True
    return super().check_is_compatible_with(other_mesh)

  @property
  def supported_memory_spaces(self) -> Sequence[Any]:
    return [
        tpu_core.MemorySpace.VMEM_SHARED,
        tpu_core.MemorySpace.SMEM,
        tpu_core.MemorySpace.SEMAPHORE,
    ]

View on GitHub (pinned to 1e1c6a8fc0)

Solutions

  1. Align the ScalarSubcoreMesh.axis_name with VectorSubcoreMesh.core_axis_name
  2. Set the same num_cores on both meshes (derive both from get_sparse_core_info())
  3. Prefer reusing one mesh definition/config object for both

Example fix

# before
scalar_mesh.check_is_compatible_with(pl_mosaic.VectorSubcoreMesh(core_axis_name='sc', subcore_axis_name='lane', num_cores=4))
# after (match axis name and core count)
scalar_mesh.check_is_compatible_with(pl_mosaic.VectorSubcoreMesh(core_axis_name=scalar_mesh.axis_name, subcore_axis_name='lane', num_cores=scalar_mesh.num_cores))
Defensive patterns

Strategy: validation

Validate before calling

def meshes_compatible(s, v):
    return s.axis_name == v.core_axis_name and s.num_cores == v.num_cores

Type guard

null

Try / catch

null

Prevention

When it happens

Trigger: Passing a VectorSubcoreMesh to ScalarSubcoreMesh.check_is_compatible_with where axis names differ or core counts differ.

Common situations: Typos or renamed axis names between mesh definitions; hardcoding num_cores for one mesh while the other is derived from hardware.

Related errors


AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27). Data as JSON: /api/errors/6324efaed79a950e. Report an issue: GitHub.