{"record":{"id":"42c1609c899c5fb7","repo":"sgl-project/sglang","slug":"duplicate-auxiliary-pp-tensor-name-r","errorCode":null,"errorMessage":"duplicate auxiliary PP tensor {name!r}","messagePattern":"duplicate auxiliary PP tensor (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/sampling/sampling_observer_pp.py","lineNumber":57,"sourceCode":"    if output is None:\n        return\n    if not isinstance(output, PipelineParallelAuxiliaryOutput):\n        raise RuntimeError(\n            \"auxiliary output does not support pipeline-parallel transport\"\n        )\n\n    output_tensors = output.to_pp_tensors()\n    if not output_tensors:\n        raise RuntimeError(\"auxiliary PP output must contain at least one tensor\")\n\n    for name, tensor in output_tensors.items():\n        if not isinstance(name, str) or not name:\n            raise RuntimeError(\"auxiliary PP tensor names must be non-empty strings\")\n        if not torch.is_tensor(tensor):\n            raise RuntimeError(f\"auxiliary PP output {name!r} is not a tensor\")\n        key = f\"{_OUTPUT_PREFIX}{name}\"\n        if key in tensors:\n            raise RuntimeError(f\"duplicate auxiliary PP tensor {name!r}\")\n        tensors[key] = tensor\n\n\ndef pop_auxiliary_output_from_pp_tensors(\n    tensors: MutableMapping[str, Any],\n    observer: Optional[SamplingObserver],\n) -> Optional[DeviceAuxiliaryOutput]:\n    output_tensors = {\n        key.removeprefix(_OUTPUT_PREFIX): value\n        for key, value in tensors.items()\n        if key.startswith(_OUTPUT_PREFIX)\n    }\n    if not output_tensors:\n        return None\n    if observer is None:\n        raise RuntimeError(\"received auxiliary PP output without a sampling observer\")\n    if not isinstance(observer, PipelineParallelSamplingObserver):\n        raise RuntimeError(","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/sampling/sampling_observer_pp.py#L39-L75","documentation":"The namespaced key for an auxiliary tensor already exists in the PP tensor dict, indicating the same output name was added twice (duplicate names across outputs or repeated call).","triggerScenarios":"Calling add_auxiliary_output_to_pp_tensors twice, or multiple outputs whose to_pp_tensors() share a field name.","commonSituations":"Attaching per-layer auxiliary outputs that each emit e.g. 'logits'; refactoring merged outputs with colliding field names.","solutions":["Namespace the tensor names per output (e.g. 'encoder.logits', 'decoder.logits')","Only add each output once per batch step"],"exampleFix":"# before\nreturn {\"logits\": a}  # in both outputs\n# after\nreturn {\"encoder_logits\": a}  # and {\"decoder_logits\": b}","handlingStrategy":"validation","validationCode":"PREFIX = \"sglang_aux_output.\"  # must match module's _OUTPUT_PREFIX\nnew_keys = {f\"{PREFIX}{k}\" for k in output.to_pp_tensors()}\nassert not (new_keys & set(tensors)), \"name collision\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Namespace tensor names per output source","Add each output exactly once per batch step"],"tags":["pipeline-parallel","sampling","duplicate-keys","validation"],"backgroundTag":"duplicate-payload-keys","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}