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 ScalarSubcoreMesh {other_mesh}.

What it means

VectorSubcoreMesh.check_is_compatible_with raises when paired with a ScalarSubcoreMesh whose axis_name/num_cores do not match the vector mesh's core_axis_name/num_cores. The two mesh views must agree on which cores they span.

Source

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

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

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

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

  @property
  def supported_memory_spaces(self) -> Sequence[Any]:
    return [

View on GitHub (pinned to 1e1c6a8fc0)

Solutions

  1. Make scalar_mesh.axis_name == vector_mesh.core_axis_name
  2. Make num_cores equal on both
  3. Centralize mesh constants in one config

Example fix

# before
vec.check_is_compatible_with(pl_mosaic.ScalarSubcoreMesh(axis_name='sparse', num_cores=4))
# after
vec.check_is_compatible_with(pl_mosaic.ScalarSubcoreMesh(axis_name=vec.core_axis_name, num_cores=vec.num_cores))
Defensive patterns

Strategy: validation

Validate before calling

def compatible(v, s):
    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: Mixing VectorSubcoreMesh and ScalarSubcoreMesh with differing core axis names or core counts.

Common situations: Renaming an axis in one mesh definition but not the other; deriving num_cores differently (hardcode vs hardware query).

Related errors


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