{"record":{"id":"648b6e3953b548c8","repo":"jax-ml/jax","slug":"mesh-has-self-num-cores-cores-but-the-current-t","errorCode":null,"errorMessage":"Mesh has {self.num_cores} cores, but the current TPU chip has only {sc_info.num_cores} SparseCores","messagePattern":"Mesh has (.+?) cores, but the current TPU chip has only (.+?) SparseCores","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/pallas/mosaic/sc_core.py","lineNumber":55,"sourceCode":"    RuntimeError: If the current TPU does not have SparseCores.\n  \"\"\"\n  sc_info = tpu_info.get_tpu_info().sparse_core\n  if sc_info is None:\n    raise RuntimeError(\"The current TPU does not have SparseCores\")\n  return sc_info\n\n\n@dataclasses.dataclass(frozen=True, kw_only=True)\nclass ScalarSubcoreMesh(pallas_core.Mesh):\n  axis_name: str\n  num_cores: int = dataclasses.field(\n      default_factory=lambda: get_sparse_core_info().num_cores\n  )\n\n  def __post_init__(self):\n    sc_info = get_sparse_core_info()\n    if self.num_cores > sc_info.num_cores:\n      raise ValueError(\n          f\"Mesh has {self.num_cores} cores, but the current TPU chip has only\"\n          f\" {sc_info.num_cores} SparseCores\"\n      )\n\n  @property\n  def core_type(self) -> tpu_core.CoreType:\n    return tpu_core.CoreType.SC_SCALAR_SUBCORE\n\n  @property\n  def default_memory_space(self) -> tpu_core.MemorySpace:\n    return tpu_core.MemorySpace.HBM\n\n  @property\n  def shape(self):\n    return collections.OrderedDict({self.axis_name: self.num_cores})\n\n  @property\n  def size(self) -> int:","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/pallas/mosaic/sc_core.py#L37-L73","documentation":"SparseCore mesh dataclasses (ScalarSubcoreMesh etc.) validate their num_cores against the actual SparseCore count of the current chip in __post_init__. Requesting more SC cores than physically present raises ValueError immediately.","triggerScenarios":"Constructing a SparseCore mesh with num_cores greater than get_sparse_core_info().num_cores, e.g. num_cores=8 on a chip with 4 SparseCores.","commonSituations":"Hardcoding core counts from a different TPU generation; scaling num_cores with a config value tuned for a larger pod slice; defaulting num_cores from a stale cached tpu_info.","solutions":["Omit num_cores to use the chip default: num_cores defaults to get_sparse_core_info().num_cores","Set num_cores = min(requested, get_sparse_core_info().num_cores) computed at runtime"],"exampleFix":"# before\nmesh = ScalarSubcoreMesh(axis_name='sc', num_cores=8)  # chip has 4\n# after\nmesh = ScalarSubcoreMesh(axis_name='sc')  # uses chip's SparseCore count","handlingStrategy":"validation","validationCode":"sc_info = get_sparse_core_info()\nnum_cores = min(num_cores, sc_info.num_cores)","typeGuard":null,"tryCatchPattern":"try:\n    mesh = ScalarSubcoreMesh(axis_name='sc', num_cores=n)\nexcept ValueError:\n    mesh = ScalarSubcoreMesh(axis_name='sc')  # chip default","preventionTips":["Let num_cores default to the chip's SparseCore count","Never hardcode SC core counts across TPU generations"],"tags":["jax","pallas","tpu","sparsecore","hardware","resource-limits"],"backgroundTag":"resource-count-exceeds-limit","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}