Skip to content

[None][feat] Refactor scaffolding streaming feature and fix openai wo…#8622

Merged
WeiHaocheng merged 1 commit intoNVIDIA:mainfrom
WeiHaocheng:feat/main_scaffolding_refactor_streaming_fix_openai
Oct 30, 2025
Merged

[None][feat] Refactor scaffolding streaming feature and fix openai wo…#8622
WeiHaocheng merged 1 commit intoNVIDIA:mainfrom
WeiHaocheng:feat/main_scaffolding_refactor_streaming_fix_openai

Conversation

@WeiHaocheng
Copy link
Collaborator

@WeiHaocheng WeiHaocheng commented Oct 23, 2025

…rker

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced ScaffoldingOutput structure for improved result handling with text and token ID tracking.
  • Documentation

    • Removed AsyncGeneration example; consider consulting updated examples for streaming workflows.
  • Breaking Changes

    • Result output access pattern updated: use result.outputs[0].text instead of previous direct output access methods.
    • All examples updated to reflect new result structure.

Description

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

  • 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 the stage-list parameter 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.md
and the scripts/test_to_stage_mapping.py helper.

kill

kill

Kill all running builds associated with pull request.

skip

skip --comment COMMENT

Skip 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-pipeline

Reuse 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.

@WeiHaocheng WeiHaocheng requested a review from a team as a code owner October 23, 2025 09:25
@WeiHaocheng WeiHaocheng force-pushed the feat/main_scaffolding_refactor_streaming_fix_openai branch 2 times, most recently from dfdd847 to 14f2a7c Compare October 24, 2025 11:09
@WeiHaocheng WeiHaocheng self-assigned this Oct 24, 2025
@WeiHaocheng
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #22435 [ run ] triggered by Bot. Commit: 14f2a7c

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 24, 2025

📝 Walkthrough

Walkthrough

This PR refactors the scaffolding result and streaming architecture. It replaces a single-output model with a multi-output list-based system using a new ScaffoldingOutput dataclass, eliminates the central streaming_event in favor of streaming_output_flag and streaming_output_list, removes AsyncGeneration examples, and updates all callers to use result.outputs[0].text for result access.

Changes

Cohort / File(s) Summary
AsyncGeneration Example Removal
examples/scaffolding/contrib/AsyncGeneration/README.md, examples/scaffolding/contrib/AsyncGeneration/stream_generation_run.py
Deleted documentation and Python script demonstrating StreamGenerationTask usage, including CLI argument parsing, test flows, and main execution entry point.
Result Architecture Core Refactoring
tensorrt_llm/scaffolding/result.py
Introduced ScaffoldingOutput dataclass (text, token_ids). Replaced single-output handling with outputs list. Removed streaming_event parameter; added set_output_streaming(). Refactored queue-based streaming retrieval in _aresult_step. Removed iterative API (iter, next).
Task Structure and Streaming Fields
tensorrt_llm/scaffolding/task.py
Updated Task with streaming_output_flag and streaming_output_list. Refactored GenerationTask: removed streaming flag, added output_str, output_tokens, context_logits, logprobs fields. Added create_scaffolding_output(). Introduced StreamGenerationTask dataclass with cancel_flag, streaming_step, request_handle, end_flag and factory method create_from_generation_task().
Worker Streaming and Result Population
tensorrt_llm/scaffolding/worker.py
Added streaming_generate_helper() for token streaming loop and fill_task_with_result() to populate GenerationTask fields from GenerationResult. Refactored generate_async() to use streaming_output_list instead of streaming_event. Added ScaffoldingOutput construction for streaming outputs.
Controller and LLM Streaming Updates
tensorrt_llm/scaffolding/controller.py, tensorrt_llm/scaffolding/scaffolding_llm.py
Renamed task.streaming to task.streaming_output_flag. Removed streaming_event initialization and replaced with per-task streaming_output_list dispatch in scaffolding_llm.py. Simplified ScaffoldingResult construction.
Export and Import Path Changes
tensorrt_llm/scaffolding/__init__.py, tensorrt_llm/scaffolding/contrib/AsyncGeneration/__init__.py
Added duplicate StreamGenerationTask entry to all in scaffolding/init.py. Removed re-exports of StreamGenerationTask and stream_generation_handler from AsyncGeneration/init.py and all declaration.
MCP Contrib Updates
examples/scaffolding/contrib/mcp/mcptest.py, tensorrt_llm/scaffolding/contrib/mcp/chat_handler.py
Updated imports to use tensorrt_llm.scaffolding.contrib.mcp module path. Changed result access from result.output.output_str to result.outputs[0].text. Removed worker fallback for max_tokens, temperature, top_p in chat_handler (now task-only).
Dynasor Example Updates
examples/scaffolding/contrib/Dynasor/scaffolding_dynasor_run.py, tensorrt_llm/scaffolding/contrib/Dynasor/dynasor_controller.py
Updated streaming output printing to use step counter and tokens_num from result.outputs[0].token_ids. Refactored dynasor_controller suffix selection logic and removed early return path for certitude.
General Example Updates
examples/scaffolding/run_basic_generation.py, examples/scaffolding/token_budget_majority_vote.py
Replaced per-output inner loop with per-result step counter. Updated result access from result.output.output_str to result.outputs[0].text.
Test Updates
tests/unittest/scaffolding/test_bench.py, tests/unittest/scaffolding/test_scaffolding.py
Updated assertions to access results via result.outputs[0].text instead of result.output.output_str or result.cur_output.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Rationale: The diff spans 18 files with mixed complexity. Core architectural changes (result.py, task.py, worker.py, scaffolding_llm.py, controller.py) introduce new data structures (ScaffoldingOutput), replace event-based streaming with list-based streaming, and refactor inter-dependent logic paths. These require understanding both old and new flows and validating correctness across multiple modules. Examples and tests apply a consistent result-access pattern migration across 6 example files and 2 test files, which is more straightforward but still requires verification. Additionally, public API changes (task fields, result structure, worker methods) necessitate careful review of backward compatibility implications.

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description is significantly incomplete relative to the template requirements. The author has provided only the template structure without filling in any substantive content: the "Description" section contains only the template comment placeholder, the "Test Coverage" section lists no actual tests, and the "PR Checklist" boxes remain unchecked with no confirmation that the required items (coding guidelines, test coverage, dependency scanning, CODEOWNERS updates, documentation) have been reviewed. The description provides no explanation of what the changes accomplish, why they are necessary, or which tests validate the modifications, all of which are explicitly required by the template. The author should complete the PR description by: (1) providing a clear explanation in the Description section of what the scaffolding streaming refactoring entails and what the OpenAI/MCP fix addresses, (2) listing the specific test files and test cases that validate these changes (from the raw summary, test_scaffolding.py and test_bench.py appear relevant), (3) reviewing and checking off the PR Checklist items to confirm compliance with coding guidelines, test coverage requirements, and documentation updates. This will ensure reviewers have sufficient context to evaluate the changes.
Docstring Coverage ⚠️ Warning Docstring coverage is 6.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "[None][feat] Refactor scaffolding streaming feature and fix openai wo…" follows the correct format specified in the template, with [None] for no ticket and [feat] for feature type. The visible portion of the title is meaningfully related to the changes in the pull request, which include refactoring the scaffolding streaming functionality (reflected in changes to result.py, task.py, worker.py, controller.py) and adjustments to MCP-related code for OpenAI/API integration (seen in mcp/mcptest.py and mcp/chat_handler.py changes). Although the title appears truncated at the end, the content that is visible accurately reflects the primary nature of the changeset.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 13

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (6)
examples/scaffolding/token_budget_majority_vote.py (2)

1-1: Missing NVIDIA Apache-2.0 copyright header.

All Python source files must include the NVIDIA Apache-2.0 copyright header with the current year at the top of the file.

As per coding guidelines


16-17: Fix typo in parameter name.

The parameter name sumple_num_per_turn should be sample_num_per_turn. This typo appears throughout the file (lines 17, 21, 27, 34, 71, 97).

Apply this diff to fix the typo in the constructor:

-    def __init__(self, generation_controller: Controller, token_budget: int,
-                 sumple_num_per_turn: int):
+    def __init__(self, generation_controller: Controller, token_budget: int,
+                 sample_num_per_turn: int):
         super().__init__()
         self.generation_controller = generation_controller
         self.token_budget = token_budget
-        self.sumple_num_per_turn = sumple_num_per_turn
+        self.sample_num_per_turn = sample_num_per_turn

Similar changes are needed at lines 27, 34, 71, and 97.

examples/scaffolding/contrib/Dynasor/scaffolding_dynasor_run.py (2)

1-1: Add the required NVIDIA Apache-2.0 copyright header.

This Python source file is missing the NVIDIA Apache-2.0 copyright header with the current year (2025), which is required by the coding guidelines.

Add the following header at the top of the file:

+# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
 import argparse

As per coding guidelines


80-82: Add bounds checking for result.outputs list access.

The non-streaming path also accesses result.outputs[0] without verifying that the outputs list is non-empty, risking an IndexError.

Apply this diff:

         results = llm.generate(prompts)
         for result in results:
-            print(result.outputs[0].text)
+            if result.outputs:
+                print(result.outputs[0].text)
tensorrt_llm/scaffolding/contrib/Dynasor/dynasor_controller.py (1)

1-1: Add the required NVIDIA Apache-2.0 copyright header.

The coding guidelines require an Apache-2.0 copyright header with the current year (2025) at the top of all Python source files.

Add this header at the top of the file:

+# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
 from enum import Enum

As per coding guidelines.

tensorrt_llm/scaffolding/task.py (1)

1-1: Add NVIDIA Apache-2.0 header (2025).

Header is required for this Python file too.

Use the same header snippet as in result.py.

🧹 Nitpick comments (2)
examples/scaffolding/token_budget_majority_vote.py (1)

107-108: API change looks correct, but consider adding defensive checks.

The updated call to result.outputs[0].text correctly uses the new multi-output API structure. However, consider adding defensive checks:

  1. Verify that result.outputs is not empty before accessing index 0
  2. Handle the case where extract_answer_from_boxed returns None (when no boxed answer is found)

Example refactor for defensive coding:

-    extracted_answer = extract_answer_from_boxed(result.outputs[0].text)
-    print(f'extracted_answer={extracted_answer}')
+    if not result.outputs:
+        print('No outputs generated')
+    else:
+        extracted_answer = extract_answer_from_boxed(result.outputs[0].text)
+        if extracted_answer is None:
+            print('No boxed answer found in output')
+        else:
+            print(f'extracted_answer={extracted_answer}')
tensorrt_llm/scaffolding/task.py (1)

86-87: Minor: comment typo.

“don’t not use TokenLogprobs” → “avoid using TokenLogprobs for general support.”

Apply:

-    # TODO: don't not use TokenLogprobs for general support
+    # TODO: Avoid using TokenLogprobs for general support
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 602b059 and 14f2a7c.

📒 Files selected for processing (18)
  • examples/scaffolding/contrib/AsyncGeneration/README.md (0 hunks)
  • examples/scaffolding/contrib/AsyncGeneration/stream_generation_run.py (0 hunks)
  • examples/scaffolding/contrib/Dynasor/scaffolding_dynasor_run.py (1 hunks)
  • examples/scaffolding/contrib/mcp/mcptest.py (4 hunks)
  • examples/scaffolding/run_basic_generation.py (1 hunks)
  • examples/scaffolding/token_budget_majority_vote.py (1 hunks)
  • tensorrt_llm/scaffolding/__init__.py (1 hunks)
  • tensorrt_llm/scaffolding/contrib/AsyncGeneration/README.md (0 hunks)
  • tensorrt_llm/scaffolding/contrib/AsyncGeneration/__init__.py (0 hunks)
  • tensorrt_llm/scaffolding/contrib/Dynasor/dynasor_controller.py (1 hunks)
  • tensorrt_llm/scaffolding/contrib/mcp/chat_handler.py (1 hunks)
  • tensorrt_llm/scaffolding/controller.py (1 hunks)
  • tensorrt_llm/scaffolding/result.py (1 hunks)
  • tensorrt_llm/scaffolding/scaffolding_llm.py (2 hunks)
  • tensorrt_llm/scaffolding/task.py (5 hunks)
  • tensorrt_llm/scaffolding/worker.py (3 hunks)
  • tests/unittest/scaffolding/test_bench.py (1 hunks)
  • tests/unittest/scaffolding/test_scaffolding.py (4 hunks)
💤 Files with no reviewable changes (4)
  • examples/scaffolding/contrib/AsyncGeneration/README.md
  • tensorrt_llm/scaffolding/contrib/AsyncGeneration/README.md
  • tensorrt_llm/scaffolding/contrib/AsyncGeneration/init.py
  • examples/scaffolding/contrib/AsyncGeneration/stream_generation_run.py
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{h,hpp,hh,hxx,cpp,cxx,cc,cu,cuh,py}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

Use only spaces, no tabs; indent with 4 spaces.

Files:

  • tensorrt_llm/scaffolding/contrib/mcp/chat_handler.py
  • tensorrt_llm/scaffolding/scaffolding_llm.py
  • examples/scaffolding/contrib/mcp/mcptest.py
  • tests/unittest/scaffolding/test_scaffolding.py
  • tensorrt_llm/scaffolding/contrib/Dynasor/dynasor_controller.py
  • tensorrt_llm/scaffolding/worker.py
  • tensorrt_llm/scaffolding/result.py
  • tests/unittest/scaffolding/test_bench.py
  • tensorrt_llm/scaffolding/__init__.py
  • examples/scaffolding/token_budget_majority_vote.py
  • tensorrt_llm/scaffolding/controller.py
  • examples/scaffolding/run_basic_generation.py
  • examples/scaffolding/contrib/Dynasor/scaffolding_dynasor_run.py
  • tensorrt_llm/scaffolding/task.py
**/*.py

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.py: Python code must target Python 3.8+.
Indent Python code with 4 spaces; do not use tabs.
Maintain module namespace when importing; prefer 'from package.subpackage import foo' then 'foo.SomeClass()' instead of importing the class directly.
Python filenames should be snake_case (e.g., some_file.py).
Python classes use PascalCase names.
Functions and methods use snake_case names.
Local variables use snake_case; prefix 'k' for variables that start with a number (e.g., k_99th_percentile).
Global variables use upper SNAKE_CASE prefixed with 'G' (e.g., G_MY_GLOBAL).
Constants use upper SNAKE_CASE (e.g., MY_CONSTANT).
Avoid shadowing variables from an outer scope.
Initialize all externally visible members of a class in the constructor.
Prefer docstrings for interfaces that may be used outside a file; comments for in-function or file-local interfaces.
Use Google-style docstrings for classes and functions (Sphinx-parsable).
Document attributes and variables inline so they render under the class/function docstring.
Avoid reflection when a simpler, explicit approach suffices (e.g., avoid dict(**locals()) patterns).
In try/except, catch the most specific exceptions possible.
For duck-typing try/except, keep the try body minimal and use else for the main logic.

Files:

  • tensorrt_llm/scaffolding/contrib/mcp/chat_handler.py
  • tensorrt_llm/scaffolding/scaffolding_llm.py
  • examples/scaffolding/contrib/mcp/mcptest.py
  • tests/unittest/scaffolding/test_scaffolding.py
  • tensorrt_llm/scaffolding/contrib/Dynasor/dynasor_controller.py
  • tensorrt_llm/scaffolding/worker.py
  • tensorrt_llm/scaffolding/result.py
  • tests/unittest/scaffolding/test_bench.py
  • tensorrt_llm/scaffolding/__init__.py
  • examples/scaffolding/token_budget_majority_vote.py
  • tensorrt_llm/scaffolding/controller.py
  • examples/scaffolding/run_basic_generation.py
  • examples/scaffolding/contrib/Dynasor/scaffolding_dynasor_run.py
  • tensorrt_llm/scaffolding/task.py
**/*.{cpp,cxx,cc,h,hpp,hh,hxx,cu,cuh,py}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

Prepend the NVIDIA Apache-2.0 copyright header with current year to the top of all source files (e.g., .cpp, .h, .cu, .py).

Files:

  • tensorrt_llm/scaffolding/contrib/mcp/chat_handler.py
  • tensorrt_llm/scaffolding/scaffolding_llm.py
  • examples/scaffolding/contrib/mcp/mcptest.py
  • tests/unittest/scaffolding/test_scaffolding.py
  • tensorrt_llm/scaffolding/contrib/Dynasor/dynasor_controller.py
  • tensorrt_llm/scaffolding/worker.py
  • tensorrt_llm/scaffolding/result.py
  • tests/unittest/scaffolding/test_bench.py
  • tensorrt_llm/scaffolding/__init__.py
  • examples/scaffolding/token_budget_majority_vote.py
  • tensorrt_llm/scaffolding/controller.py
  • examples/scaffolding/run_basic_generation.py
  • examples/scaffolding/contrib/Dynasor/scaffolding_dynasor_run.py
  • tensorrt_llm/scaffolding/task.py
🧬 Code graph analysis (9)
tensorrt_llm/scaffolding/contrib/mcp/chat_handler.py (1)
tensorrt_llm/scaffolding/worker.py (1)
  • add_param_if_not_none (47-51)
tensorrt_llm/scaffolding/scaffolding_llm.py (2)
examples/scaffolding/contrib/Dynasor/scaffolding_dynasor_run.py (1)
  • task (67-75)
tensorrt_llm/scaffolding/result.py (3)
  • result (45-49)
  • set_output_streaming (30-31)
  • ScaffoldingResult (12-67)
examples/scaffolding/contrib/mcp/mcptest.py (2)
tensorrt_llm/scaffolding/contrib/mcp/chat_handler.py (1)
  • chat_handler (36-52)
tensorrt_llm/scaffolding/result.py (1)
  • result (45-49)
tests/unittest/scaffolding/test_scaffolding.py (1)
tensorrt_llm/scaffolding/result.py (1)
  • result (45-49)
tensorrt_llm/scaffolding/worker.py (5)
tensorrt_llm/llmapi/llm.py (1)
  • generate_async (332-497)
tensorrt_llm/executor/executor.py (1)
  • GenerationExecutor (77-578)
tensorrt_llm/executor/result.py (1)
  • GenerationResult (656-830)
tensorrt_llm/scaffolding/result.py (3)
  • result (45-49)
  • ScaffoldingOutput (7-9)
  • _aresult_step (37-43)
tensorrt_llm/scaffolding/task.py (3)
  • GenerationTask (46-99)
  • StreamGenerationTask (103-125)
  • StreamGenerationTask (136-150)
examples/scaffolding/token_budget_majority_vote.py (2)
tensorrt_llm/scaffolding/math_utils.py (1)
  • extract_answer_from_boxed (14-53)
tensorrt_llm/scaffolding/result.py (1)
  • result (45-49)
examples/scaffolding/run_basic_generation.py (2)
tensorrt_llm/scaffolding/result.py (1)
  • result (45-49)
tensorrt_llm/scaffolding/scaffolding_llm.py (1)
  • generate_async (173-193)
examples/scaffolding/contrib/Dynasor/scaffolding_dynasor_run.py (2)
tensorrt_llm/scaffolding/result.py (1)
  • result (45-49)
tensorrt_llm/scaffolding/scaffolding_llm.py (1)
  • generate_async (173-193)
tensorrt_llm/scaffolding/task.py (2)
tensorrt_llm/scaffolding/result.py (2)
  • result (45-49)
  • ScaffoldingOutput (7-9)
tensorrt_llm/scaffolding/contrib/AsyncGeneration/stream_generation.py (1)
  • StreamGenerationTask (10-33)
🪛 Ruff (0.14.1)
examples/scaffolding/contrib/mcp/mcptest.py

31-31: Redefinition of unused MCPController from line 7

Remove definition: MCPController

(F811)


31-31: Redefinition of unused MCPWorker from line 8

Remove definition: MCPWorker

(F811)

tensorrt_llm/scaffolding/result.py

34-34: Undefined name TaskCollection

(F821)


45-45: Unused method argument: timeout

(ARG002)

tensorrt_llm/scaffolding/task.py

136-136: Redefinition of unused StreamGenerationTask from line 103

(F811)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Pre-commit Check
🔇 Additional comments (12)
tensorrt_llm/scaffolding/contrib/Dynasor/dynasor_controller.py (2)

108-108: Code is correct; no changes needed.

The GenerationTask class maintains backward compatibility by keeping the output_str attribute, which is populated from result.outputs[0].text via the fill_task_with_result() method (see tensorrt_llm/scaffolding/worker.py:215). The dynasor_controller code reads from output_str after tasks have been filled, so the attribute access is valid. The internal GenerationTask API layer is properly bridged to the external output structure—no update required.


129-132: The review comment is based on incorrect assumptions about the codebase.

The original comment references "tasks[0].result assignment," but this attribute does not exist in the GenerationTask or Task classes. The codebase uses only output_str, which the current code at line 140 correctly assigns to: tasks[0].output_str = current_prompt.

The control flow refactoring is sound:

  • Certitude path: appends answer to current_prompt, breaks, then assigns at line 140
  • Max-tokens path: exits loop normally, then assigns at line 140
  • Both paths converge on the same output mechanism (output_str)

The suffix selection logic (line 129) correctly chooses answer_suffix_with_marker when </think> is not yet present to close the think tag.

Likely an incorrect or invalid review comment.

tensorrt_llm/scaffolding/contrib/mcp/chat_handler.py (1)

22-24: Worker-level parameter fallbacks removed—verify intended behavior.

The parameter selection now only considers task-level values for max_tokens, temperature, and top_p, removing worker-level fallbacks. If a task attribute is None, the parameter will not be set at all. Ensure this behavior is intentional and that downstream OpenAI API calls handle missing optional parameters correctly.

examples/scaffolding/contrib/mcp/mcptest.py (1)

64-64: LGTM! Result access updated to new structure.

The change to result.outputs[0].text correctly aligns with the new multi-output result structure introduced in this PR.

tests/unittest/scaffolding/test_bench.py (1)

59-59: LGTM! Test assertion updated to new outputs structure.

The change correctly accesses the first output's text via results[0].outputs[0].text, aligning with the new multi-output result model.

tensorrt_llm/scaffolding/controller.py (1)

70-70: LGTM! Attribute renamed to match new streaming architecture.

The rename from task.streaming to task.streaming_output_flag aligns with the broader streaming refactoring. The logic remains unchanged.

examples/scaffolding/run_basic_generation.py (1)

57-63: LGTM! Async streaming simplified with new outputs structure.

The refactored loop removes the inner iteration and directly accesses result.outputs[0], making the code cleaner and consistent with the new multi-output result model.

tests/unittest/scaffolding/test_scaffolding.py (1)

52-53: LGTM! All test assertions updated to new outputs structure.

All test assertions now correctly access the output text via result.outputs[0].text, consistently reflecting the new multi-output result model across unbatched, batched, async, and majority vote scenarios.

Also applies to: 65-66, 77-78, 89-90

tensorrt_llm/scaffolding/scaffolding_llm.py (2)

84-87: LGTM! Streaming refactored to use output list.

The streaming logic now correctly iterates over task.streaming_output_list and emits outputs via set_output_streaming, replacing the previous event-based mechanism. Clearing the list after emission prevents duplicate outputs.


174-174: LGTM! ScaffoldingResult initialization simplified.

The removal of the streaming_event argument aligns with the streaming architecture refactoring where results now use a queue-based approach instead of event-based synchronization.

tensorrt_llm/scaffolding/task.py (1)

81-89: Result fields and create_scaffolding_output look consistent.

Mapping to ScaffoldingOutput aligns with the new outputs[0] API.

Also applies to: 98-100

tensorrt_llm/scaffolding/worker.py (1)

214-219: Field mapping confirmed in GenerationResult outputs API.

The GenerationResult class exposes the accessed fields correctly. Verification confirms:

  • outputs[0].text, outputs[0].token_ids, and outputs[0].logprobs are consistently accessed throughout the codebase
  • context_logits is present at the GenerationResult level as expected

The field mapping is sound and aligns with existing API usage patterns.

@tensorrt-cicd
Copy link
Collaborator

PR_Github #22435 [ run ] completed with state SUCCESS. Commit: 14f2a7c
/LLM/main/L0_MergeRequest_PR pipeline #16908 completed with status: 'FAILURE'

@WeiHaocheng WeiHaocheng force-pushed the feat/main_scaffolding_refactor_streaming_fix_openai branch from 14f2a7c to fbda2be Compare October 26, 2025 01:50
@WeiHaocheng
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #22514 [ run ] triggered by Bot. Commit: fbda2be

@tensorrt-cicd
Copy link
Collaborator

PR_Github #22514 [ run ] completed with state SUCCESS. Commit: fbda2be
/LLM/main/L0_MergeRequest_PR pipeline #16971 completed with status: 'SUCCESS'
Pipeline passed with automatic retried tests. Check the rerun report for details.

@WeiHaocheng WeiHaocheng force-pushed the feat/main_scaffolding_refactor_streaming_fix_openai branch from fbda2be to 24576d4 Compare October 29, 2025 06:44
@WeiHaocheng WeiHaocheng enabled auto-merge (squash) October 29, 2025 06:44
@WeiHaocheng
Copy link
Collaborator Author

/bot run --reuse-pipeline

@tensorrt-cicd
Copy link
Collaborator

PR_Github #22858 Bot args parsing error: usage: /bot [-h]
{run,kill,skip,submit,reviewers,reuse-pipeline,reuse-review} ...
/bot: error: unrecognized arguments: --reuse-pipeline

@WeiHaocheng
Copy link
Collaborator Author

/bot --help

@github-actions
Copy link

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 the stage-list parameter to access the appropriate container environment. Note: Does NOT update GitHub check status.

kill

kill

Kill all running builds associated with pull request.

skip

skip --comment COMMENT

Skip 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-pipeline

Reuse 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.

@WeiHaocheng WeiHaocheng force-pushed the feat/main_scaffolding_refactor_streaming_fix_openai branch from 24576d4 to 9194149 Compare October 30, 2025 02:23
@WeiHaocheng WeiHaocheng disabled auto-merge October 30, 2025 02:23
@WeiHaocheng WeiHaocheng enabled auto-merge (squash) October 30, 2025 02:23
@WeiHaocheng
Copy link
Collaborator Author

/bot reuse-pipeline

@tensorrt-cicd
Copy link
Collaborator

PR_Github #22960 [ reuse-pipeline ] triggered by Bot. Commit: 9194149

@tensorrt-cicd
Copy link
Collaborator

PR_Github #22960 [ reuse-pipeline ] completed with state SUCCESS. Commit: 9194149
Reusing PR_Github #22514 for commit 9194149

…rker

Signed-off-by: Fred Wei <20514172+WeiHaocheng@users.noreply.github.com>
@WeiHaocheng WeiHaocheng force-pushed the feat/main_scaffolding_refactor_streaming_fix_openai branch from 9194149 to 09074aa Compare October 30, 2025 03:22
@WeiHaocheng
Copy link
Collaborator Author

/bot reuse-pipeline

1 similar comment
@WeiHaocheng
Copy link
Collaborator Author

/bot reuse-pipeline

@tensorrt-cicd
Copy link
Collaborator

PR_Github #23007 [ reuse-pipeline ] triggered by Bot. Commit: 09074aa

@tensorrt-cicd
Copy link
Collaborator

PR_Github #23007 [ reuse-pipeline ] completed with state SUCCESS. Commit: 09074aa
Reusing PR_Github #22514 for commit 09074aa

@WeiHaocheng WeiHaocheng merged commit cc28668 into NVIDIA:main Oct 30, 2025
4 of 5 checks passed
fredricz-20070104 pushed a commit to fredricz-20070104/TensorRT-LLM that referenced this pull request Nov 5, 2025
NVIDIA#8622)

Signed-off-by: Fred Wei <20514172+WeiHaocheng@users.noreply.github.com>
Signed-off-by: FredricZ-2007 <226039983+fredricz-20070104@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants