{"record":{"id":"88003125e0282f6e","repo":"sgl-project/sglang","slug":"missing-value-for-a-expected-e-g-a-2-4","errorCode":null,"errorMessage":"missing value for {a} (expected e.g. `{a} 2,4`)","messagePattern":"missing value for (.+?) \\(expected e\\.g\\. `(.+?) 2,4`\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/kernels/ops/communication/mp.py","lineNumber":99,"sourceCode":"    psutil.wait_procs(descendants, timeout=5)\n\n\ndef _extract_num_gpus_override(\n    argv: list[str],\n) -> tuple[list[int] | None, list[str]]:\n    \"\"\"Pop `--num-gpu(s)` flags out of `argv` and return them separately.\n\n    Accepts `--num-gpu N`, `--num-gpu=N`, `--num-gpus ...`, and comma-separated\n    lists like `--num-gpu 2,4,8`. May be repeated.\n    \"\"\"\n    override: list[int] = []\n    remaining: list[str] = []\n    i = 0\n    while i < len(argv):\n        a = argv[i]\n        if a in (\"--num-gpu\", \"--num-gpus\"):\n            if i + 1 >= len(argv):\n                raise ValueError(f\"missing value for {a} (expected e.g. `{a} 2,4`)\")\n            override.extend(int(x) for x in argv[i + 1].split(\",\"))\n            i += 2\n        elif a.startswith(\"--num-gpu=\") or a.startswith(\"--num-gpus=\"):\n            _, val = a.split(\"=\", 1)\n            override.extend(int(x) for x in val.split(\",\"))\n            i += 1\n        else:\n            remaining.append(a)\n            i += 1\n    return (override if override else None), remaining\n\n\ndef multigpu_launch(\n    name: str,\n    file: str,\n    num_gpus: Sequence[int],\n    env_key: str,\n    inner: Callable[[], int],","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/kernels/ops/communication/mp.py#L81-L117","documentation":"_extract_num_gpus_override parses --num-gpu/--num-gpus from a test/bench command line. The space-separated form requires a following value token (e.g. `--num-gpu 2,4`); if the flag is the last argument with no value after it, the parser raises this ValueError before anything launches.","triggerScenarios":"Running a multi-GPU pytest/benchmark with `--num-gpu` as the final CLI token, e.g. `pytest test_x.py --num-gpu` (missing the list).","commonSituations":"Shell scripts where the GPU list variable is empty (`--num-gpu $GPUS` with GPUS unset) or a truncated copy-pasted command line.","solutions":["Provide the value: `--num-gpu 2,4` or the equals form `--num-gpu=2,4`","Quote/defaults the variable in scripts: `--num-gpu ${GPUS:-1,2}` or skip the flag entirely when unset"],"exampleFix":"# before\npytest test_mp.py --num-gpu\n# after\npytest test_mp.py --num-gpu=2,4","handlingStrategy":"validation","validationCode":"# in shell: prefer the equals form which cannot dangle\n# pytest bench.py --num-gpu=2,4","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use --num-gpu=<list> instead of the space-separated form in scripts","Default empty variables: ${GPUS:-2,4} so the flag never trails without a value"],"tags":["cli-parsing","multi-gpu","argument-validation"],"backgroundTag":"missing-cli-argument-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}