{"record":{"id":"df0459fa194924df","repo":"jax-ml/jax","slug":"cannot-specify-both-devices-and-num-cores","errorCode":null,"errorMessage":"cannot specify both devices and num_cores","messagePattern":"cannot specify both devices and num_cores","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/pallas/mosaic/core.py","lineNumber":450,"sourceCode":"    return [\n        MemorySpace.VMEM,\n        MemorySpace.SMEM,\n        MemorySpace.CMEM,\n        MemorySpace.SEMAPHORE,\n    ]\n\n  @contextlib.contextmanager\n  def tracing_context(self):\n    yield\n\n\ndef create_tensorcore_mesh(\n    axis_name: str,\n    devices: Sequence[jax.Device] | None = None,\n    num_cores: int | None = None,\n) -> TensorCoreMesh:\n  if devices is not None and num_cores is not None:\n    raise ValueError(\"cannot specify both devices and num_cores\")\n  if num_cores is None:\n    if devices is None:\n      num_cores = _get_default_num_cores()\n    else:\n      num_cores = devices[0].num_cores\n  return TensorCoreMesh(axis_name=axis_name, num_cores=num_cores)\n\n\ndef _convert_semaphore_type_to_aval(\n    out_shape: SemaphoreType,\n) -> jax_core.AbstractValue:\n  return out_shape.get_array_aval()\n\n\npallas_core._out_shape_to_aval_mapping[SemaphoreType] = (\n    _convert_semaphore_type_to_aval\n)\n","sourceCodeStart":432,"sourceCodeEnd":468,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/pallas/mosaic/core.py#L432-L468","documentation":"create_tensorcore_mesh builds a TensorCoreMesh from either an explicit device sequence or a core count. Specifying both devices and num_cores is ambiguous and rejected outright.","triggerScenarios":"Calling jax._src.pallas.mosaic.core.create_tensorcore_mesh(axis_name, devices=[d], num_cores=4) — both keyword arguments supplied.","commonSituations":"Copy-pasted configuration evolving from num_cores to devices-based setup leaving both args in place; wrapper functions forwarding **kwargs that include both.","solutions":["Pass exactly one of devices or num_cores","If using devices, omit num_cores — it is derived from devices[0].num_cores","Audit wrapper functions that forward **kwargs to this API"],"exampleFix":"// before\nmesh = create_tensorcore_mesh('tc', devices=devs, num_cores=4)\n// after\nmesh = create_tensorcore_mesh('tc', devices=devs)","handlingStrategy":"validation","validationCode":"assert (devices is None) != (num_cores is None), 'pass exactly one of devices/num_cores'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Don't forward **kwargs blindly into mesh creation","Pick one configuration style (devices-based or count-based) for the codebase"],"tags":["jax","pallas","tpu","mesh","mutually-exclusive-args"],"backgroundTag":"conflicting-arguments","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}