{"record":{"id":"a8ae5c892d2876f6","repo":"sgl-project/sglang","slug":"unknown-match-type-match-type-must-be-bfs","errorCode":null,"errorMessage":"Unknown match_type: '{match_type}'. Must be 'BFS' or 'PROB'.","messagePattern":"Unknown match_type: '(.+?)'\\. Must be 'BFS' or 'PROB'\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/kernels/ops/speculative/ngram_corpus.py","lineNumber":58,"sourceCode":"\n    @tvm_ffi.register_object(\"sgl.NgramCorpus\")\n    class NgramCorpusFFI(tvm_ffi.Object):\n        __slots__ = (\"__dict__\",)\n\n        def __init__(\n            self,\n            capacity: int,\n            max_trie_depth: int,\n            min_bfs_breadth: int,\n            max_bfs_breadth: int,\n            draft_token_num: int,\n            match_type: str,\n            external_sam_budget: int = 0,\n            external_corpus_max_tokens: int = 10000000,\n        ) -> None:\n            mt = _MATCH_TYPE_MAP.get(match_type)\n            if mt is None:\n                raise ValueError(\n                    f\"Unknown match_type: '{match_type}'. Must be 'BFS' or 'PROB'.\"\n                )\n            self.__ffi_init__(\n                capacity,\n                max_trie_depth,\n                min_bfs_breadth,\n                max_bfs_breadth,\n                draft_token_num,\n                mt,\n                external_sam_budget,\n                external_corpus_max_tokens,\n            )\n            self._draft_token_num = draft_token_num\n\n        def insert(self, batch_tokens: List[List[int]]) -> None:\n            tokens_flat, offsets = _to_csr(batch_tokens)\n            self.async_insert(tokens_flat, offsets)  # type: ignore\n","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/kernels/ops/speculative/ngram_corpus.py#L40-L76","documentation":"The ngram corpus only accepts match_type of 'BFS' or 'PROB' (mapped via _MATCH_TYPE_MAP). Any other string raises immediately in __init__.","triggerScenarios":"Passing match_type='bfs' (lowercase), 'prob_sample', or a typo like 'PRO ' to the ngram corpus constructor.","commonSituations":"Config files with lowercase or renamed speculation settings (e.g. porting from vLLM-style 'greedy'/'sample' ngram params to this API).","solutions":["Use exactly 'BFS' or 'PROB' (case-sensitive).","Check _MATCH_TYPE_MAP keys in ngram_corpus.py for the accepted values.","Validate/normalize the spec config string before constructing."],"exampleFix":"// before\ncorpus = NgramCorpus(..., match_type='bfs')\n// after\ncorpus = NgramCorpus(..., match_type='BFS')","handlingStrategy":"validation","validationCode":"assert match_type in ('BFS', 'PROB'), match_type","typeGuard":"def is_valid_match_type(s: str) -> bool:\n    return s in ('BFS', 'PROB')","tryCatchPattern":null,"preventionTips":["Uppercase-normalize and validate the config value before construction."],"tags":["argument-validation","ngram","speculative-decoding"],"backgroundTag":"invalid-enum-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}