-
Notifications
You must be signed in to change notification settings - Fork 2k
[TRTLLM-10154][feat] Enable guided decoding with reasoning parsers #10890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
/bot run --disable-fail-fast |
|
PR_Github #32949 [ run ] triggered by Bot. Commit: |
📝 WalkthroughWalkthroughThe changes integrate reasoning parser support into the OpenAI protocol handling layer, enabling optional rewrapping of guided decoding parameters with reasoning-oriented structural tags and propagating this capability through sampling parameter constructors in protocol serialization paths. Testing infrastructure is updated to parameterize model configurations across multiple test runs. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tensorrt_llm/serve/openai_protocol.py (1)
1-3: Add the NVIDIA copyright header.This source file lacks the required NVIDIA copyright header with the latest meaningful modification year (2026). Please add the standard project header above the existing comments to meet compliance requirements.
🤖 Fix all issues with AI agents
In `@tensorrt_llm/serve/openai_protocol.py`:
- Line 40: The import of ReasoningParserFactory should preserve the module
namespace: change the direct symbol import to import the reasoning_parser module
(e.g., import tensorrt_llm.llmapi.reasoning_parser as reasoning_parser) and
update all usages like ReasoningParserFactory(...) to
reasoning_parser.ReasoningParserFactory(...); also update the other
occurrence(s) around the block referenced (uses at the lines corresponding to
276-277) to similarly qualify with reasoning_parser to follow the
namespace-preserving import guideline.
In `@tests/integration/defs/.test_durations`:
- Line 834: Add a missing duration entry for the "openai/gpt-oss-120b" variant
in the .test_durations list for the parametrized test
"test_e2e.py::test_openai_chat_guided_decoding": add a new key-value pair with
the exact test identifier
"test_e2e.py::test_openai_chat_guided_decoding[openai/gpt-oss-120b]" and a
numeric duration (e.g., match the existing Llama value 55.12449237401597 or use
an observed/estimated runtime) so the durations file contains entries for both
"meta-llama/Llama-3.1-8B-Instruct" and "openai/gpt-oss-120b".
In `@tests/integration/defs/test_e2e.py`:
- Around line 1702-1709: The test test_openai_chat_guided_decoding uses model
names containing "/" and "-" which break pytest's -k expression and also has an
unused llm_root parameter; update the signature to mark the unused param (e.g.,
_llm_root) and map each model_name to a safe identifier before invoking
llm_venv.run_cmd, then pass that safe identifier to the "-k" argument in
llm_venv.run_cmd so pytest receives a valid expression; adjust references to
model_name in the test body (and the parameter list) accordingly to use the
mapped safe key when filtering.
In `@tests/unittest/llmapi/apps/_test_openai_chat_guided_decoding.py`:
- Around line 27-40: The helper temp_extra_llm_api_options_file currently writes
to a fixed path "extra_llm_api_options.yaml" which can collide across parallel
tests; change it to create a unique temp file (e.g., use
tempfile.NamedTemporaryFile(delete=False) or tempfile.mkstemp or create a unique
temp dir via tempfile.mkdtemp) and write the YAML there, returning the unique
path; update any uses of temp_extra_llm_api_options_file to rely on the returned
path and ensure the file is removed after the test if needed—refer to the
temp_extra_llm_api_options_file function and the
extra_llm_api_options_dict/speculative_config keys to locate where to implement
this.
🧹 Nitpick comments (1)
tests/unittest/llmapi/apps/_test_openai_chat_guided_decoding.py (1)
19-23: Add explicitidsso nodeids are safe for-kfiltering.Default ids include
/and-, which can make-kselection brittle. Explicit ids keep selection stable and machine-safe.🔧 Suggested tweak
-@pytest.fixture( - scope="module", - params=["meta-llama/Llama-3.1-8B-Instruct", "openai/gpt-oss-120b"]) +@pytest.fixture( + scope="module", + params=["meta-llama/Llama-3.1-8B-Instruct", "openai/gpt-oss-120b"], + ids=["llama3_1_8b", "gpt_oss_120b"]) def model_name(request): return request.param
Signed-off-by: Enwei Zhu <21126786+syuoni@users.noreply.github.com>
d442d6f to
745e717
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #32955 [ run ] triggered by Bot. Commit: |
|
PR_Github #32955 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #33030 [ run ] triggered by Bot. Commit: |
|
PR_Github #33030 [ run ] completed with state |
LinPoly
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…VIDIA#10890) Signed-off-by: Enwei Zhu <21126786+syuoni@users.noreply.github.com>
Description
This PR enables guided decoding with reasoning parsers (including harmony format), resolving:
We choose xgrammar's structural tag to enable this combination, offloading all the grammar-related things to grammar engines. This choice also reduces the risk to break higher-order feature combinations (e.g., with speculative decoding).
Test Coverage
PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...Provide a user friendly way for developers to interact with a Jenkins server.
Run
/bot [-h|--help]to print this help message.See details below for each supported subcommand.
Details
run [--reuse-test (optional)pipeline-id --disable-fail-fast --skip-test --stage-list "A10-PyTorch-1, xxx" --gpu-type "A30, H100_PCIe" --test-backend "pytorch, cpp" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" --detailed-log --debug(experimental)]Launch build/test pipelines. All previously running jobs will be killed.
--reuse-test (optional)pipeline-id(OPTIONAL) : Allow the new pipeline to reuse build artifacts and skip successful test stages from a specified pipeline or the last pipeline if no pipeline-id is indicated. If the Git commit ID has changed, this option will be always ignored. The DEFAULT behavior of the bot is to reuse build artifacts and successful test results from the last pipeline.--disable-reuse-test(OPTIONAL) : Explicitly prevent the pipeline from reusing build artifacts and skipping successful test stages from a previous pipeline. Ensure that all builds and tests are run regardless of previous successes.--disable-fail-fast(OPTIONAL) : Disable fail fast on build/tests/infra failures.--skip-test(OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.--stage-list "A10-PyTorch-1, xxx"(OPTIONAL) : Only run the specified test stages. Examples: "A10-PyTorch-1, xxx". Note: Does NOT update GitHub check status.--gpu-type "A30, H100_PCIe"(OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.--test-backend "pytorch, cpp"(OPTIONAL) : Skip test stages which don't match the specified backends. Only support [pytorch, cpp, tensorrt, triton]. Examples: "pytorch, cpp" (does not run test stages with tensorrt or triton backend). Note: Does NOT update GitHub pipeline status.--only-multi-gpu-test(OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.--disable-multi-gpu-test(OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.--add-multi-gpu-test(OPTIONAL) : Force run the multi-GPU tests in addition to running L0 pre-merge pipeline.--post-merge(OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.--extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx"(OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx".--detailed-log(OPTIONAL) : Enable flushing out all logs to the Jenkins console. This will significantly increase the log volume and may slow down the job.--debug(OPTIONAL) : Experimental feature. Enable access to the CI container for debugging purpose. Note: Specify exactly one stage in thestage-listparameter to access the appropriate container environment. Note: Does NOT update GitHub check status.For guidance on mapping tests to stage names, see
docs/source/reference/ci-overview.mdand the
scripts/test_to_stage_mapping.pyhelper.kill
killKill all running builds associated with pull request.
skip
skip --comment COMMENTSkip testing for latest commit on pull request.
--comment "Reason for skipping build/test"is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.reuse-pipeline
reuse-pipelineReuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.
Summary by CodeRabbit
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.