sgl-project/sglang · error · ValueError

Comfy layer {prefix!r} is missing checkpoint tensors: {sorte

Error message

Comfy layer {prefix!r} is missing checkpoint tensors: {sorted(missing)}

What it means

Raised while inspecting a ComfyUI-style quantized checkpoint: the quant marker for a layer declares a required format, but the safetensors checkpoint lacks one or more tensors the format requires (weight, scales, etc.). The library validates checkpoint completeness before building an encoder quant config, so a partial or mismatched export is rejected early.

Source

Thrown at python/sglang/multimodal_gen/runtime/utils/quantization_utils.py:158

        if marker_format == "asym_w4a8_int8":
            required = {
                f"{prefix}.weight",
                f"{prefix}.weight_s_rel",
                f"{prefix}.weight_s_channel",
            }
        if marker_format == "nvfp4":
            required.add(f"{prefix}.weight_scale_2")
        if marker_format not in (
            "float8_e4m3fn",
            "int8_tensorwise",
            "asym_w4a8_int8",
            "convrot_w4a4",
            "nvfp4",
        ):
            continue
        missing = required - checkpoint_meta.keys()
        if missing:
            raise ValueError(
                f"Comfy layer {prefix!r} is missing checkpoint tensors: "
                f"{sorted(missing)}"
            )
        if marker_format == "float8_e4m3fn":
            marker["_activation_scheme"] = (
                "static" if f"{prefix}.input_scale" in checkpoint_meta else "dynamic"
            )
            continue
        if marker_format == "asym_w4a8_int8":
            weight_dtype, weight_shape = checkpoint_meta[f"{prefix}.weight"]
            scale_dtype, scale_shape = checkpoint_meta[f"{prefix}.weight_s_rel"]
            channel_dtype, channel_shape = checkpoint_meta[f"{prefix}.weight_s_channel"]
            group_size = int(marker.get("group_size", 16))
            if group_size < 4:
                raise ValueError(
                    f"Comfy W4A8 layer {prefix!r} has invalid group_size={group_size}"
                )
            if weight_dtype != "I8" or scale_dtype != "F8_E4M3":

View on GitHub (pinned to 0132848349)

Solutions

  1. Inspect the safetensors file (e.g. safetensors.safe_open(...).keys()) and compare against the marker's required tensor names for the failing prefix
  2. Re-export or re-download the checkpoint so every layer carrying a quant marker also has all its required tensors
  3. If the layer was intentionally left unquantized, remove its quant marker from the checkpoint
  4. If loading sharded weights, ensure all shards are passed to the inspector

Example fix

# before: partial checkpoint
load_safetensors("model.safetensors")  # raises ValueError: missing checkpoint tensors

# after: verify required tensors exist first
meta = read_safetensors_meta("model.safetensors")
assert all(k in meta for k in required_tensor_names(prefix)), 'incomplete export'
load_safetensors("model.safetensors")
Defensive patterns

Strategy: validation

Validate before calling

from safetensors import safe_open

required = {f"{prefix}.{suffix}" for suffix in REQUIRED_SUFFIXES[marker_format]}
with safe_open(path, framework="np") as f:
    keys = set(f.keys())
missing = required - keys
if missing:
    raise FileNotFoundError(f"incomplete checkpoint, missing {sorted(missing)}")

Type guard

def is_complete_comfy_checkpoint(meta: dict, markers: dict) -> bool:
    return all(
        REQUIRED_SUFFIXES.get(m.get("format"), ()) <= {
            k.removeprefix(p + ".") for k in meta if k.startswith(p + ".")
        }
        for p, m in markers.items()
    )

Prevention

When it happens

Trigger: Calling inspect_comfy_quant_markers (directly or via _get_encoder_quant_config / inspect_minimax_h3_safetensors) on a checkpoint where a tensor prefix has a quant marker whose format requires keys like {prefix}.weight, {prefix}.weight_s_rel, etc., but at least one required key is absent from the safetensors metadata.

Common situations: Checkpoint exported with a partial quantization pass (some layers skipped mid-export), safetensors file split into shards and only one shard loaded, manual pruning/renaming of tensors, or a version change in the export tool that renamed required tensor keys.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/df796c9593b13377. Report an issue: GitHub.