{"record":{"id":"e09984c02c0b32b4","repo":"sgl-project/sglang","slug":"either-chunk-index-or-chunk-size-must-be-provided","errorCode":null,"errorMessage":"Either chunk_index or chunk_size must be provided.","messagePattern":"Either chunk_index or chunk_size must be provided\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/dits/sana_wm_components.py","lineNumber":407,"sourceCode":"    )\n\n\ndef _sana_wm_normalize_chunk_index(\n    chunk_index: Optional[List[int]],\n    T: int,\n    chunk_size: Optional[int] = None,\n    chunk_split_strategy: str = \"uniform\",\n) -> list[int]:\n    if chunk_index is not None:\n        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]],","sourceCodeStart":389,"sourceCodeEnd":425,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/dits/sana_wm_components.py#L389-L425","documentation":"_sana_wm_normalize_chunk_index needs either an explicit chunk_index list or a chunk_size to derive boundaries. Supplying neither makes chunk boundary computation impossible.","triggerScenarios":"Calling the attention/GDN chunk-scan path (via _sana_wm_chunk_boundaries_for_attention or _gdn_chunk_scan_forward) with both chunk_index=None and chunk_size=None.","commonSituations":"New model config omitting chunk_gdn_chunk_size; a wrapper that conditionally forwards only one of the two kwargs and the condition picked neither; None defaults propagating from an unset config object.","solutions":["Set either chunk_index (list of boundary frame indices) or chunk_size (positive int) in the block config / call","If you intended unchunked processing, pass chunk_size equal to the full T","Default chunk_size in your config loader, e.g. chunk_size if chunk_size is not None else 32"],"exampleFix":"# before\nbounds = _sana_wm_normalize_chunk_index(T, chunk_index=None, chunk_size=None)\n# after\nbounds = _sana_wm_normalize_chunk_index(T, chunk_index=None, chunk_size=32)","handlingStrategy":"validation","validationCode":"assert (chunk_index is None) != (chunk_size is None), 'provide exactly one of chunk_index/chunk_size'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default chunk_size in config loader: chunk_size or 32"],"tags":["sana-wm","chunking","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}