{"record":{"id":"cf26d36583007075","repo":"jax-ml/jax","slug":"device-id-s-must-be-an-int32-value-but-got-aval","errorCode":null,"errorMessage":"`device_id`s must be an int32 value, but got {aval.dtype}","messagePattern":"`device_id`s must be an int32 value, but got (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/pallas/primitives.py","lineNumber":1036,"sourceCode":"    args_tree,\n    device_id_type: DeviceIdType,\n):\n  (\n      sem_aval,\n      sem_transforms_avals,\n      value_aval,\n      device_id_aval,\n      core_index_aval,\n  ) = tree_util.tree_unflatten(args_tree, avals)\n  check_sem_avals(sem_aval, sem_transforms_avals, \"signal\")\n  if value_aval.dtype != jnp.dtype(\"int32\"):\n    raise ValueError(f\"Must signal an int32 value, but got {value_aval.dtype}\")\n  effs: set[effects.Effect] = {sem_effect}\n  if device_id_aval is not None:\n    device_id_flat_avals = tree_util.tree_leaves(device_id_aval)\n    for aval in device_id_flat_avals:\n      if aval.dtype != jnp.dtype(\"int32\"):\n        raise ValueError(\n            f\"`device_id`s must be an int32 value, but got {aval.dtype}\"\n        )\n    if device_id_type is DeviceIdType.MESH and isinstance(device_id_aval, dict):\n      for k in device_id_aval:\n        if not isinstance(k, tuple):\n          k = (k,)\n        for k_ in k:\n          effs.add(jax_core.NamedAxisEffect(k_))\n    else:\n      effs.add(pallas_core.comms_effect)\n  return [], effs\n\n\ndef _pp_device_id(device_id, context):\n  if device_id is None:\n    return pp.text(\"None\")\n  elif isinstance(device_id, dict):\n    items = []","sourceCodeStart":1018,"sourceCodeEnd":1054,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/pallas/primitives.py#L1018-L1054","documentation":"When semaphore_signal targets remote devices via device_id, every leaf of the device_id tree must be int32; any other dtype is rejected.","triggerScenarios":"Calling semaphore_signal(..., device_id=ids) where ids (or a dict entry) is int64/float rather than int32.","commonSituations":"Passing device ids obtained from jax.devices() indices or mesh computations as int64; mixed device_id dicts (MESH type) with non-int32 entries.","solutions":["Cast device ids to int32 before passing: tuple(int(i) for i in ids) via jnp.int32","Validate each leaf dtype of the device_id tree is int32"],"exampleFix":"// before\nsemaphore_signal(sem, 1, device_id=(0, dev_id))\n// after\nsemaphore_signal(sem, 1, device_id=(0, jnp.int32(dev_id)))","handlingStrategy":"validation","validationCode":"ids = jax.tree.map(lambda x: x.astype(jnp.int32), device_id)\nassert all(l.dtype == jnp.int32 for l in jax.tree.leaves(device_id))","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Normalize device id trees to int32 before signaling","Check dict values too when using MESH device_id_type"],"tags":["pallas","semaphore","dtype-validation","device-id","jax"],"backgroundTag":"dtype-mismatch","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}