{"record":{"id":"7240a20a547cc61c","repo":"sgl-project/sglang","slug":"auxiliary-pp-output-name-r-is-not-a-tensor","errorCode":null,"errorMessage":"auxiliary PP output {name!r} is not a tensor","messagePattern":"auxiliary PP output (.+?) is not a tensor","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/sampling/sampling_observer_pp.py","lineNumber":54,"sourceCode":"    tensors: MutableMapping[str, Any],\n    output: Optional[DeviceAuxiliaryOutput],\n) -> None:\n    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:","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/sampling/sampling_observer_pp.py#L36-L72","documentation":"A value in the to_pp_tensors() mapping is not a torch.Tensor; PP transport only forwards tensors, so the payload is invalid.","triggerScenarios":"to_pp_tensors() returning numbers, lists, numpy arrays, or None among its values.","commonSituations":"Custom auxiliary output stuffing scalars/arrays into the tensor dict instead of tensorizing them.","solutions":["Convert all values to torch tensors in to_pp_tensors()","Pass non-tensor metadata through a separate channel"],"exampleFix":"# before\nreturn {\"logprob\": float(v)}\n# after\nreturn {\"logprob\": torch.tensor(float(v))}","handlingStrategy":"validation","validationCode":"import torch\nt = output.to_pp_tensors()\nassert all(torch.is_tensor(v) for v in t.values())","typeGuard":"import torch\ndef all_tensors(t: dict) -> bool:\n    return all(torch.is_tensor(v) for v in t.values())","tryCatchPattern":null,"preventionTips":["Tensorize scalars/arrays before putting them in PP payloads"],"tags":["pipeline-parallel","sampling","torch","validation"],"backgroundTag":"payload-schema-validation","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}