KEMBAR78
[TRTLLM-7876][test] Test trtllm-serve with --extra_llm_api_options by StanleySun639 · Pull Request #7492 · NVIDIA/TensorRT-LLM · GitHub
Skip to content

Conversation

@StanleySun639
Copy link
Collaborator

@StanleySun639 StanleySun639 commented Sep 3, 2025

@coderabbitai summary

Description

The test case is using --extra_llm_api_options to enable torch compile. RCCA nvbugs#5340941.

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.

@StanleySun639 StanleySun639 force-pushed the user/stsun/add-trtllm-serve-tests branch from 14eb973 to ade49e5 Compare September 3, 2025 04:27
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 3, 2025

📝 Walkthrough

Walkthrough

Adds a new serve integration test and YAML config, updates test lists, and adjusts conftest utilities/fixtures. Introduces serve_test_root fixture, readiness and OpenAI chat verification helpers, and a test that launches trtllm-serve with extra_llm_api_options. Mostly style/formatting changes in conftest; parametrize_with_ids signature reformatted.

Changes

Cohort / File(s) Summary
Test fixtures and utilities
tests/integration/defs/conftest.py
Style-only edits (quotes, docstrings, formatting), minor conditional cleanup, standardized strings. Adds serve_test_root fixture. Refactors parametrize_with_ids to multi-line signature (no logic change). Updates marker string styles and option help strings.
Serve integration test
tests/integration/defs/examples/serve/test_serve.py
New test module: server readiness poller, OpenAI-compatible chat completion check, and test_extra_llm_api_options that launches trtllm-serve with a config and validates responses.
Serve test configuration
tests/integration/defs/examples/serve/test_configs/Qwen3-30B-A3B-FP8.yml
New YAML config for trtllm-serve: torch compile flags, server limits, KV cache fraction, logging.
Test list updates
tests/integration/test_lists/qa/llm_function_full.txt
Appends path to the new serve test to the LLM function full test list.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor T as PyTest (test_extra_llm_api_options)
  participant S as trtllm-serve
  participant H as /health endpoint
  participant A as OpenAI-compatible API
  participant M as Model runtime

  T->>S: Launch trtllm-serve with model + extra_llm_api_options
  loop Poll until ready or timeout
    T->>H: GET /health
    alt 200 OK
      H-->>T: Ready
    else Not ready
      H-->>T: Retry after sleep
    end
  end
  T->>A: chat.completions.create(system+user messages)
  A->>M: Generate completion
  M-->>A: Tokens/content
  A-->>T: choices[0].message.content
  T->>T: Assert structure and non-empty content
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • LinPoly
  • nv-guomingz
  • litaotju
  • Superjomn
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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

🧹 Nitpick comments (8)
tests/integration/defs/examples/serve/test_configs/Qwen3-30B-A3B-FP8.yml (1)

21-21: Add newline at EOF.

Minor formatting nit for consistency with repo style.

-print_iter_log: true
+print_iter_log: true
+
tests/integration/defs/conftest.py (4)

77-82: Docstring is inaccurate and missing closing punctuation; clarify default behavior.

Function now defaults to /scratch.trt_llm_data/llm-models and no longer asserts validity. Update the docstring and end the first line with a period.

-def llm_models_root() -> str:
-    """return LLM_MODELS_ROOT path if it is set in env, assert when it's set but not a valid path"""
+def llm_models_root() -> str:
+    """Return the LLM models root path.
+
+    If LLM_MODELS_ROOT is unset, defaults to '/scratch.trt_llm_data/llm-models'.
+    This function does not validate path existence.
+    """

149-151: Avoid assert False; raise an explicit exception.

Using assert False can be stripped with -O and obscures intent.

-                    assert (
-                        False
-                    ), f"{cached_dir} does not exist, and fail_if_path_is_invalid is True, please check the cache directory"
+                    raise AssertionError(
+                        f"{cached_dir} does not exist, and fail_if_path_is_invalid is True, please check the cache directory"
+                    )

2001-2009: Log fallback path for GPU memory detection.

When nvidia-smi and /proc/meminfo parsing fail, consider logging a warning before defaulting to 8192 MiB to aid debugging in CI.

-            except:
-                memory = 8192  # Default 8GB if all else fails
+            except Exception:
+                print_warning("Falling back to default GPU memory=8192 MiB; nvidia-smi and /proc/meminfo unavailable.")
+                memory = 8192  # Default 8GB if all else fails

2389-2395: Docstring punctuation and wording.

Add a period and fix wording.

-@pytest.fixture(scope="function")
-def serve_test_root(llm_root):
-    "Get servetest root"
+@pytest.fixture(scope="function")
+def serve_test_root(llm_root):
+    "Get serve test root."
tests/integration/defs/examples/serve/test_serve.py (3)

95-122: Consider using a free ephemeral port to avoid flakiness.

Hard-coding 8000 risks collisions in CI. Optional: pick a free port at runtime and pass it to both the server and checks.

+    # Optionally pick a free port to avoid collisions
+    # import socket
+    # with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
+    #     s.bind(("127.0.0.1", 0))
+    #     http_port = s.getsockname()[1]
+    http_port = "8000"
     cmd = [
         "trtllm-serve",
         "serve",
         model_path,
         "--host",
         "0.0.0.0",
         "--port",
-        "8000",
+        str(http_port),
         "--backend",
         "pytorch",
         "--extra_llm_api_options",
         config_file,
     ]
@@
-        check_server_ready()
+        check_server_ready(http_port=str(http_port))

126-131: Use os.path.basename to derive model id; safer across platforms.

Path splitting on “/” breaks on Windows.

-        model_name = model_path.split('/')[-1]  # "Qwen3-30B-A3B-FP8"
+        model_name = os.path.basename(model_path)  # "Qwen3-30B-A3B-FP8"

54-66: Optional: verify accepted model id before chatting.

Listing /v1/models and asserting the chosen model exists would make the test more robust.

-        # Make a chat completion request
+        # Optional: verify model is available
+        # models = client.models.list()
+        # assert any(m.id == model_name for m in models.data), f"Model {model_name} not found in server."
+        # Make a chat completion request
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9a4f606 and ade49e5.

📒 Files selected for processing (4)
  • tests/integration/defs/conftest.py (37 hunks)
  • tests/integration/defs/examples/serve/test_configs/Qwen3-30B-A3B-FP8.yml (1 hunks)
  • tests/integration/defs/examples/serve/test_serve.py (1 hunks)
  • tests/integration/test_lists/qa/llm_function_full.txt (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

Filenames compiled into a target must be case-insensitively unique

Files:

  • tests/integration/defs/examples/serve/test_configs/Qwen3-30B-A3B-FP8.yml
  • tests/integration/test_lists/qa/llm_function_full.txt
  • tests/integration/defs/examples/serve/test_serve.py
  • tests/integration/defs/conftest.py
**/*.{h,hpp,hh,hxx,cc,cpp,cxx,cu,cuh,py}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

Use spaces, not tabs; indent 4 spaces

Files:

  • tests/integration/defs/examples/serve/test_serve.py
  • tests/integration/defs/conftest.py
**/*.py

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.py: Code must target Python 3.8+
Indent with 4 spaces; do not use tabs (Python)
Maintain module namespace on import: prefer from package.subpackage import foo; use foo.Symbol()
Python filenames use snake_case
Python class names use PascalCase
Python functions and methods use snake_case
Python local variables use snake_case; if starting with a number concept, prefix with k (e.g., k_99th_percentile)
Python global variables use G_ prefix with UPPER_SNAKE_CASE
Python constants use UPPER_SNAKE_CASE
Avoid shadowing variables from outer scopes
Initialize all externally visible class members in init
For public interfaces, prefer docstrings over comments; comments should be for in-function or file-local interfaces
Use Google-style docstrings for classes and functions (Sphinx-parsable)
Document attributes and variables inline with docstrings immediately after assignment
Avoid reflection when a non-reflective approach suffices
Limit except clauses to specific exceptions where possible
When using try/except for duck-typing, keep try body minimal and move logic to else

Files:

  • tests/integration/defs/examples/serve/test_serve.py
  • tests/integration/defs/conftest.py
**/*.{cpp,cc,cxx,h,hpp,hh,hxx,cu,cuh,py}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

Prepend NVIDIA copyright header (current year) to all source files

Files:

  • tests/integration/defs/examples/serve/test_serve.py
  • tests/integration/defs/conftest.py
🧠 Learnings (1)
📚 Learning: 2025-07-28T17:06:08.621Z
Learnt from: moraxu
PR: NVIDIA/TensorRT-LLM#6303
File: tests/integration/test_lists/qa/examples_test_list.txt:494-494
Timestamp: 2025-07-28T17:06:08.621Z
Learning: In TensorRT-LLM testing, it's common to have both CLI flow tests (test_cli_flow.py) and PyTorch API tests (test_llm_api_pytorch.py) for the same model. These serve different purposes: CLI flow tests validate the traditional command-line workflow, while PyTorch API tests validate the newer LLM API backend. Both are legitimate and should coexist.

Applied to files:

  • tests/integration/test_lists/qa/llm_function_full.txt
  • tests/integration/defs/examples/serve/test_serve.py
🧬 Code graph analysis (2)
tests/integration/defs/examples/serve/test_serve.py (2)
tests/integration/defs/conftest.py (2)
  • llm_models_root (77-82)
  • serve_test_root (2390-2394)
tests/integration/defs/trt_test_alternative.py (1)
  • popen (195-214)
tests/integration/defs/conftest.py (1)
tests/integration/defs/triton_server/conftest.py (5)
  • models_root (285-289)
  • llm_models_root (24-33)
  • get_device_count (253-257)
  • skip_by_device_memory (261-269)
  • get_device_memory (272-281)
🪛 Ruff (0.12.2)
tests/integration/defs/conftest.py

788-788: First line should end with a period, question mark, or exclamation point

Add closing punctuation

(D415)


812-812: First line should end with a period, question mark, or exclamation point

Add closing punctuation

(D415)


1208-1208: First line should end with a period, question mark, or exclamation point

Add closing punctuation

(D415)


1845-1845: First line should end with a period, question mark, or exclamation point

Add closing punctuation

(D415)


1876-1876: First line should end with a period, question mark, or exclamation point

Add closing punctuation

(D415)


1966-1966: First line should end with a period, question mark, or exclamation point

Add closing punctuation

(D415)


2292-2292: First line should end with a period, question mark, or exclamation point

Add closing punctuation

(D415)


2392-2392: First line should end with a period, question mark, or exclamation point

Add closing punctuation

(D415)

⏰ 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 (2)
tests/integration/defs/conftest.py (1)

1812-1839: Parametrize helper LGTM.

Nice utility; auto-generated ids improve readability in reports.

tests/integration/defs/examples/serve/test_serve.py (1)

1-8: Add NVIDIA SPDX header and guard for missing OpenAI dependency.

Tests may fail with ModuleNotFoundError; skip cleanly if SDK isn’t installed. Also add the standard header.

+# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES.
+# SPDX-License-Identifier: Apache-2.0
+
 import os
 import time
 
 import requests
-from defs.conftest import llm_models_root, skip_pre_hopper
+import pytest
+from defs.conftest import llm_models_root, skip_pre_hopper
 from defs.trt_test_alternative import popen, print_error, print_info
-from openai import OpenAI
+try:
+    from openai import OpenAI
+except Exception:
+    pytest.skip("OpenAI Python SDK not installed; `pip install openai>=1.0`.", allow_module_level=True)
 from requests.exceptions import RequestException
⛔ Skipped due to learnings
Learnt from: EmmaQiaoCh
PR: NVIDIA/TensorRT-LLM#7370
File: tests/unittest/trt/model_api/test_model_quantization.py:24-27
Timestamp: 2025-08-29T14:07:45.863Z
Learning: In TensorRT-LLM's CI infrastructure, pytest skip markers (pytest.mark.skip) are properly honored even when test files have __main__ blocks that call test functions directly. The testing system correctly skips tests without requiring modifications to the __main__ block execution pattern.
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.

@tensorrt-cicd
Copy link
Collaborator

PR_Github #17467 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #17467 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #13128 completed with status: 'FAILURE'

@StanleySun639 StanleySun639 force-pushed the user/stsun/add-trtllm-serve-tests branch from ade49e5 to ad71830 Compare September 3, 2025 06:35
@StanleySun639
Copy link
Collaborator Author

/bot run --skip-test

@tensorrt-cicd
Copy link
Collaborator

PR_Github #17493 [ run ] triggered by Bot

@StanleySun639 StanleySun639 marked this pull request as draft September 3, 2025 11:00
@StanleySun639 StanleySun639 marked this pull request as ready for review September 3, 2025 13:37
@tensorrt-cicd
Copy link
Collaborator

PR_Github #17493 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #13145 (Partly Tested) completed with status: 'SUCCESS'

Signed-off-by: Stanley Sun <190317771+StanleySun639@users.noreply.github.com>
Signed-off-by: Stanley Sun <190317771+StanleySun639@users.noreply.github.com>
Signed-off-by: Stanley Sun <190317771+StanleySun639@users.noreply.github.com>
@StanleySun639 StanleySun639 force-pushed the user/stsun/add-trtllm-serve-tests branch from ad71830 to 16d7878 Compare September 4, 2025 01:51
@StanleySun639
Copy link
Collaborator Author

/bot skip --comment "Local tested pass"

@StanleySun639
Copy link
Collaborator Author

Test results: H200

@tensorrt-cicd
Copy link
Collaborator

PR_Github #17589 [ skip ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #17589 [ skip ] completed with state SUCCESS
Skipping testing for commit 16d7878

@StanleySun639 StanleySun639 enabled auto-merge (squash) September 4, 2025 02:24
@StanleySun639 StanleySun639 merged commit db8eb0a into NVIDIA:main Sep 4, 2025
5 checks passed
@StanleySun639 StanleySun639 deleted the user/stsun/add-trtllm-serve-tests branch September 4, 2025 02:34
greg-kwasniewski1 pushed a commit to nv-auto-deploy/TensorRT-LLM that referenced this pull request Sep 4, 2025
…VIDIA#7492)

Signed-off-by: Stanley Sun <190317771+StanleySun639@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.

3 participants