sgl-project/sglang · error · ValueError
min_hits must be positive, got {min_hits}
Error message
min_hits must be positive, got {min_hits} What it means
The Kimi-K3 ViT CUDA graph runner's min_hits threshold (how many times a shape must be seen before capturing a graph) must be positive; min_hits <= 0 is rejected in __init__ to avoid capturing graphs for transient shapes.
Source
Thrown at python/sglang/srt/multimodal/kimi_k3_vit_cuda_graph_runner.py:48
graph: torch.cuda.CUDAGraph
input_buffer: torch.Tensor
outputs: Tuple[torch.Tensor, ...]
metadata: KimiK3VisionForwardMetadata
class KimiK3ViTCudaGraphRunner:
def __init__(
self,
tower: KimiK3VisionTower,
*,
capacity: int,
min_hits: int,
max_seqlen: int | None = None,
) -> None:
if capacity <= 0:
raise ValueError(f"capacity must be positive, got {capacity}")
if min_hits <= 0:
raise ValueError(f"min_hits must be positive, got {min_hits}")
if max_seqlen is not None and max_seqlen <= 0:
raise ValueError(f"max_seqlen must be positive, got {max_seqlen}")
self.tower = tower
self.capacity = capacity
self.min_hits = min_hits
self.max_seqlen = max_seqlen
self.graphs: dict[Hashable, _CapturedVisionGraph] = {}
self.seen: OrderedDict[Hashable, int] = OrderedDict()
self.failed_keys: set[Hashable] = set()
self._graph_memory_pool: Any = None
self._capacity_logged = False
self._max_seqlen_logged = False
logger.info(
"Kimi-K3 ViT CUDA graph: capacity=%d min_hits=%d max_seqlen=%s",
capacity,
min_hits,
max_seqlen,
)View on GitHub (pinned to 0132848349)
Solutions
- Set min_hits >= 1 (2-3 is typical to avoid one-off captures)
- Validate/normalize the value at config-parse time: max(1, min_hits)
- Check the env var actually exporting the intended number
Example fix
// before runner = KimiK3VitCudaGraphRunner(tower=t, capacity=8, min_hits=cfg.min_hits) # cfg.min_hits == 0 // after runner = KimiK3VitCudaGraphRunner(tower=t, capacity=8, min_hits=max(1, cfg.min_hits))
Defensive patterns
Strategy: validation
Validate before calling
assert isinstance(min_hits, int) and min_hits >= 1, f"min_hits must be >= 1, got {min_hits}" Prevention
- Default min_hits to 2-3 in configs
- Sanitize env-derived ints before passing them in
When it happens
Trigger: Constructing the runner with min_hits=0 or negative, e.g. from a default of 0 in a config struct or an env var parsed as int('0').
Common situations: Tuning scripts sweeping min_hits from 0; misparsed SGLANG_* env variable yielding 0.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- capacity must be positive, got {capacity}
- max_seqlen must be positive, got {max_seqlen}
- --bcg-text-buckets must contain at least one positive intege
- Not support pos_emb_type: {pos_emb_type}
- Not support norm_type: {norm_type}
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/19d734bc432c6e3d.
Report an issue: GitHub.