sgl-project/sglang · error · ValueError
Unknown cache_dit_params['secondary'] keys: {sorted(unknown)
Error message
Unknown cache_dit_params['secondary'] keys: {sorted(unknown)}. Valid keys: {sorted(CACHE_DIT_REQUEST_KNOB_KEYS)}. What it means
Once 'secondary' is confirmed to be a dict, resolve_cache_dit_request_overrides computes unknown = set(secondary) - CACHE_DIT_REQUEST_KNOB_KEYS and rejects unknown nested keys, listing the valid knob names. Only after this does it copy the dict via dict(secondary).
Source
Thrown at python/sglang/multimodal_gen/runtime/cache/cache_dit_integration.py:245
if not isinstance(raw, dict):
raise ValueError(f"cache_dit_params must be a dict, got {type(raw).__name__}.")
unknown = set(raw) - CACHE_DIT_REQUEST_PARAM_KEYS
if unknown:
raise ValueError(
f"Unknown cache_dit_params keys: {sorted(unknown)}. "
f"Valid keys: {sorted(CACHE_DIT_REQUEST_PARAM_KEYS)}."
)
overrides = dict(raw)
secondary = overrides.get("secondary")
if secondary is not None:
if not isinstance(secondary, dict):
raise ValueError(
"cache_dit_params['secondary'] must be a dict, got "
f"{type(secondary).__name__}."
)
unknown = set(secondary) - CACHE_DIT_REQUEST_KNOB_KEYS
if unknown:
raise ValueError(
f"Unknown cache_dit_params['secondary'] keys: {sorted(unknown)}. "
f"Valid keys: {sorted(CACHE_DIT_REQUEST_KNOB_KEYS)}."
)
overrides["secondary"] = dict(secondary)
return overrides
def cache_dit_overrides_key(overrides: dict) -> tuple:
"""Hashable snapshot of request overrides, for mount-change detection."""
def _freeze(value):
if isinstance(value, dict):
return tuple(sorted((k, _freeze(v)) for k, v in value.items()))
if isinstance(value, (list, tuple)):
return tuple(_freeze(v) for v in value)
return value
return _freeze(overrides)View on GitHub (pinned to 0132848349)
Solutions
- Use only knob names from CACHE_DIT_REQUEST_KNOB_KEYS (printed in the error message).
- Set non-request-level knobs server-side via CacheDitConfig instead.
- Re-check valid knob keys after upgrading sglang.
Example fix
// before
request(cache_dit_params={"secondary": {"cfg_weight": 1.0}})
// after
request(cache_dit_params={"secondary": {"cfg": 1.0}}) Defensive patterns
Strategy: validation
Validate before calling
from sglang.multimodal_gen.runtime.cache.cache_dit_integration import CACHE_DIT_REQUEST_KNOB_KEYS
sec = (cache_dit_params or {}).get("secondary") or {}
bad = set(sec) - CACHE_DIT_REQUEST_KNOB_KEYS
assert not bad, f"unknown secondary keys: {bad}" Type guard
def valid_secondary_keys(sec: dict) -> bool:
return set(sec) <= CACHE_DIT_REQUEST_KNOB_KEYS Try / catch
try:
client.generate(prompt, cache_dit_params=params)
except ValueError as e:
if "cache_dit_params['secondary'] keys" in str(e):
params["secondary"] = {k: v for k, v in sec.items() if k in CACHE_DIT_REQUEST_KNOB_KEYS}
retry(client.generate, prompt, cache_dit_params=params)
raise Prevention
- Snapshot the valid knob-key set per deployed sglang version.
- Add integration tests asserting request payloads only use valid knob keys.
- Prefer server-level CacheDitConfig for knobs not exposed per-request.
When it happens
Trigger: Sending cache_dit_params={"secondary": {"cfgx": 1.0}} where 'cfgx' is not in CACHE_DIT_REQUEST_KNOB_KEYS.
Common situations: Guessing knob names ('cfg_weight' vs 'cfg'); the knob set changing between sglang versions; copying server CacheDitConfig field names into the per-request override dict.
Related errors
- Unknown cache_dit_params keys: {sorted(unknown)}. Valid keys
- cache_dit_params['secondary'] must be a dict, got {type(seco
- cache_dit_params must be a dict, got {type(raw).__name__}.
- Transformer {transformer.__class__.__name__} has no attribut
- num_inference_steps is required for transformer-only mode. P
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/3c8210cfd18f9142.
Report an issue: GitHub.