{"record":{"id":"2bb675d3f6476cd7","repo":"sgl-project/sglang","slug":"kv-canary-launch-plan-entries-kernel-requires-req","errorCode":null,"errorMessage":"kv-canary: launch_plan_entries_kernel requires req_to_verify_expected_tokens_valid_lens when req_to_verify_expected_tokens is set","messagePattern":"kv-canary: launch_plan_entries_kernel requires req_to_verify_expected_tokens_valid_lens when req_to_verify_expected_tokens is set","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/kernels/ops/kv_canary/plan/entries_kernel.py","lineNumber":51,"sourceCode":"    full_to_swa_index_mapping: Optional[torch.Tensor],\n    verify_offsets_scratch: torch.Tensor,\n    verify_enable: torch.Tensor,\n    req_to_verify_expected_tokens: Optional[torch.Tensor],\n    req_to_verify_expected_tokens_valid_lens: Optional[torch.Tensor],\n    out_verify_slot_indices: torch.Tensor,\n    out_verify_expected_tokens: torch.Tensor,\n    out_verify_expected_positions: torch.Tensor,\n    out_verify_prev_slot_indices: torch.Tensor,\n    kv_token_id_vs_position_offset: int,\n    swa_window_size: int,\n) -> None:\n    has_swa_lut = full_to_swa_index_mapping is not None\n    has_verify_expected_token_pool = req_to_verify_expected_tokens is not None\n    if (\n        has_verify_expected_token_pool\n        and req_to_verify_expected_tokens_valid_lens is None\n    ):\n        raise ValueError(\n            \"kv-canary: launch_plan_entries_kernel requires \"\n            \"req_to_verify_expected_tokens_valid_lens when req_to_verify_expected_tokens is set\"\n        )\n    module = _jit_plan_entries_module(has_swa_lut, has_verify_expected_token_pool)\n    module.plan_entries(\n        req_pool_indices,\n        prefix_lens,\n        req_to_token,\n        full_to_swa_index_mapping,\n        verify_offsets_scratch,\n        verify_enable,\n        req_to_verify_expected_tokens,\n        req_to_verify_expected_tokens_valid_lens,\n        out_verify_slot_indices,\n        out_verify_expected_tokens,\n        out_verify_expected_positions,\n        out_verify_prev_slot_indices,\n        int(kv_token_id_vs_position_offset),","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/kernels/ops/kv_canary/plan/entries_kernel.py#L33-L69","documentation":"When a req_to_verify_expected_tokens pool tensor is supplied, the entries kernel also needs its valid-lengths companion tensor so it knows how many entries per request are meaningful. Without valid_lens the kernel cannot safely read expected-token rows.","triggerScenarios":"Calling launch_plan_entries_kernel (usually via launch_canary_plan_kernels) with req_to_verify_expected_tokens set but req_to_verify_expected_tokens_valid_lens=None.","commonSituations":"Adding expected-token tracking for spec-decode verification and passing the pool tensor but not the per-request valid length vector produced alongside it.","solutions":["Pass req_to_verify_expected_tokens_valid_lens (same bs, int32) together with the pool tensor","If you don't need expected-token tracking, pass req_to_verify_expected_tokens=None"],"exampleFix":"// before\nlaunch_plan_entries_kernel(..., req_to_verify_expected_tokens=pool, req_to_verify_expected_tokens_valid_lens=None)\n// after\nlaunch_plan_entries_kernel(..., req_to_verify_expected_tokens=pool, req_to_verify_expected_tokens_valid_lens=valid_lens)","handlingStrategy":"validation","validationCode":"if req_to_verify_expected_tokens is not None:\n    assert req_to_verify_expected_tokens_valid_lens is not None","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat (pool tensor, valid_lens) as an inseparable pair in your dataclasses"],"tags":["kv-canary","plan-entries","argument-validation"],"backgroundTag":"missing-required-argument","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}