{"record":{"id":"65f78984440173c3","repo":"vllm-project/vllm","slug":"either-prompt-lookup-max-or-prompt-lookup-min-must","errorCode":null,"errorMessage":"Either prompt_lookup_max or prompt_lookup_min must be provided when using the ngram method.","messagePattern":"Either prompt_lookup_max or prompt_lookup_min must be provided when using the ngram method\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"vllm/config/speculative.py","lineNumber":811,"sourceCode":"                        \"custom proposer module path (e.g., 'my_module.MyProposer').\"\n                    )\n            else:\n                raise ValueError(\n                    \"num_speculative_tokens was provided but without speculative model.\"\n                )\n\n        if self.method in (\"ngram\", \"[ngram]\"):\n            self.method = \"ngram\"\n\n        if self.method in (\"ngram\", \"ngram_gpu\"):\n            # Set default values if not provided\n            if self.prompt_lookup_min is None and self.prompt_lookup_max is None:\n                # TODO(woosuk): Tune these values. They are arbitrarily chosen.\n                self.prompt_lookup_min = 5\n                self.prompt_lookup_max = 5\n            elif self.prompt_lookup_min is None:\n                if self.prompt_lookup_max is None:\n                    raise ValueError(\n                        \"Either prompt_lookup_max or prompt_lookup_min must be \"\n                        \"provided when using the ngram method.\"\n                    )\n                self.prompt_lookup_min = self.prompt_lookup_max\n            elif self.prompt_lookup_max is None:\n                if self.prompt_lookup_min is None:\n                    raise ValueError(\n                        \"Either prompt_lookup_max or prompt_lookup_min must be \"\n                        \"provided when using the ngram method.\"\n                    )\n                self.prompt_lookup_max = self.prompt_lookup_min\n\n            # Validate values\n            if self.prompt_lookup_min > self.prompt_lookup_max:\n                raise ValueError(\n                    f\"prompt_lookup_min={self.prompt_lookup_min} must \"\n                    f\"be <= prompt_lookup_max={self.prompt_lookup_max}\"\n                )","sourceCodeStart":793,"sourceCodeEnd":829,"githubUrl":"https://github.com/vllm-project/vllm/blob/c794754062d49a8fdb63ab3c5215b488b865030c/vllm/config/speculative.py#L793-L829","documentation":"Defensive branch while defaulting ngram window sizes: if prompt_lookup_min is None it is copied from prompt_lookup_max; the inner raise fires only if max were also None, which the preceding both-None branch (defaults 5/5) already handles — i.e. in the current code this specific raise is effectively unreachable. In practice, omitting both values gives you 5/5, not this error.","triggerScenarios":"Only reachable if the both-None early branch is removed or the values are mutated between the checks (e.g. a subclass overriding __post_init__ behavior); with stock vLLM, normal ngram usage never triggers it.","commonSituations":"Forked/patched SpeculativeConfig where the defaulting order changed; reading old source where the guard was the primary path.","solutions":["Rely on the built-in default: pass neither prompt_lookup_min nor prompt_lookup_max (both become 5)","Or set at least one of prompt_lookup_min/prompt_lookup_max explicitly","If you maintain a fork, keep the both-None default branch ahead of this guard"],"exampleFix":"# before\nSpeculativeConfig(method='ngram', num_speculative_tokens=3, prompt_lookup_min=None, prompt_lookup_max=None)  # on a fork without the default branch\n\n# after\nSpeculativeConfig(method='ngram', num_speculative_tokens=3, prompt_lookup_min=5, prompt_lookup_max=5)","handlingStrategy":"validation","validationCode":"def ngram_windows_ok(plmin: int | None, plmax: int | None) -> bool:\n    return not (plmin is None and plmax is None) or True  # stock code defaults both to 5; guard only for forks\n\ndef ngram_windows_explicit(plmin: int | None, plmax: int | None) -> bool:\n    return plmin is not None or plmax is not None","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Omit both ngram window params to get the 5/5 default","On forks, keep the both-None defaulting branch ahead of this guard"],"tags":["speculative-decoding","ngram","config","dead-code"],"backgroundTag":null,"analyzedSha":"c794754062d49a8fdb63ab3c5215b488b865030c","analyzedAt":"2026-08-14T21:17:39.825Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}