{"record":{"id":"df75263b47c2bb4a","repo":"sgl-project/sglang","slug":"gguf-tensor-tensor-name-is-quantized-but-diffus","errorCode":null,"errorMessage":"GGUF tensor {tensor.name} is quantized, but diffusion GGUF currently supports packed data only for 2D linear .weight tensors","messagePattern":"GGUF tensor (.+?) is quantized, but diffusion GGUF currently supports packed data only for 2D linear \\.weight tensors","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/loader/gguf_weights.py","lineNumber":105,"sourceCode":"    for tensor in reader.tensors:\n        weight_type = WeightType(tensor.tensor_type)\n        shape_field = reader.fields.get(f\"comfy.gguf.orig_shape.{tensor.name}\")\n        logical_shape = (\n            tuple(int(dim) for dim in shape_field.contents())\n            if shape_field is not None\n            else tuple(int(dim) for dim in reversed(tensor.shape))\n        )\n        if math.prod(logical_shape) != tensor.n_elements:\n            raise ValueError(\n                f\"GGUF tensor {tensor.name} declares original shape \"\n                f\"{logical_shape}, which contains {math.prod(logical_shape)} \"\n                f\"elements instead of {tensor.n_elements}\"\n            )\n        is_quantized = int(weight_type) not in _UNQUANTIZED_TYPES\n        dequantize_on_load = False\n        if is_quantized:\n            if len(logical_shape) != 2 or not tensor.name.endswith(\".weight\"):\n                raise ValueError(\n                    f\"GGUF tensor {tensor.name} is quantized, but diffusion GGUF \"\n                    \"currently supports packed data only for 2D linear .weight \"\n                    \"tensors\"\n                )\n            block_size, type_size = gguf.GGML_QUANT_SIZES[weight_type]\n            inner_dim = logical_shape[-1]\n            if inner_dim % block_size:\n                if shape_field is None:\n                    raise ValueError(\n                        f\"GGUF tensor {tensor.name} has inner dimension {inner_dim}, \"\n                        f\"which is not a multiple of block size {block_size}\"\n                    )\n                dequantize_on_load = True\n                stored_shape = logical_shape\n            else:\n                stored_shape = (\n                    *logical_shape[:-1],\n                    inner_dim // block_size * type_size,","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/loader/gguf_weights.py#L87-L123","documentation":"The GGUF loader supports packed (still-quantized) data only for 2D linear-layer .weight tensors. This tensor is quantized but is either not 2D or not named *.weight (e.g. a conv weight, bias, or norm tensor), so there is no packed layout it can safely map.","triggerScenarios":"read_gguf_tensor_meta encounters a tensor with weight_type not in _UNQUANTIZED_TYPES whose logical_shape has rank != 2 or whose name does not end with '.weight'. Common with quantized conv/norm tensors in diffusion GGUF checkpoints.","commonSituations":"Loading a ComfyUI diffusion GGUF where convolution or group-norm tensors were quantized alongside linear weights; using a quantizer preset that quantizes non-linear layers; a GGUF produced for a different runtime that allows packed N-D tensors.","solutions":["Re-quantize the checkpoint leaving non-linear tensors (conv, norm, bias) in an unquantized type such as F32/F16/BF16","If the tensor genuinely is a linear weight, check that its name ends with '.weight' and its declared shape is 2D; fix naming/shape metadata","Use a checkpoint flavor known to work with this loader (only 2D linear weights quantized)"],"exampleFix":"# before: quantize everything, including convs -> error on 'conv_in.weight' [320,4,3,3]\n# after (quantizer config): exclude conv/norm layers\nquant_config.exclude_patterns = ['conv*', '*norm*']  # keep them F16","handlingStrategy":"validation","validationCode":"for t in reader.tensors:\n    wt = reader.get_field('general.type')  # per-tensor type from t.tensor_type\n    if t.tensor_type not in UNQUANTIZED and (len(t.shape) != 2 or not t.name.endswith('.weight')):\n        raise SkipOrRequantize(t.name)","typeGuard":"def is_packed_safe(t) -> bool:\n    return t.tensor_type in UNQUANTIZED or (len(t.shape) == 2 and t.name.endswith('.weight'))","tryCatchPattern":"try:\n    meta = read_gguf_tensor_meta(reader, t)\nexcept ValueError as e:\n    if 'packed data only' in str(e):\n        log.warning('skipping unsupported quantized tensor %s', t.name)\n    else:\n        raise","preventionTips":["Use quantizer presets that exclude conv/norm layers","Test-load checkpoints in CI before deployment","Prefer checkpoints from the model's official GGUF releases"],"tags":["gguf","quantization","tensor-layout","diffusion"],"backgroundTag":"unsupported-quantized-tensor-layout","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}