sgl-project/sglang · error · ValueError
Invalid global_segment_size: missing number before 'gb'
Error message
Invalid global_segment_size: missing number before 'gb'
What it means
Parsing global_segment_size rejected a string like 'gb' or ' gb' — the suffix was present but the numeric part was empty. The parser accepts ints, plain numeric strings, or '<N>gb' (converted to bytes).
Source
Thrown at python/sglang/srt/mem_cache/storage/mooncake_store/mooncake_store.py:78
tensor = torch.frombuffer(c_array, dtype=torch.uint8, count=size)
if dtype != torch.uint8:
element_size = torch.tensor([], dtype=dtype).element_size()
assert size % element_size == 0, "Size must be divisible by element size"
tensor = tensor.view(dtype)
return tensor.view(dims)
def _parse_global_segment_size(value) -> int:
if isinstance(value, int):
return value
if isinstance(value, str):
s = value.strip().lower()
if s.endswith("gb"):
num = s[:-2].strip()
if not num:
raise ValueError(
"Invalid global_segment_size: missing number before 'gb'"
)
return int(num) * 1024 * 1024 * 1024
return int(s)
return int(value)
def _normalize_tenant_id(value) -> str:
if value is None:
return DEFAULT_TENANT_ID
tenant_id = str(value).strip()
return tenant_id if tenant_id else DEFAULT_TENANT_ID
@dataclass
class MooncakeStoreConfig:
local_hostname: str
metadata_server: strView on GitHub (pinned to 0132848349)
Solutions
- Set a valid value: integer bytes or "<N>gb", e.g. "8gb" or 8589934592
Example fix
// before
{"global_segment_size": "gb"}
// after
{"global_segment_size": "8gb"} Defensive patterns
Strategy: validation
Validate before calling
import re
def valid_global_segment_size(v) -> bool:
if isinstance(v, int):
return v > 0
if isinstance(v, str):
s = v.strip().lower()
if s.endswith('gb'):
return bool(re.fullmatch(r'\d+(\.\d+)?', s[:-2].strip()))
return s.isdigit()
return False Prevention
- Validate config files with a schema (pydantic/jsonschema) before launch
- Add unit tests for size-string parsing
When it happens
Trigger: Passing MooncakeStoreConfig global_segment_size as the literal string 'gb', 'GB', or whitespace-only before the suffix.
Common situations: Hand-edited mooncake config JSON with "global_segment_size": "gb" or a templating variable that expanded to empty.
Related errors
- Either master_server_address or client_server_address is req
- Either master_server_address or client_server_address is req
- This browser cannot encode H.264 MP4
- H.264 encoder did not return MP4 decoder config
- delta payload size mismatch: expected ${expectedSize}, got $
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/4121a36928e546e8.
Report an issue: GitHub.