vllm-project/vllm · error · TypeError

Unsupported type for size: {type(value)}

Error message

Unsupported type for size: {type(value)}

What it means

_parse_size converts global_segment_size / local_buffer_size values to byte counts. Non-int, non-str inputs (float, bool, list, None) are attempted via int(value); if that fails it raises TypeError with the value's type. Note bools and floats that do convert silently succeed, so this error means a genuinely unconvertible type.

Source

Thrown at vllm/distributed/kv_transfer/kv_connector/v1/mooncake/store/worker.py:199

    if value is None:
        return DEFAULT_TENANT_ID
    if not isinstance(value, str):
        raise TypeError(
            f"tenant_id must be a string or null, got {type(value).__name__}: {value!r}"
        )
    tenant_id = value.strip()
    return tenant_id if tenant_id else DEFAULT_TENANT_ID


def _parse_size(value: Any) -> int:
    """Parse storage size strings with units: GB, MB, KB, B."""
    if isinstance(value, int):
        return value
    if not isinstance(value, str):
        try:
            return int(value)
        except (TypeError, ValueError) as e:
            raise TypeError(f"Unsupported type for size: {type(value)}") from e

    cleaned = value.strip().lower()
    if not cleaned:
        raise ValueError("Size cannot be empty.")

    unit_multipliers = {
        "gb": 1024**3,
        "mb": 1024**2,
        "kb": 1024,
        "b": 1,
    }
    match = re.match(r"^\s*([\d.]+)\s*(gb|mb|kb|b)?\s*$", cleaned)
    if not match:
        raise ValueError(f"Invalid format: '{value}'")

    number_str = match.group(1)
    unit = match.group(2) or "b"
    multiplier = unit_multipliers[unit]

View on GitHub (pinned to c794754062)

Solutions

  1. Use a plain int (bytes) or a unit string like "8GB" for size fields in the mooncake config
  2. Remove any list/object wrapper around the value

Example fix

// before
{ "global_segment_size": ["8GB"] }

// after
{ "global_segment_size": "8GB" }
Defensive patterns

Strategy: type-guard

Validate before calling

for k in ("global_segment_size", "local_buffer_size"):
    v = raw.get(k)
    if not isinstance(v, (int, str)):
        raise TypeError(f"{k} must be int or size string")

Type guard

def is_valid_size_input(v) -> bool:
    return isinstance(v, (int, str))

Prevention

When it happens

Trigger: "global_segment_size": ["8GB"] or 1.5e9's string-less cousin such as an embedded object in the config JSON; a float like 1.5 (int() truncates it — no error) vs a list/dict (error).

Common situations: Templating systems injecting structured values where a scalar was expected; hand-edited JSON putting arrays around sizes.

Related errors


AI-assisted analysis of vllm-project/vllm@c794754062 (2026-08-14). Data as JSON: /api/errors/f6e33c8fc197e475. Report an issue: GitHub.