Skip to content

Conversation

@Superjomn
Copy link
Collaborator

@Superjomn Superjomn commented Sep 15, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Error responses within batched results are now forwarded unchanged, avoiding redundant wrapping and ensuring clearer, consistent error messages.
  • Tests

    • Added coverage for very long prompts to ensure stable handling of oversized inputs.
    • Added a validation test confirming requests exceeding the configured max-token limit produce a clear, actionable error.

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.

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.

@Superjomn Superjomn requested a review from a team as a code owner September 15, 2025 08:08
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 15, 2025

📝 Walkthrough

Walkthrough

Added an early passthrough in handle_for_ipc_batched to forward pre-existing ErrorResponse objects unchanged; other responses still undergo background-error checks, error wrapping, or logprob processing. Added two tests: a long-prompt OpenAI completion test and a PyTorch LLM max-token overflow test.

Changes

Cohort / File(s) Summary
Executor response handling
tensorrt_llm/executor/worker.py
Added an early isinstance(response, ErrorResponse) guard in handle_for_ipc_batched to pass ErrorResponse instances through unchanged; preserved existing background-error detection, response.has_error() wrapping, logprobs computation, and _send_rsp invocation.
OpenAI completions tests
tests/unittest/llmapi/apps/_test_openai_completions.py
Added test_single_completion_with_too_long_prompt which calls client.completions.create with a long repeated prompt, max_tokens=5, and temperature=0.0.
PyTorch LLM tests
tests/unittest/llmapi/test_llm_pytorch.py
Added import random and TestLlmError.test_max_num_token_check that builds an LLM with max_num_tokens=100, supplies 101 token IDs, and asserts a ValueError about exceeding max_num_tokens.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Client
  participant Worker
  participant BGCheck as BackgroundErrorCheck

  Client->>Worker: send batched request
  Worker->>Worker: produce/receive response
  alt response is ErrorResponse (passthrough)
    Worker-->>Client: forward ErrorResponse (unchanged)
  else not ErrorResponse
    Worker->>BGCheck: _has_background_error(response)?
    alt background error present
      Worker-->>Client: _create_error_response(...) -> _send_rsp
    else no background error
      alt response.has_error()
        Worker-->>Client: wrap as ErrorResponse -> _send_rsp
      else success
        Worker->>Worker: compute logprobs / wrap if needed
        Worker-->>Client: _send_rsp success
      end
    end
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR body contains only the repository's standard template scaffold with placeholder headings and no concrete Description or Test Coverage content explaining the fix, rationale, or tests. The template requires a short explanation of the issue and solution plus the tests that guard the change, but those sections are blank which prevents reviewers from understanding intent, scope, and verification steps. Because the required descriptive details are missing, the description check fails. Please populate the Description with a concise summary of the bug and the code changes (files modified and rationale) and include the NVBugs/issue reference; list the exact tests added or modified in Test Coverage (for example, tests/unittest/llmapi/test_llm_pytorch.py::TestLlmError::test_max_num_token_check and tests/unittest/llmapi/apps/_test_openai_completions.py::test_single_completion_with_too_long_prompt) and explain how they validate the fix; and complete the PR Checklist and include any CI failure context or repro steps so reviewers can validate and approve the change.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% 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 "[https://nvbugs/5427043][fix] cherrypick: request length exceeds max_num_tokens" follows the repository's ticketed-format and succinctly identifies the primary issue being addressed (requests exceeding max_num_tokens). The raw change summary shows tests and logic related to enforcing max_num_tokens and related error handling, so the title is directly related and informative for reviewers.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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.

@Superjomn
Copy link
Collaborator Author

/bot run

@Superjomn Superjomn changed the title [https://nvbugs/5427043][fix] request length exceeds max_num_tokens [https://nvbugs/5427043][fix] cherrypick: request length exceeds max_num_tokens Sep 15, 2025
@Superjomn Superjomn requested a review from litaotju September 15, 2025 08:08
@tensorrt-cicd
Copy link
Collaborator

PR_Github #18597 [ run ] triggered by Bot

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: 3

Caution

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

⚠️ Outside diff range comments (2)
tensorrt_llm/executor/worker.py (1)

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

All Python sources must start with the NVIDIA Apache-2.0 copyright header for 2025.

Apply this diff at the top of the file:

+# Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# 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.
tests/unittest/llmapi/apps/_test_openai_completions.py (1)

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

All Python sources must start with the NVIDIA Apache-2.0 copyright header for 2025.

Apply this diff at the top of the file:

+# Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# 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.
🧹 Nitpick comments (1)
tests/unittest/llmapi/test_llm_pytorch.py (1)

829-838: Make the test deterministic and release resources.

  • Seed RNG or avoid randomness to prevent flaky tests.
  • Use the LLM context manager (or explicit shutdown) to avoid leaking GPU resources.
  • Decorate with force_ampere to match other GPU-bound tests.

Apply this diff:

-class TestLlmError:
+class TestLlmError:
 
-    def test_max_num_token_check(self):
+    @force_ampere
+    def test_max_num_token_check(self):
         """ LLM should raise error when got prompt length exceed the valid range. """
         llm = LLM(llama_model_path,
                   kv_cache_config=global_kvcache_config,
                   max_num_tokens=100)
 
-        with pytest.raises(ValueError,
-                           match="should not exceed max_num_tokens"):
-            ids = [random.randint(10, 100) for _ in range(101)]
-            llm.generate([ids])
+        with llm:
+            with pytest.raises(ValueError, match="should not exceed max_num_tokens"):
+                random.seed(0)
+                ids = [random.randint(10, 100) for _ in range(101)]
+                llm.generate([ids])
📜 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 2d40adb and 05b308d.

📒 Files selected for processing (3)
  • tensorrt_llm/executor/worker.py (1 hunks)
  • tests/unittest/llmapi/apps/_test_openai_completions.py (1 hunks)
  • tests/unittest/llmapi/test_llm_pytorch.py (2 hunks)
🧰 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/executor/worker.py
  • tests/unittest/llmapi/test_llm_pytorch.py
  • tests/unittest/llmapi/apps/_test_openai_completions.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/executor/worker.py
  • tests/unittest/llmapi/test_llm_pytorch.py
  • tests/unittest/llmapi/apps/_test_openai_completions.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/executor/worker.py
  • tests/unittest/llmapi/test_llm_pytorch.py
  • tests/unittest/llmapi/apps/_test_openai_completions.py
🧬 Code graph analysis (3)
tensorrt_llm/executor/worker.py (2)
tensorrt_llm/serve/openai_protocol.py (1)
  • ErrorResponse (100-105)
tensorrt_llm/executor/utils.py (1)
  • ErrorResponse (107-110)
tests/unittest/llmapi/test_llm_pytorch.py (1)
tensorrt_llm/llmapi/llm.py (1)
  • generate (235-313)
tests/unittest/llmapi/apps/_test_openai_completions.py (1)
tests/unittest/llmapi/apps/_test_openai_chat.py (2)
  • client (82-83)
  • model_name (21-22)
🪛 Ruff (0.12.2)
tests/unittest/llmapi/test_llm_pytorch.py

837-837: Standard pseudo-random generators are not suitable for cryptographic purposes

(S311)

⏰ 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

@tensorrt-cicd
Copy link
Collaborator

PR_Github #18597 [ run ] completed with state SUCCESS
/LLM/release-1.0/L0_MergeRequest_PR pipeline #387 completed with status: 'FAILURE'

@Superjomn
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #18687 [ run ] triggered by Bot

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: 0

♻️ Duplicate comments (1)
tests/unittest/llmapi/test_llm_pytorch.py (1)

1-1: No NVIDIA header needed in tests (ack past bot comment).

Per repo convention, files under tests/ don’t require the NVIDIA Apache-2.0 header. The prior bot warning can be ignored.

🧹 Nitpick comments (2)
tests/unittest/llmapi/test_llm_pytorch.py (2)

1-1: Drop unnecessary RNG import (make test deterministic).

Avoids flakiness and silences Ruff S311 by not using random at all.

Apply:

-import random

827-838: Make the test deterministic, ensure LLM cleanup, and relax the exception match

  • Use a deterministic token sequence (e.g. ids = [42] * 101) instead of random.
  • Construct/enter the LLM with a context manager to guarantee cleanup (with LLM(model=..., kv_cache_config=..., max_num_tokens=100) as llm: ...).
  • Rename test to test_max_num_tokens_check and fix docstring to: "LLM should raise an error when prompt length exceeds max_num_tokens."
  • Relax the pytest.raises match to something robust (e.g. match=r"max_num_tokens") — the exact phrase "should not exceed max_num_tokens" only appears in this test, not in the raise sites.

Location: tests/unittest/llmapi/test_llm_pytorch.py (around lines 827–838).

📜 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 05b308d and 73c482e.

📒 Files selected for processing (3)
  • tensorrt_llm/executor/worker.py (1 hunks)
  • tests/unittest/llmapi/apps/_test_openai_completions.py (1 hunks)
  • tests/unittest/llmapi/test_llm_pytorch.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • tensorrt_llm/executor/worker.py
  • tests/unittest/llmapi/apps/_test_openai_completions.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:

  • tests/unittest/llmapi/test_llm_pytorch.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:

  • tests/unittest/llmapi/test_llm_pytorch.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:

  • tests/unittest/llmapi/test_llm_pytorch.py
🧠 Learnings (2)
📚 Learning: 2025-09-04T17:00:29.500Z
Learnt from: CR
PR: NVIDIA/TensorRT-LLM#0
File: CODING_GUIDELINES.md:0-0
Timestamp: 2025-09-04T17:00:29.500Z
Learning: Applies to **/*.{cpp,cxx,cc,h,hpp,hh,hxx,cu,cuh,py} : Prepend the NVIDIA Apache-2.0 copyright header with current year to the top of all source files (e.g., .cpp, .h, .cu, .py).

Applied to files:

  • tests/unittest/llmapi/test_llm_pytorch.py
📚 Learning: 2025-08-06T13:58:07.506Z
Learnt from: galagam
PR: NVIDIA/TensorRT-LLM#6487
File: tests/unittest/_torch/auto_deploy/unit/singlegpu/test_ad_trtllm_bench.py:1-12
Timestamp: 2025-08-06T13:58:07.506Z
Learning: In TensorRT-LLM, test files (files under tests/ directories) do not require NVIDIA copyright headers, unlike production source code files. Test files typically start directly with imports, docstrings, or code.

Applied to files:

  • tests/unittest/llmapi/test_llm_pytorch.py
🧬 Code graph analysis (1)
tests/unittest/llmapi/test_llm_pytorch.py (1)
tensorrt_llm/llmapi/llm.py (2)
  • LLM (1111-1127)
  • generate (235-313)
🪛 Ruff (0.12.2)
tests/unittest/llmapi/test_llm_pytorch.py

837-837: Standard pseudo-random generators are not suitable for cryptographic purposes

(S311)

⏰ 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 (1)
tests/unittest/llmapi/test_llm_pytorch.py (1)

825-826: Whitespace-only change.

No action needed.

@tensorrt-cicd
Copy link
Collaborator

PR_Github #18687 [ run ] completed with state SUCCESS
/LLM/release-1.0/L0_MergeRequest_PR pipeline #392 completed with status: 'FAILURE'

@Superjomn
Copy link
Collaborator Author

/bot run

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: 0

♻️ Duplicate comments (1)
tests/unittest/llmapi/apps/_test_openai_completions.py (1)

83-93: Turn this into a real assertion; printing isn’t a test.

Assert the client raises on too-long prompts and remove the print.

Apply this diff:

-def test_single_completion_with_too_long_prompt(client: openai.OpenAI,
-                                                model_name):
-    completion = client.completions.create(
-        model=model_name,
-        prompt="Hello, my name is" * 100,
-        max_tokens=5,
-        temperature=0.0,
-    )
-
-    print(completion)
+def test_single_completion_with_too_long_prompt(client: openai.OpenAI,
+                                                model_name):
+    with pytest.raises(openai.BadRequestError,
+                       match=r"(should not exceed max_num_tokens|exceed|too\s+long)"):
+        client.completions.create(
+            model=model_name,
+            prompt="Hello, my name is" * 100,
+            max_tokens=5,
+            temperature=0.0,
+        )
🧹 Nitpick comments (2)
tests/unittest/llmapi/test_llm_pytorch.py (2)

1-1: Drop randomness in tests; make deterministic (also silences Ruff S311).

Random token IDs can cause flakiness and trigger S311. Use a fixed sequence; token ID 0 is valid and already used elsewhere in this file.

Apply this diff:

-import random

829-838: Make the check deterministic and tighten the docstring.

Deterministic IDs make the failure mode consistent across runs; improve docstring grammar.

Apply this diff:

-    def test_max_num_token_check(self):
-        """ LLM should raise error when got prompt length exceed the valid range. """
+    def test_max_num_token_check(self):
+        """LLM should raise when prompt length exceeds max_num_tokens."""
         llm = LLM(llama_model_path,
                   kv_cache_config=global_kvcache_config,
                   max_num_tokens=100)

         with pytest.raises(ValueError,
                            match="should not exceed max_num_tokens"):
-            ids = [random.randint(10, 100) for _ in range(101)]
+            ids = [0] * 101
             llm.generate([ids])
📜 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 73c482e and 0e21a58.

📒 Files selected for processing (3)
  • tensorrt_llm/executor/worker.py (1 hunks)
  • tests/unittest/llmapi/apps/_test_openai_completions.py (1 hunks)
  • tests/unittest/llmapi/test_llm_pytorch.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tensorrt_llm/executor/worker.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:

  • tests/unittest/llmapi/apps/_test_openai_completions.py
  • tests/unittest/llmapi/test_llm_pytorch.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:

  • tests/unittest/llmapi/apps/_test_openai_completions.py
  • tests/unittest/llmapi/test_llm_pytorch.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:

  • tests/unittest/llmapi/apps/_test_openai_completions.py
  • tests/unittest/llmapi/test_llm_pytorch.py
🧠 Learnings (2)
📚 Learning: 2025-09-04T17:00:29.500Z
Learnt from: CR
PR: NVIDIA/TensorRT-LLM#0
File: CODING_GUIDELINES.md:0-0
Timestamp: 2025-09-04T17:00:29.500Z
Learning: Applies to **/*.{cpp,cxx,cc,h,hpp,hh,hxx,cu,cuh,py} : Prepend the NVIDIA Apache-2.0 copyright header with current year to the top of all source files (e.g., .cpp, .h, .cu, .py).

Applied to files:

  • tests/unittest/llmapi/test_llm_pytorch.py
📚 Learning: 2025-08-06T13:58:07.506Z
Learnt from: galagam
PR: NVIDIA/TensorRT-LLM#6487
File: tests/unittest/_torch/auto_deploy/unit/singlegpu/test_ad_trtllm_bench.py:1-12
Timestamp: 2025-08-06T13:58:07.506Z
Learning: In TensorRT-LLM, test files (files under tests/ directories) do not require NVIDIA copyright headers, unlike production source code files. Test files typically start directly with imports, docstrings, or code.

Applied to files:

  • tests/unittest/llmapi/test_llm_pytorch.py
🧬 Code graph analysis (2)
tests/unittest/llmapi/apps/_test_openai_completions.py (1)
tests/unittest/llmapi/apps/_test_openai_chat.py (2)
  • client (82-83)
  • model_name (21-22)
tests/unittest/llmapi/test_llm_pytorch.py (2)
tests/unittest/_torch/test_beam_search.py (1)
  • llm (37-50)
tensorrt_llm/llmapi/llm.py (2)
  • LLM (1111-1127)
  • generate (235-313)
🪛 Ruff (0.12.2)
tests/unittest/llmapi/test_llm_pytorch.py

837-837: Standard pseudo-random generators are not suitable for cryptographic purposes

(S311)

⏰ 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

@Superjomn
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #18790 [ run ] triggered by Bot

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: 0

🧹 Nitpick comments (2)
tests/unittest/llmapi/test_llm_pytorch.py (2)

1-1: Remove unused nondeterministic import.

Drop random and make the test deterministic (also silences Ruff S311).

Apply this diff:

-import random

829-838: Make the test deterministic, robust, and ensure cleanup.

Avoid randomness, wrap LLM in a context manager, and relax the regex to be less brittle.

Apply this diff:

-        with pytest.raises(ValueError,
-                           match="should not exceed max_num_tokens"):
-            ids = [random.randint(10, 100) for _ in range(101)]
-            llm.generate([ids])
+        with llm:
+            with pytest.raises(ValueError, match=r"exceed.*max_num_tokens"):
+                ids = list(range(101))
+                llm.generate([ids])

Optional: add a boundary test to prevent off‑by‑one regressions:

def test_max_num_token_at_limit(self):
    llm = LLM(llama_model_path,
              kv_cache_config=global_kvcache_config,
              max_num_tokens=100)
    with llm:
        ids = list(range(100))  # exactly at limit
        llm.generate([ids])  # should not raise
📜 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 0e21a58 and aecf43c.

📒 Files selected for processing (3)
  • tensorrt_llm/executor/worker.py (1 hunks)
  • tests/unittest/llmapi/apps/_test_openai_completions.py (1 hunks)
  • tests/unittest/llmapi/test_llm_pytorch.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • tensorrt_llm/executor/worker.py
  • tests/unittest/llmapi/apps/_test_openai_completions.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:

  • tests/unittest/llmapi/test_llm_pytorch.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:

  • tests/unittest/llmapi/test_llm_pytorch.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:

  • tests/unittest/llmapi/test_llm_pytorch.py
🧠 Learnings (3)
📓 Common learnings
Learnt from: tongyuantongyu
PR: NVIDIA/TensorRT-LLM#7726
File: tensorrt_llm/executor/worker.py:983-986
Timestamp: 2025-09-15T10:44:42.133Z
Learning: ErrorResponse objects are only created for the IPC path (handle_for_ipc_batched()) to work around serialization issues when tllm.Response contains Exception objects. They never appear in the single-process path (handle_for_worker()).
📚 Learning: 2025-09-04T17:00:29.500Z
Learnt from: CR
PR: NVIDIA/TensorRT-LLM#0
File: CODING_GUIDELINES.md:0-0
Timestamp: 2025-09-04T17:00:29.500Z
Learning: Applies to **/*.{cpp,cxx,cc,h,hpp,hh,hxx,cu,cuh,py} : Prepend the NVIDIA Apache-2.0 copyright header with current year to the top of all source files (e.g., .cpp, .h, .cu, .py).

Applied to files:

  • tests/unittest/llmapi/test_llm_pytorch.py
📚 Learning: 2025-08-06T13:58:07.506Z
Learnt from: galagam
PR: NVIDIA/TensorRT-LLM#6487
File: tests/unittest/_torch/auto_deploy/unit/singlegpu/test_ad_trtllm_bench.py:1-12
Timestamp: 2025-08-06T13:58:07.506Z
Learning: In TensorRT-LLM, test files (files under tests/ directories) do not require NVIDIA copyright headers, unlike production source code files. Test files typically start directly with imports, docstrings, or code.

Applied to files:

  • tests/unittest/llmapi/test_llm_pytorch.py
🧬 Code graph analysis (1)
tests/unittest/llmapi/test_llm_pytorch.py (1)
tensorrt_llm/llmapi/llm.py (2)
  • LLM (1111-1127)
  • generate (235-313)
🪛 Ruff (0.12.2)
tests/unittest/llmapi/test_llm_pytorch.py

837-837: Standard pseudo-random generators are not suitable for cryptographic purposes

(S311)

⏰ 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 (1)
tests/unittest/llmapi/test_llm_pytorch.py (1)

1-1: Ignore header bot for tests.

Per repo convention, test files under tests/ don’t require the NVIDIA Apache-2.0 header. No action needed here.

@tensorrt-cicd
Copy link
Collaborator

PR_Github #18790 [ run ] completed with state ABORTED
/LLM/release-1.0/L0_MergeRequest_PR pipeline #397 completed with status: 'FAILURE'

@nv-guomingz nv-guomingz added the Cherry-pick It's a label that applies to Cherry-pick PR. label Sep 17, 2025
@Superjomn
Copy link
Collaborator Author

/bot run

@Superjomn Superjomn enabled auto-merge (squash) September 18, 2025 09:15
@tensorrt-cicd
Copy link
Collaborator

PR_Github #19171 [ run ] triggered by Bot

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: 0

Caution

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

⚠️ Outside diff range comments (2)
tensorrt_llm/executor/worker.py (2)

809-813: Construct ErrorResponse with a string message.

Passing the Exception object as error_msg violates the ErrorResponse schema and can break IPC serialization.

Apply this diff:

-                            worker._await_response_helper.temp_error_responses.put(
-                                ErrorResponse(req.id, e, req.id))
+                            worker._await_response_helper.temp_error_responses.put(
+                                ErrorResponse(req.id, str(e), req.id))

935-944: Convert all non-string ErrorResponse message arguments to strings

  • tensorrt_llm/executor/worker.py:257 — already uses str(bck_error) (OK).
  • tensorrt_llm/executor/worker.py:812 — currently passes exception variable e; change to str(e) when constructing ErrorResponse.
  • tensorrt_llm/executor/worker.py:942 — passes response.error_msg; ensure it is a string (wrap with str(response.error_msg) or provide a string fallback).
  • tensorrt_llm/serve/openai_server.py:132 — message is non-string; pass message=str(message) (or otherwise ensure it is a string).

Re-run the AST/script after changes to confirm no remaining non-string usages.

♻️ Duplicate comments (1)
tensorrt_llm/executor/worker.py (1)

935-937: Do not forward ErrorResponse with non‑string error_msg; coerce to str before IPC.

Without coercion, upstream sites that pass Exception objects (see worker_main) will leak non‑serializable payloads and can break pickling/JSON expectations.

Apply this diff:

-            if isinstance(response, ErrorResponse):
-                pass  # send ErrorResponse directly
+            if isinstance(response, ErrorResponse):
+                # Normalize error_msg for transport/schema
+                if not isinstance(response.error_msg, str):
+                    response = ErrorResponse(
+                        response.client_id, str(response.error_msg), response.request_id
+                    )
🧹 Nitpick comments (2)
tests/unittest/llmapi/test_llm_pytorch.py (2)

1-1: Remove unnecessary randomness (and import).

Deterministic IDs are sufficient here; using random adds noise and triggers S311. Replace with a fixed list and drop the import.

Apply this diff:

-import random

827-839: Make the test deterministic and ensure resource cleanup.

  • Use a context manager for LLM to avoid leaks.
  • Replace RNG with a deterministic token list; only length matters.

Apply this diff:

-class TestLlmError:
-
-    def test_max_num_token_check(self):
-        """ LLM should raise error when got prompt length exceed the valid range. """
-        llm = LLM(llama_model_path,
-                  kv_cache_config=global_kvcache_config,
-                  max_num_tokens=100)
-
-        with pytest.raises(ValueError,
-                           match="should not exceed max_num_tokens"):
-            ids = [random.randint(10, 100) for _ in range(101)]
-            llm.generate([ids])
+class TestLlmError:
+    def test_max_num_token_check(self):
+        """LLM raises when prompt length exceeds max_num_tokens."""
+        with LLM(
+            llama_model_path,
+            kv_cache_config=global_kvcache_config,
+            max_num_tokens=100,
+        ) as llm:
+            with pytest.raises(ValueError, match="should not exceed max_num_tokens"):
+                ids = [42] * 101  # deterministic valid token id
+                llm.generate([ids])
📜 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 aecf43c and e6710b8.

📒 Files selected for processing (3)
  • tensorrt_llm/executor/worker.py (1 hunks)
  • tests/unittest/llmapi/apps/_test_openai_completions.py (1 hunks)
  • tests/unittest/llmapi/test_llm_pytorch.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/unittest/llmapi/apps/_test_openai_completions.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/executor/worker.py
  • tests/unittest/llmapi/test_llm_pytorch.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/executor/worker.py
  • tests/unittest/llmapi/test_llm_pytorch.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/executor/worker.py
  • tests/unittest/llmapi/test_llm_pytorch.py
🧠 Learnings (3)
📓 Common learnings
Learnt from: tongyuantongyu
PR: NVIDIA/TensorRT-LLM#7726
File: tensorrt_llm/executor/worker.py:983-986
Timestamp: 2025-09-15T10:44:42.160Z
Learning: ErrorResponse objects are only created for the IPC path (handle_for_ipc_batched()) to work around serialization issues when tllm.Response contains Exception objects. They never appear in the single-process path (handle_for_worker()).
📚 Learning: 2025-09-04T17:00:29.500Z
Learnt from: CR
PR: NVIDIA/TensorRT-LLM#0
File: CODING_GUIDELINES.md:0-0
Timestamp: 2025-09-04T17:00:29.500Z
Learning: Applies to **/*.{cpp,cxx,cc,h,hpp,hh,hxx,cu,cuh,py} : Prepend the NVIDIA Apache-2.0 copyright header with current year to the top of all source files (e.g., .cpp, .h, .cu, .py).

Applied to files:

  • tests/unittest/llmapi/test_llm_pytorch.py
📚 Learning: 2025-08-06T13:58:07.506Z
Learnt from: galagam
PR: NVIDIA/TensorRT-LLM#6487
File: tests/unittest/_torch/auto_deploy/unit/singlegpu/test_ad_trtllm_bench.py:1-12
Timestamp: 2025-08-06T13:58:07.506Z
Learning: In TensorRT-LLM, test files (files under tests/ directories) do not require NVIDIA copyright headers, unlike production source code files. Test files typically start directly with imports, docstrings, or code.

Applied to files:

  • tests/unittest/llmapi/test_llm_pytorch.py
🧬 Code graph analysis (1)
tensorrt_llm/executor/worker.py (2)
tensorrt_llm/serve/openai_protocol.py (1)
  • ErrorResponse (100-105)
tensorrt_llm/executor/utils.py (1)
  • ErrorResponse (107-110)
🪛 Ruff (0.12.2)
tests/unittest/llmapi/test_llm_pytorch.py

837-837: Standard pseudo-random generators are not suitable for cryptographic purposes

(S311)

⏰ 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 (1)
tests/unittest/llmapi/test_llm_pytorch.py (1)

1-1: Clarification: header not required for tests.

Per repo convention, test files don’t carry the NVIDIA Apache-2.0 header. The prior bot warning can be ignored.

@tensorrt-cicd
Copy link
Collaborator

PR_Github #19171 [ run ] completed with state FAILURE
/LLM/release-1.0/L0_MergeRequest_PR pipeline #417 completed with status: 'FAILURE'

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: 0

♻️ Duplicate comments (1)
tensorrt_llm/executor/worker.py (1)

935-937: Coerce ErrorResponse.error_msg to str before IPC.

Passing Exception objects through IPC can break serialization. Convert error_msg to str here.

Apply this diff:

-            if isinstance(response, ErrorResponse):
-                pass  # send ErrorResponse directly
+            if isinstance(response, ErrorResponse):
+                # Ensure string payload for transport/schema compliance
+                if not isinstance(response.error_msg, str):
+                    response = ErrorResponse(response.client_id,
+                                             str(response.error_msg),
+                                             response.request_id)

Also fix the construction site that enqueues a raw Exception (outside this hunk) to keep call-sites consistent:

-                            worker._await_response_helper.temp_error_responses.put(
-                                ErrorResponse(req.id, e, req.id))
+                            worker._await_response_helper.temp_error_responses.put(
+                                ErrorResponse(req.id, str(e), req.id))
🧹 Nitpick comments (1)
tests/unittest/llmapi/test_llm_pytorch.py (1)

1-1: Make the test deterministic and ensure cleanup.

Avoid RNG in unit tests and use the LLM context manager to prevent resource leaks.

Apply this diff:

-import random
@@
 class TestLlmError:
 
     def test_max_num_token_check(self):
         """ LLM should raise error when got prompt length exceed the valid range. """
-        llm = LLM(llama_model_path,
-                  kv_cache_config=global_kvcache_config,
-                  max_num_tokens=100)
-
-        with pytest.raises(ValueError,
-                           match="should not exceed max_num_tokens"):
-            ids = [random.randint(10, 100) for _ in range(101)]
-            llm.generate([ids])
+        with LLM(llama_model_path,
+                 kv_cache_config=global_kvcache_config,
+                 max_num_tokens=100) as llm:
+            with pytest.raises(ValueError,
+                               match="should not exceed max_num_tokens"):
+                ids = [42] * 101
+                llm.generate([ids])

Also applies to: 829-839

📜 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 e6710b8 and 8355705.

📒 Files selected for processing (3)
  • tensorrt_llm/executor/worker.py (1 hunks)
  • tests/unittest/llmapi/apps/_test_openai_completions.py (1 hunks)
  • tests/unittest/llmapi/test_llm_pytorch.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/unittest/llmapi/apps/_test_openai_completions.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:

  • tests/unittest/llmapi/test_llm_pytorch.py
  • tensorrt_llm/executor/worker.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:

  • tests/unittest/llmapi/test_llm_pytorch.py
  • tensorrt_llm/executor/worker.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:

  • tests/unittest/llmapi/test_llm_pytorch.py
  • tensorrt_llm/executor/worker.py
🧠 Learnings (3)
📓 Common learnings
Learnt from: tongyuantongyu
PR: NVIDIA/TensorRT-LLM#7726
File: tensorrt_llm/executor/worker.py:983-986
Timestamp: 2025-09-15T10:44:42.160Z
Learning: ErrorResponse objects are only created for the IPC path (handle_for_ipc_batched()) to work around serialization issues when tllm.Response contains Exception objects. They never appear in the single-process path (handle_for_worker()).
📚 Learning: 2025-09-04T17:00:29.500Z
Learnt from: CR
PR: NVIDIA/TensorRT-LLM#0
File: CODING_GUIDELINES.md:0-0
Timestamp: 2025-09-04T17:00:29.500Z
Learning: Applies to **/*.{cpp,cxx,cc,h,hpp,hh,hxx,cu,cuh,py} : Prepend the NVIDIA Apache-2.0 copyright header with current year to the top of all source files (e.g., .cpp, .h, .cu, .py).

Applied to files:

  • tests/unittest/llmapi/test_llm_pytorch.py
📚 Learning: 2025-08-06T13:58:07.506Z
Learnt from: galagam
PR: NVIDIA/TensorRT-LLM#6487
File: tests/unittest/_torch/auto_deploy/unit/singlegpu/test_ad_trtllm_bench.py:1-12
Timestamp: 2025-08-06T13:58:07.506Z
Learning: In TensorRT-LLM, test files (files under tests/ directories) do not require NVIDIA copyright headers, unlike production source code files. Test files typically start directly with imports, docstrings, or code.

Applied to files:

  • tests/unittest/llmapi/test_llm_pytorch.py
🧬 Code graph analysis (2)
tests/unittest/llmapi/test_llm_pytorch.py (1)
tensorrt_llm/llmapi/llm.py (2)
  • LLM (1111-1127)
  • generate (235-313)
tensorrt_llm/executor/worker.py (2)
benchmarks/cpp/gptManagerBenchmark.cpp (4)
  • response (208-230)
  • response (208-209)
  • response (232-270)
  • response (232-232)
tensorrt_llm/executor/utils.py (1)
  • ErrorResponse (107-110)
🪛 Ruff (0.12.2)
tests/unittest/llmapi/test_llm_pytorch.py

837-837: Standard pseudo-random generators are not suitable for cryptographic purposes

(S311)

⏰ 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

@tensorrt-cicd
Copy link
Collaborator

PR_Github #19266 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #19266 [ run ] completed with state SUCCESS
/LLM/release-1.0/L0_MergeRequest_PR pipeline #420 completed with status: 'FAILURE'

@Superjomn
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #19358 [ run ] triggered by Bot

Signed-off-by: Superjomn <[email protected]>
@Superjomn
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #19489 [ run ] triggered by Bot

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: 0

🧹 Nitpick comments (2)
tests/unittest/llmapi/test_llm_pytorch.py (2)

1-1: Remove random import (switch test to deterministic IDs).

After making the test deterministic (see suggestion below), drop this now‑unneeded import.

-import random

827-839: Make the test deterministic and guarantee LLM cleanup.

  • Use fixed token IDs to avoid non‑determinism and S311 noise; the test only cares about length.
  • Use the LLM context manager so resources are released even when the exception is raised.
  • Tighten the docstring.
-class TestLlmError:
+class TestLlmError:

-    def test_max_num_token_check(self):
-        """ LLM should raise error when got prompt length exceed the valid range. """
-        llm = LLM(llama_model_path,
-                  kv_cache_config=global_kvcache_config,
-                  max_num_tokens=100)
-
-        with pytest.raises(ValueError,
-                           match="should not exceed max_num_tokens"):
-            ids = [random.randint(10, 100) for _ in range(101)]
-            llm.generate([ids])
+    def test_max_num_token_check(self):
+        """Raise when prompt length exceeds max_num_tokens."""
+        with LLM(model=llama_model_path,
+                 kv_cache_config=global_kvcache_config,
+                 max_num_tokens=100) as llm:
+            with pytest.raises(ValueError, match="should not exceed max_num_tokens"):
+                ids = [42] * 101
+                llm.generate([ids])

Optional: add a passing boundary case (len==100) in a separate test.

📜 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 8355705 and 903a995.

📒 Files selected for processing (3)
  • tensorrt_llm/executor/worker.py (1 hunks)
  • tests/unittest/llmapi/apps/_test_openai_completions.py (1 hunks)
  • tests/unittest/llmapi/test_llm_pytorch.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/unittest/llmapi/apps/_test_openai_completions.py
  • tensorrt_llm/executor/worker.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:

  • tests/unittest/llmapi/test_llm_pytorch.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:

  • tests/unittest/llmapi/test_llm_pytorch.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:

  • tests/unittest/llmapi/test_llm_pytorch.py
🧠 Learnings (3)
📓 Common learnings
Learnt from: tongyuantongyu
PR: NVIDIA/TensorRT-LLM#7726
File: tensorrt_llm/executor/worker.py:983-986
Timestamp: 2025-09-15T10:44:42.160Z
Learning: ErrorResponse objects are only created for the IPC path (handle_for_ipc_batched()) to work around serialization issues when tllm.Response contains Exception objects. They never appear in the single-process path (handle_for_worker()).
📚 Learning: 2025-09-04T17:00:29.500Z
Learnt from: CR
PR: NVIDIA/TensorRT-LLM#0
File: CODING_GUIDELINES.md:0-0
Timestamp: 2025-09-04T17:00:29.500Z
Learning: Applies to **/*.{cpp,cxx,cc,h,hpp,hh,hxx,cu,cuh,py} : Prepend the NVIDIA Apache-2.0 copyright header with current year to the top of all source files (e.g., .cpp, .h, .cu, .py).

Applied to files:

  • tests/unittest/llmapi/test_llm_pytorch.py
📚 Learning: 2025-08-06T13:58:07.506Z
Learnt from: galagam
PR: NVIDIA/TensorRT-LLM#6487
File: tests/unittest/_torch/auto_deploy/unit/singlegpu/test_ad_trtllm_bench.py:1-12
Timestamp: 2025-08-06T13:58:07.506Z
Learning: In TensorRT-LLM, test files (files under tests/ directories) do not require NVIDIA copyright headers, unlike production source code files. Test files typically start directly with imports, docstrings, or code.

Applied to files:

  • tests/unittest/llmapi/test_llm_pytorch.py
🧬 Code graph analysis (1)
tests/unittest/llmapi/test_llm_pytorch.py (1)
tensorrt_llm/llmapi/llm.py (2)
  • LLM (1111-1127)
  • generate (235-313)
🪛 Ruff (0.13.1)
tests/unittest/llmapi/test_llm_pytorch.py

837-837: Standard pseudo-random generators are not suitable for cryptographic purposes

(S311)

⏰ 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 (1)
tests/unittest/llmapi/test_llm_pytorch.py (1)

1-1: No license header needed for tests; ignore the bot’s suggestion.

Per repo norms for tests/ files, copyright headers are not required. Leaving the file headerless is correct. (Based on retrieved learnings.)

@tensorrt-cicd
Copy link
Collaborator

PR_Github #19489 [ run ] completed with state SUCCESS
/LLM/release-1.0/L0_MergeRequest_PR pipeline #434 completed with status: 'FAILURE'

@Superjomn
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #19542 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #19542 [ run ] completed with state SUCCESS
/LLM/release-1.0/L0_MergeRequest_PR pipeline #436 completed with status: 'SUCCESS'

@Superjomn Superjomn merged commit bc4136f into NVIDIA:release/1.0 Sep 22, 2025
4 checks passed
@Superjomn Superjomn deleted the release-cherry-pick branch September 22, 2025 10:37
dominicshanshan pushed a commit to dominicshanshan/TensorRT-LLM that referenced this pull request Sep 23, 2025
dominicshanshan pushed a commit to dominicshanshan/TensorRT-LLM that referenced this pull request Sep 23, 2025
dominicshanshan pushed a commit to dominicshanshan/TensorRT-LLM that referenced this pull request Sep 23, 2025
yuanjingx87 pushed a commit that referenced this pull request Sep 23, 2025
dominicshanshan pushed a commit to dominicshanshan/TensorRT-LLM that referenced this pull request Sep 24, 2025
dominicshanshan pushed a commit to dominicshanshan/TensorRT-LLM that referenced this pull request Sep 24, 2025
dominicshanshan pushed a commit to dominicshanshan/TensorRT-LLM that referenced this pull request Sep 24, 2025
dominicshanshan pushed a commit to dominicshanshan/TensorRT-LLM that referenced this pull request Sep 24, 2025
dominicshanshan pushed a commit to dominicshanshan/TensorRT-LLM that referenced this pull request Sep 24, 2025
dominicshanshan pushed a commit to dominicshanshan/TensorRT-LLM that referenced this pull request Sep 24, 2025
dominicshanshan pushed a commit to dominicshanshan/TensorRT-LLM that referenced this pull request Sep 24, 2025
dominicshanshan pushed a commit to dominicshanshan/TensorRT-LLM that referenced this pull request Sep 24, 2025
dominicshanshan pushed a commit to dominicshanshan/TensorRT-LLM that referenced this pull request Sep 25, 2025
chzblych pushed a commit that referenced this pull request Sep 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Cherry-pick It's a label that applies to Cherry-pick PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants