{"record":{"id":"65fb31390299c80b","repo":"jax-ml/jax","slug":"process-id-must-be-a-nonnegative-int-got-process","errorCode":null,"errorMessage":"process_id must be a nonnegative int. Got process_id={process_id} of type {type(process_id)}.","messagePattern":"process_id must be a nonnegative int\\. Got process_id=(.+?) of type (.+?)\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"jax/_src/distributed.py","lineNumber":143,"sourceCode":"      (coordinator_address, num_processes, process_id, local_device_ids) = (\n          clusters.ClusterEnv.auto_detect_unset_distributed_params(\n              coordinator_address,\n              num_processes,\n              process_id,\n              local_device_ids,\n              cluster_detection_method,\n              initialization_timeout,\n          )\n      )\n\n    if coordinator_address is None:\n      raise ValueError('coordinator_address should be defined.')\n    if num_processes is None:\n      raise ValueError('Number of processes must be defined.')\n    if process_id is None:\n      raise ValueError('The process id of the current process must be defined.')\n    if not isinstance(process_id, int):\n      raise TypeError(\"process_id must be a nonnegative int. \"\n                      f\"Got process_id={process_id} of type {type(process_id)}.\")\n    if not isinstance(num_processes, int):\n      raise TypeError(\"num_processes must be a positive int. \"\n                      f\"Got num_processes={num_processes} of type {type(num_processes)}.\")\n    if not (0 <= process_id < num_processes):\n      raise ValueError(\"process_id and num_processes must be nonnegative, with process_id < num_processes. \"\n                       f\"Got process_id={process_id}, num_processes={num_processes}.\")\n\n    self.coordinator_address = coordinator_address\n\n    # The default value of [::]:port tells the coordinator to bind to all\n    # available addresses on the same port as coordinator_address.\n    default_coordinator_bind_address = '[::]:' + coordinator_address.rsplit(':', 1)[1]\n    coordinator_bind_address = (coordinator_bind_address or\n                                os.environ.get('JAX_COORDINATOR_BIND_ADDRESS',\n                                               default_coordinator_bind_address))\n    if coordinator_bind_address is None:\n      raise ValueError('coordinator_bind_address should be defined.')","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/distributed.py#L125-L161","documentation":"process_id must be a Python int >= 0; passing a string, float, None-alternative, or negative value raises this TypeError with the offending value and type included in the message.","triggerScenarios":"jax.distributed.initialize(process_id='0') (string from env/parsing), process_id=-1, or a float like 0.0; any non-int type fails isinstance(process_id, int).","commonSituations":"Reading rank from environment without int() conversion; YAML/JSON config values parsed as strings; numpy ints usually pass but floats from computed ranks do not.","solutions":["Wrap in int(): process_id=int(os.environ['RANK'])","Validate 0 <= process_id < num_processes before calling initialize","Sanitize config files that store rank/world size as strings"],"exampleFix":"# before\njax.distributed.initialize(..., process_id=os.environ['RANK'])\n# after\njax.distributed.initialize(..., process_id=int(os.environ['RANK']))","handlingStrategy":"type-guard","validationCode":"process_id = int(os.environ['RANK'])\nassert isinstance(process_id, int) and process_id >= 0","typeGuard":"def valid_rank(v) -> bool:\n    return isinstance(v, int) and not isinstance(v, bool) and v >= 0","tryCatchPattern":null,"preventionTips":["Always int()-cast env/config values","Type CLI args with argparse type=int"],"tags":["jax","distributed","type-error","rank"],"backgroundTag":"config-value-wrong-type","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}