sgl-project/sglang · error · ValueError
Ambiguous tensor payload for multi-module update. Provide a
Error message
Ambiguous tensor payload for multi-module update. Provide a dict mapping module_name -> module payload, requested modules: {module_names}. What it means
Raised by WeightsUpdater._resolve_module_payloads when a non-dict payload is given but the update targets more than one module. With multiple modules the updater cannot tell which payload belongs to which module, so it demands a dict keyed by module name.
Source
Thrown at python/sglang/multimodal_gen/runtime/post_training/weights_updater.py:759
def _resolve_module_payloads(
self,
named_tensors: Any,
modules_to_update: list[tuple[str, torch.nn.Module]],
) -> dict[str, Any]:
module_names = [name for name, _ in modules_to_update]
if isinstance(named_tensors, dict):
missing = [name for name in module_names if name not in named_tensors]
if missing:
raise ValueError(
f"Missing tensor payload for module(s): {missing}. "
f"Provided modules: {list(named_tensors.keys())}"
)
return {name: named_tensors[name] for name in module_names}
if len(module_names) == 1:
return {module_names[0]: named_tensors}
raise ValueError(
"Ambiguous tensor payload for multi-module update. "
"Provide a dict mapping module_name -> module payload, "
f"requested modules: {module_names}."
)
def _materialize_weights_iter(self, module_payload: Any, load_format: str | None):
if load_format == "flattened_bucket":
if not isinstance(module_payload, dict):
raise ValueError(
"flattened_bucket payload must be a dict with "
"'flattened_tensor' and 'metadata'."
)
flattened_tensor = module_payload.get("flattened_tensor")
metadata = module_payload.get("metadata")
if flattened_tensor is None or metadata is None:
raise ValueError(
"flattened_bucket payload missing 'flattened_tensor' or 'metadata'."
)View on GitHub (pinned to 0132848349)
Solutions
- Pass a dict {module_name: payload} covering every requested module
- Or set target_modules to exactly one module so the single payload can be assigned to it
Example fix
// before
updater.update_weights_from_tensor(named_tensors=flat_payload, target_modules=["a","b"])
// after
updater.update_weights_from_tensor(named_tensors={"a": payload_a, "b": payload_b}) Defensive patterns
Strategy: type-guard
Validate before calling
if len(target_modules) > 1 and not isinstance(named_tensors, dict):
named_tensors = {target_modules[0]: named_tensors} # only valid if you truly want one module
# otherwise build a per-module dict Type guard
def is_multi_module_payload(named_tensors: Any, n: int) -> bool:
return n == 1 or isinstance(named_tensors, dict) Prevention
- Always pass a dict {module_name: payload} regardless of module count
- Keep target_modules explicit rather than None on multi-module pipelines
When it happens
Trigger: Calling update_weights_from_tensor with named_tensors being a single payload object (list/tuple/flattened bucket) while target_modules (or the default full module set) contains 2+ modules. A single payload is only accepted when exactly one module is being updated.
Common situations: Code originally written for a single-module pipeline reused on a multi-module pipeline; defaulting target_modules=None (all modules) but passing one flat payload.
Related errors
- Missing tensor payload for module(s): {missing}. Provided mo
- Module(s) requested for update not found in pipeline: {unkno
- flattened_bucket payload must be a dict with 'flattened_tens
- flattened_bucket payload missing 'flattened_tensor' or 'meta
- Unsupported module payload type for load_format={load_format
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/4d26c37845a4e6d8.
Report an issue: GitHub.