docs: add a sampling-params reference for the generation backends - #3994
Open
yupengtang wants to merge 1 commit into
Open
docs: add a sampling-params reference for the generation backends#3994yupengtang wants to merge 1 commit into
yupengtang wants to merge 1 commit into
Conversation
`docs/design-docs/generation.md` lists temperature / top_p / top_k as config fields but never says how each backend reads them, and they genuinely differ. Adds `docs/design-docs/sampling-params.md` with the per-backend table, links it from the design-docs toctree, and points at it from the generation doc. The part worth writing down is that "no top-k restriction" has two spellings: vLLM and SGLang want -1, TRT-LLM and Megatron want 0, and TRT-LLM's SamplingParams rejects negatives outright, so a config carrying `top_k: -1` works on vLLM and raises at request time on TRT-LLM. `null` is the portable value. `examples/configs/evals/eval.yaml` currently uses -1, commented "-1 means disable". Also documents that the vLLM HTTP path -- what NeMo-Gym agentic rollouts talk to -- asserts top_k is unset and pins it to -1, so it ignores the configured value while every other path honors it. Two details differ from the table in the issue, both verified against main: greedy resolves to temperature=0.0 and top_k=1 only on the paths that take a `greedy` flag, and the HTTP servers have no such flag at all; and SGLang omits the top_k key entirely rather than sending the sentinel. Signed-off-by: Yupeng Tang <85978465+yupengtang@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do ?
Adds
docs/design-docs/sampling-params.md, a reference for how each generation backend interpretstemperature/top_p/top_k.generation.mdlists them as config fields but never says how the backends read them, and they genuinely disagree — including on what "disabled" means. The page covers the two questions in #3776: how to set the params across backends, and what actually reaches each engine.Linked from the design-docs toctree in
docs/index.mdand from theGenerationConfigblock indocs/design-docs/generation.md.Issues
Closes #3776.
Usage
The headline rule the page exists to state:
top_k: null-1— unrestricted0— unrestrictedtop_k: -1require top_k >= 0top_k: 0So
nullis the portable "unrestricted" value, andexamples/configs/evals/eval.yaml'stop_k: -1 # -1 means disableis vLLM-shaped — it raises at request time on a TRT-LLM run. I left that config alone since it is a behaviour change rather than a docs one; happy to fix it here or in a follow-up, whichever you prefer.Before your PR is "Ready for review"
Pre checks:
Docs-only, so no tests.
python -m sphinx -b html docs/ <out>builds clean, the new page renders, and no warning references any of the three files.Additional Information
Verification
I re-checked every row of the table in the issue against
mainrather than copying it, since it was written on Aug 23. All six rows still hold. Two details came out differently, and the page reflects the verified behaviour:Greedy is not uniform across all paths. The issue says every backend uses
top_k=1for greedy. That is true of every path that takes agreedyflag —BaseVllmGenerationWorker._build_sampling_params,generate_text/generate_text_async,sglang_generation.py,trtllm_worker_async.py,megatron_worker.py, all resolving totemperature=0.0, top_k=1. Buttrtllm_http_server.pyhas nogreedyparameter at all, and neither does the vLLM chat-completions handler; on the HTTP paths greedy is whatever the caller puts on the request. The page states that rather than implying agreedyflag exists there.SGLang drops the key. It does not send
top_k: -1; it omitstop_kfrom the request dict entirely when the resolved value is-1. Worth stating since it is the one backend where "disabled" is not a value at all.require top_k >= 0is upstream, not in this repo. There is no such check innemo_rl/models/generation/trtllm/. It lives in TRT-LLM's ownSamplingParams(if self.top_k is not None and self.top_k < 0: raise ValueError(f"require top_k >= 0, got top_k={self.top_k}")), whose docstring also documents0as "all logits".tensorrt-llm==1.3.0rc21is whatpyproject.tomlpins. I verified it against upstream before writing it down.Scope
Kept to the suggested scope: the table, the
nullvs-1vs0rule, the vLLM-HTTPtop_kgap, greedy, and a pointer fromgeneration.md. It references #2053 for where top-p/top-k support came from and #3537 for the TRT-LLM direct-vs-HTTP alignment.I did not change any behaviour — in particular the vLLM HTTP path still ignores
top_k, and the page says so explicitly rather than pretending the config applies. If you would rather that path threadtop_klike TRT-LLM's now does, that is a code change and I am happy to open it separately.