{"record":{"id":"eb163cc0245f101d","repo":"sgl-project/sglang","slug":"mask-strategy-0-cannot-be-none-for-slidingtileatt","errorCode":null,"errorMessage":"mask_strategy[0] cannot be None for SlidingTileAttention","messagePattern":"mask_strategy\\[0\\] cannot be None for SlidingTileAttention","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/layers/attention/backends/sliding_tile_attn.py","lineNumber":210,"sourceCode":"\n    def postprocess_output(\n        self,\n        output: torch.Tensor,\n        attn_metadata: SlidingTileAttentionMetadata,\n    ) -> torch.Tensor:\n        return self.untile(output)\n\n    def forward(\n        self,\n        q: torch.Tensor,\n        k: torch.Tensor,\n        v: torch.Tensor,\n        attn_metadata: SlidingTileAttentionMetadata,\n    ) -> torch.Tensor:\n        if self.mask_strategy is None:\n            raise ValueError(\"mask_strategy cannot be None for SlidingTileAttention\")\n        if self.mask_strategy[0] is None:\n            raise ValueError(\"mask_strategy[0] cannot be None for SlidingTileAttention\")\n\n        timestep = attn_metadata.current_timestep\n        forward_context: ForwardContext = get_forward_context()\n        forward_batch = forward_context.forward_batch\n        if forward_batch is None:\n            raise ValueError(\"forward_batch cannot be None\")\n        # pattern:'.double_blocks.0.attn.impl' or '.single_blocks.0.attn.impl'\n        layer_idx = int(self.prefix.split(\".\")[-3])\n        if attn_metadata.STA_param is None or len(attn_metadata.STA_param) <= layer_idx:\n            raise ValueError(\"Invalid STA_param\")\n        STA_param = attn_metadata.STA_param[layer_idx]\n\n        text_length = q.shape[1] - self.img_seq_length\n        has_text = text_length > 0\n\n        query = q.transpose(1, 2).contiguous()\n        key = k.transpose(1, 2).contiguous()\n        value = v.transpose(1, 2).contiguous()","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/layers/attention/backends/sliding_tile_attn.py#L192-L228","documentation":"Even when a mask strategy exists, its first timestep entry (mask_strategy[0]) is required by STA forward to derive per-timestep masks; if the loaded JSON has null at index 0 the backend raises ValueError.","triggerScenarios":"Calling STA forward with a mask_strategy JSON whose first entry is null/missing.","commonSituations":"Reusing another model's mask_strategy.json; hand-edited or partially generated strategy files; template JSON with null placeholders.","solutions":["Regenerate the mask strategy file so entry 0 is a valid mask list","Use the official mask strategy shipped with the model checkpoint","Validate the JSON right after load (reject null first entry) and fall back to another backend if invalid"],"exampleFix":"# before\n# mask.json: {\"0\": null, \"1\": [...]} -> ValueError at forward\n# after\nms = json.load(open(mask_strategy_file_path))\nassert ms[0] is not None, 'mask_strategy[0] must exist'\nbackend.mask_strategy = dict_to_3d_list(ms)","handlingStrategy":"validation","validationCode":"strategy = json.load(open(mask_strategy_file_path))\nassert strategy and strategy[0] is not None, \"mask_strategy[0] missing in mask JSON\"","typeGuard":"def valid_mask_strategy(ms) -> bool:\n    return ms is not None and len(ms) > 0 and ms[0] is not None","tryCatchPattern":null,"preventionTips":["Use the mask strategy file shipped with the model checkpoint","Validate the JSON structure right after loading"],"tags":["sliding-tile-attention","mask-strategy","validation","forward"],"backgroundTag":"invalid-config-file","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}