{"record":{"id":"dbb197b229b50d2a","repo":"sgl-project/sglang","slug":"chunk-index-must-be-strictly-increasing-got-norm","errorCode":null,"errorMessage":"chunk_index must be strictly increasing, got {normalized}.","messagePattern":"chunk_index must be strictly increasing, got (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/dits/sana_wm_components.py","lineNumber":417,"sourceCode":"        normalized = [int(idx) for idx in chunk_index]\n        if not normalized or normalized[0] != 0:\n            normalized = [0] + [idx for idx in normalized if idx > 0]\n        normalized = [idx for idx in normalized if idx < T]\n        if not normalized:\n            normalized = [0]\n    else:\n        if chunk_size is None:\n            raise ValueError(\"Either chunk_index or chunk_size must be provided.\")\n        normalized = _sana_wm_chunk_index_from_chunk_size(\n            T,\n            int(chunk_size),\n            strategy=chunk_split_strategy,\n        )\n\n    if normalized[-1] != T:\n        normalized.append(T)\n    if any(end <= start for start, end in zip(normalized[:-1], normalized[1:])):\n        raise ValueError(f\"chunk_index must be strictly increasing, got {normalized}.\")\n    return normalized\n\n\ndef _sana_wm_chunk_boundaries_for_attention(\n    HW: Tuple[int, int, int],\n    chunk_size: Optional[int],\n    chunk_split_strategy: str,\n    chunk_index: Optional[List[int]],\n) -> Optional[list[int]]:\n    T, _, _ = HW\n    if chunk_index is None and (chunk_size is None or int(chunk_size) >= T):\n        return None\n\n    boundaries = _sana_wm_normalize_chunk_index(\n        chunk_index,\n        T,\n        chunk_size=chunk_size,\n        chunk_split_strategy=chunk_split_strategy,","sourceCodeStart":399,"sourceCodeEnd":435,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/dits/sana_wm_components.py#L399-L435","documentation":"After normalization, chunk boundaries must be strictly increasing (and end at T). Any non-increasing adjacent pair — duplicate indices or a decrease — fails this invariant before slicing.","triggerScenarios":"Passing chunk_index with duplicates like [0, 8, 8, 16], an unsorted list, or an index >= T (post-filtering can leave e.g. [0,0]); also indices not starting at 0 can interact badly with normalization.","commonSituations":"User-supplied chunk_index from config computed with float arithmetic then int()-cast (duplicates); indices generated for a larger T reused on a smaller clip (filtered to [0]); off-by-one in boundary generation.","solutions":["Sort and deduplicate chunk_index before passing: sorted(set(chunk_index))","Ensure all indices are in (0, T) and the list strictly increases","Prefer passing chunk_size and letting the helper compute indices"],"exampleFix":"# before\nidx = _sana_wm_normalize_chunk_index(T, chunk_index=[0, 8, 8, 16])\n# after\nidx = _sana_wm_normalize_chunk_index(T, chunk_index=sorted({0, 8, 8, 16}))","handlingStrategy":"validation","validationCode":"idx = sorted({int(i) for i in chunk_index if 0 < i < T})\nassert all(b > a for a, b in zip(idx, idx[1:]))","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always sorted(set(...)) user-provided index lists; prefer chunk_size"],"tags":["sana-wm","chunking","invalid-argument","ordering"],"backgroundTag":"invalid-argument-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}