-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[TRTLLM-7876][test] Test trtllm-serve with --extra_llm_api_options #7492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TRTLLM-7876][test] Test trtllm-serve with --extra_llm_api_options #7492
Conversation
14eb973 to
ade49e5
Compare
📝 WalkthroughWalkthroughAdds 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
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
|
/bot run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 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: Avoidassert False; raise an explicit exception.Using
assert Falsecan 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.
📒 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.ymltests/integration/test_lists/qa/llm_function_full.txttests/integration/defs/examples/serve/test_serve.pytests/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.pytests/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.pytests/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.pytests/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.txttests/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.
tests/integration/defs/examples/serve/test_configs/Qwen3-30B-A3B-FP8.yml
Show resolved
Hide resolved
|
PR_Github #17467 [ run ] triggered by Bot |
|
PR_Github #17467 [ run ] completed with state |
ade49e5 to
ad71830
Compare
|
/bot run --skip-test |
|
PR_Github #17493 [ run ] triggered by Bot |
|
PR_Github #17493 [ run ] completed with state |
ad71830 to
16d7878
Compare
|
/bot skip --comment "Local tested pass" |
|
Test results: H200 |
|
PR_Github #17589 [ skip ] triggered by Bot |
|
PR_Github #17589 [ skip ] completed with state |
…VIDIA#7492) Signed-off-by: Stanley Sun <190317771+StanleySun639@users.noreply.github.com>
@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 thestage-listparameter to access the appropriate container environment. Note: Does NOT update GitHub check status.For guidance on mapping tests to stage names, see
docs/source/reference/ci-overview.mdand the
scripts/test_to_stage_mapping.pyhelper.kill
killKill all running builds associated with pull request.
skip
skip --comment COMMENTSkip testing for latest commit on pull request.
--comment "Reason for skipping build/test"is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.reuse-pipeline
reuse-pipelineReuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.