{"record":{"id":"857c3b2a79ad9daf","repo":"jax-ml/jax","slug":"num-processes-must-be-a-positive-int-got-num-proc","errorCode":null,"errorMessage":"num_processes must be a positive int. Got num_processes={num_processes} of type {type(num_processes)}.","messagePattern":"num_processes must be a positive int\\. Got num_processes=(.+?) of type (.+?)\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"jax/_src/distributed.py","lineNumber":146,"sourceCode":"              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.')\n\n    if local_device_ids:\n      visible_devices = ','.join(str(x) for x in local_device_ids)","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/distributed.py#L128-L164","documentation":"num_processes must be a Python int (positive); strings, floats, or other types fail the isinstance check and raise this TypeError showing the received value and its type.","triggerScenarios":"jax.distributed.initialize(num_processes='8'), num_processes=8.0, or a value parsed from a config string without conversion.","commonSituations":"Env var read without int(); CLI argparse without type=int; YAML configs yielding strings; computed world sizes as floats.","solutions":["Convert: num_processes=int(os.environ['WORLD_SIZE'])","Use argparse with type=int for CLI flags","Assert isinstance(num_processes, int) and num_processes > 0 in launch scripts"],"exampleFix":"# before\njax.distributed.initialize(..., num_processes=os.environ['NRANKS'])\n# after\njax.distributed.initialize(..., num_processes=int(os.environ['NRANKS']))","handlingStrategy":"type-guard","validationCode":"num_processes = int(os.environ['WORLD_SIZE'])\nassert isinstance(num_processes, int) and num_processes > 0","typeGuard":"def valid_world_size(v) -> bool:\n    return isinstance(v, int) and not isinstance(v, bool) and v > 0","tryCatchPattern":null,"preventionTips":["Cast config strings to int at load time","Add schema validation for distributed config files"],"tags":["jax","distributed","type-error","world-size"],"backgroundTag":"config-value-wrong-type","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}