{"record":{"id":"0b796cfad9cf22ab","repo":"sgl-project/sglang","slug":"block-token-tags-must-cover-the-rank-local-packed","errorCode":null,"errorMessage":"block_token_tags must cover the rank-local packed sequence ({local_seq_len}), got {block_token_tags.shape[0]}.","messagePattern":"block_token_tags must cover the rank-local packed sequence \\((.+?)\\), got (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/dits/minimax_h3.py","lineNumber":2540,"sourceCode":"            local_embedding_layout=kwargs.get(\"local_embedding_layout\"),\n        )\n        self.release_mps_non_layer_weights(*_MPS_EMBED_WEIGHT_PREFIXES)\n        # request-step AdaLN input shared by all blocks\n        adaln_input = (\n            t_emb\n            if self.adaln_t_table is not None\n            else nn.functional.silu(t_emb).to(_BF16_DTYPE)\n        )\n        inverse_indices = inverse_indices.to(device)\n        block_inverse = inverse_indices[row_start:row_stop]\n        if block_token_tags is None:\n            assert token_tags is not None\n            token_tags = token_tags.to(device)\n            block_token_tags = token_tags[row_start:row_stop].clamp(min=0)\n        else:\n            block_token_tags = block_token_tags.to(device)\n            if block_token_tags.shape[0] != local_seq_len:\n                raise ValueError(\n                    \"block_token_tags must cover the rank-local packed sequence \"\n                    f\"({local_seq_len}), got {block_token_tags.shape[0]}.\"\n                )\n        block_combined = kwargs.get(\"block_combined_indices\")\n        if block_combined is None:\n            block_combined = torch.add(\n                block_token_tags,\n                block_inverse,\n                alpha=MINIMAX_H3_ADALN_MODALITY_NUM,\n            )\n\n        hidden = decoder_input\n        cu_seqlens = cu_seqlens.to(device)\n        block_adaln_params = None\n        adaln_cache_plan_index = None\n        if self.adaln_cache is not None:\n            adaln_cache_plan_index = self.adaln_cache.lookup(\n                unique_timesteps.view(-1).to(device)","sourceCodeStart":2522,"sourceCodeEnd":2558,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/dits/minimax_h3.py#L2522-L2558","documentation":"When block_token_tags are supplied directly (not derived from global token_tags), they must cover exactly the rank-local packed sequence length local_seq_len after sequence-parallel sharding. A mismatch means tags were not sliced to this rank's chunk.","triggerScenarios":"Passing full-sequence (global) token_tags as block_token_tags under SP>1, or slicing with the wrong row_start/row_stop after changing the SP degree.","commonSituations":"Custom pipelines that precompute block tags without accounting for ring/Ulysses sharding; SP config changed between tag generation and forward.","solutions":["Pass global token_tags instead and let forward slice rows itself (the token_tags branch in the source)","If supplying block_token_tags, slice to the rank-local chunk length: tags[row_start:row_stop] matching local_seq_len","Recompute local_seq_len = seq_len // (ulysses_ws * ring_ws) and verify tag length equals it"],"exampleFix":"// before\nmodel(..., block_token_tags=all_tags)  # full length under SP\n// after\nmodel(..., token_tags=all_tags)         # let the model slice per-rank","handlingStrategy":"validation","validationCode":"local_len = x.shape[1] // (ulysses_ws * ring_ws)\nassert block_token_tags is None or block_token_tags.shape[0] == local_len","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer passing global token_tags and let the model slice","Recompute local lengths whenever the SP degree changes"],"tags":["minimax-h3","token-tags","sequence-parallelism"],"backgroundTag":"tensor-shape-mismatch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}