-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[TRTC-1921][feat] Add trtllm-configure CLI tool and scenario/profile schemas #9160
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
base: main
Are you sure you want to change the base?
[TRTC-1921][feat] Add trtllm-configure CLI tool and scenario/profile schemas #9160
Conversation
…schemas Signed-off-by: Anish Shanbhag <[email protected]>
Signed-off-by: Anish Shanbhag <[email protected]>
📝 WalkthroughWalkthroughIntroduces a new Changes
Sequence DiagramsequenceDiagram
actor User
User->>trtllm-configure: invoke CLI with subcommand args
rect rgb(240, 248, 255)
Note over TRTLLMConfigure: CLI Parsing Phase
trtllm-configure->>TRTLLMConfigure: parse_args() via Pydantic CliSubCommand
TRTLLMConfigure->>TRTLLMConfigure: determine active subcommand
end
rect rgb(240, 255, 240)
Note over TRTLLMConfigure: Config Retrieval Phase
TRTLLMConfigure->>Subcommand: get_config()
Subcommand-->>TRTLLMConfigure: return LlmArgs
end
rect rgb(255, 250, 240)
Note over TRTLLMConfigure: Output Generation Phase
TRTLLMConfigure->>TRTLLMConfigure: convert LlmArgs to dict
TRTLLMConfigure->>TRTLLMConfigure: dump to YAML
TRTLLMConfigure->>File: write YAML to output path
File-->>User: config.yaml created
end
TRTLLMConfigure-->>User: log success + suggested serve command
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (3)
tests/unittest/configure/test_configure.py (1)
10-38: Solid CLI-flow test; consider guarding againstexclude_defaultbrittlenessThis is a nice, focused test of the
TRTLLMConfigure.run()path: it covers subcommand wiring, YAML emission, and verifies a specific field from anLlmArgsconfig written to disk. This aligns well with the pattern of having explicit CLI-flow tests alongside API-level tests in this repo. Based on learningsOne small robustness concern:
run()usesconfig.model_dump(exclude_unset=True, exclude_default=True), so ifkv_cache_free_gpu_memory_fractionever has a default equal to0.9, that key will be omitted from the YAML and this test will fail even though the behavior is technically correct.You might want to:
- Use a value that is very unlikely to ever become the default (e.g.,
0.37), or- Explicitly confirm in a comment that the test intentionally relies on this field’s default being different from
0.9.Either keeps the assertion meaningful while reducing accidental breakage if LlmArgs defaults are tuned later.
tensorrt_llm/configure/profile.py (1)
9-33: Profile base design is reasonable; clarify multi-inheritance intent and stub behaviorThe profile abstraction looks sane:
BaseProfiledefines the contract, and the concrete profiles mix in both the profile base and their scenario types to get fields + behavior.A couple of design points worth making explicit:
InferenceMaxProfile(BaseProfile, BenchmarkScenario)andThroughputLatencySLAProfile(BaseProfile, ThroughputLatencySLAScenario)both inherit from Pydantic models (viaBaseProfileand the scenario classes). Python’s MRO will collapseBaseModelto a single base, but it’s worth double-checking Pydantic’s multiple-inheritance semantics for combined field definitions and validators. If any surprises show up, an alternative would be to haveBaseProfilebe a pureABC(noBaseModel) and rely on the scenario classes for the Pydantic modeling.- Both
get_config()implementations currently ignore scenario fields and just return a freshLlmArgs()with TODOs. If this CLI is meant to ship as a structural stub in this PR, that’s fine; otherwise, it may be worth documenting that current behavior is “default LlmArgs only” so users don’t over-interpret the “optimize” wording in the help.If you’d like, I can sketch a pattern for plugging in DB-backed/heuristic logic into
get_config()while keeping the signatures and tests stable.tensorrt_llm/configure/cli.py (1)
25-28: Consider using custom exception classes for validation errors (optional).Static analysis suggests avoiding long error messages directly in
ValueErrorraises (TRY003). While this is acceptable in Pydantic validators, you could optionally define custom exception classes for better error handling patterns.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
setup.py(1 hunks)tensorrt_llm/commands/configure.py(1 hunks)tensorrt_llm/configure/cli.py(1 hunks)tensorrt_llm/configure/profile.py(1 hunks)tensorrt_llm/configure/scenario.py(1 hunks)tests/unittest/configure/test_configure.py(1 hunks)
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: venkywonka
Repo: NVIDIA/TensorRT-LLM PR: 6029
File: .github/pull_request_template.md:45-53
Timestamp: 2025-08-27T17:50:13.264Z
Learning: For PR templates in TensorRT-LLM, avoid suggesting changes that would increase developer overhead, such as converting plain bullets to mandatory checkboxes. The team prefers guidance-style bullets that don't require explicit interaction to reduce friction in the PR creation process.
Learnt from: moraxu
Repo: NVIDIA/TensorRT-LLM PR: 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.
Learnt from: jiaganc
Repo: NVIDIA/TensorRT-LLM PR: 7031
File: tensorrt_llm/bench/dataclasses/configuration.py:90-104
Timestamp: 2025-08-26T09:37:10.463Z
Learning: In TensorRT-LLM, the `get_pytorch_perf_config()` method returns `self.pytorch_config` which can contain default `cuda_graph_config` values, so `llm_args` may already have this config before the extra options processing.
Learnt from: achartier
Repo: NVIDIA/TensorRT-LLM PR: 6763
File: tests/integration/defs/triton_server/conftest.py:16-22
Timestamp: 2025-08-11T20:09:24.389Z
Learning: In the TensorRT-LLM test infrastructure, the team prefers simple, direct solutions (like hard-coding directory traversal counts) over more complex but robust approaches when dealing with stable directory structures. They accept the maintenance cost of updating tests if the layout changes.
Learnt from: MatthiasKohl
Repo: NVIDIA/TensorRT-LLM PR: 6904
File: cpp/tensorrt_llm/pybind/thop/bindings.cpp:55-57
Timestamp: 2025-08-14T15:38:01.771Z
Learning: In TensorRT-LLM Python bindings, tensor parameter collections like mla_tensor_params and spec_decoding_tensor_params are kept as required parameters without defaults to maintain API consistency, even when it might affect backward compatibility.
Learnt from: fredricz-20070104
Repo: NVIDIA/TensorRT-LLM PR: 7645
File: tests/integration/test_lists/qa/llm_function_core.txt:648-648
Timestamp: 2025-09-09T09:40:45.658Z
Learning: In TensorRT-LLM test lists, it's common and intentional for the same test to appear in multiple test list files when they serve different purposes (e.g., llm_function_core.txt for comprehensive core functionality testing and llm_function_core_sanity.txt for quick sanity checks). This duplication allows tests to be run in different testing contexts.
Learnt from: yibinl-nvidia
Repo: NVIDIA/TensorRT-LLM PR: 6506
File: examples/models/core/mixtral/requirements.txt:3-3
Timestamp: 2025-08-01T15:14:45.673Z
Learning: In TensorRT-LLM, examples directory can have different dependency versions than the root requirements.txt file. Version conflicts between root and examples dependencies are acceptable because examples are designed to be standalone and self-contained.
Learnt from: jiaganc
Repo: NVIDIA/TensorRT-LLM PR: 7031
File: tensorrt_llm/bench/dataclasses/configuration.py:90-104
Timestamp: 2025-08-26T09:37:10.463Z
Learning: In TensorRT-LLM's bench configuration, the `get_pytorch_perf_config()` method returns `self.pytorch_config` which is a Dict[str, Any] that can contain default values including `cuda_graph_config`, making the fallback `llm_args["cuda_graph_config"]` safe to use.
Learnt from: pengbowang-nv
Repo: NVIDIA/TensorRT-LLM PR: 7192
File: tests/integration/test_lists/test-db/l0_dgx_b200.yml:56-72
Timestamp: 2025-08-26T09:49:04.956Z
Learning: In TensorRT-LLM test configuration files, the test scheduling system handles wildcard matching with special rules that prevent duplicate test execution even when the same tests appear in multiple yaml files with overlapping GPU wildcards (e.g., "*b200*" and "*gb200*").
Learnt from: ixlmar
Repo: NVIDIA/TensorRT-LLM PR: 8398
File: tensorrt_llm/_torch/pyexecutor/sampling_utils.py:237-272
Timestamp: 2025-10-17T13:21:31.724Z
Learning: The setup.py file in TensorRT-LLM explicitly requires Python 3.10+ via `python_requires=">=3.10, <4"`, making match/case statements and other Python 3.10+ features appropriate throughout the codebase.
Learnt from: nv-lschneider
Repo: NVIDIA/TensorRT-LLM PR: 7910
File: cpp/tensorrt_llm/thop/allreduceOp.cpp:352-446
Timestamp: 2025-09-23T15:12:38.312Z
Learning: In TensorRT-LLM NCCL device implementation, NCCL version 2.28+ requirements are handled at runtime in the nccl_device/config layer rather than with compile-time guards. This allows the allreduceOp to remain version-agnostic and delegates version compatibility validation to the appropriate lower-level components that can gracefully handle unsupported configurations.
📚 Learning: 2025-08-26T09:49:04.956Z
Learnt from: pengbowang-nv
Repo: NVIDIA/TensorRT-LLM PR: 7192
File: tests/integration/test_lists/test-db/l0_dgx_b200.yml:56-72
Timestamp: 2025-08-26T09:49:04.956Z
Learning: In TensorRT-LLM test configuration files, the test scheduling system handles wildcard matching with special rules that prevent duplicate test execution even when the same tests appear in multiple yaml files with overlapping GPU wildcards (e.g., "*b200*" and "*gb200*").
Applied to files:
tests/unittest/configure/test_configure.py
📚 Learning: 2025-07-28T17:06:08.621Z
Learnt from: moraxu
Repo: NVIDIA/TensorRT-LLM PR: 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/unittest/configure/test_configure.pytensorrt_llm/commands/configure.pytensorrt_llm/configure/cli.pysetup.py
📚 Learning: 2025-09-09T09:40:45.658Z
Learnt from: fredricz-20070104
Repo: NVIDIA/TensorRT-LLM PR: 7645
File: tests/integration/test_lists/qa/llm_function_core.txt:648-648
Timestamp: 2025-09-09T09:40:45.658Z
Learning: In TensorRT-LLM test lists, it's common and intentional for the same test to appear in multiple test list files when they serve different purposes (e.g., llm_function_core.txt for comprehensive core functionality testing and llm_function_core_sanity.txt for quick sanity checks). This duplication allows tests to be run in different testing contexts.
Applied to files:
tests/unittest/configure/test_configure.pytensorrt_llm/commands/configure.py
📚 Learning: 2025-08-06T13:58:07.506Z
Learnt from: galagam
Repo: NVIDIA/TensorRT-LLM PR: 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/configure/test_configure.pytensorrt_llm/commands/configure.py
📚 Learning: 2025-08-26T09:37:10.463Z
Learnt from: jiaganc
Repo: NVIDIA/TensorRT-LLM PR: 7031
File: tensorrt_llm/bench/dataclasses/configuration.py:90-104
Timestamp: 2025-08-26T09:37:10.463Z
Learning: In TensorRT-LLM, the `get_pytorch_perf_config()` method returns `self.pytorch_config` which can contain default `cuda_graph_config` values, so `llm_args` may already have this config before the extra options processing.
Applied to files:
tensorrt_llm/commands/configure.py
📚 Learning: 2025-10-17T13:21:31.724Z
Learnt from: ixlmar
Repo: NVIDIA/TensorRT-LLM PR: 8398
File: tensorrt_llm/_torch/pyexecutor/sampling_utils.py:237-272
Timestamp: 2025-10-17T13:21:31.724Z
Learning: The setup.py file in TensorRT-LLM explicitly requires Python 3.10+ via `python_requires=">=3.10, <4"`, making match/case statements and other Python 3.10+ features appropriate throughout the codebase.
Applied to files:
setup.py
🧬 Code graph analysis (5)
tests/unittest/configure/test_configure.py (2)
tensorrt_llm/configure/cli.py (3)
InferenceMaxSubCommand(32-33)TRTLLMConfigure(43-84)run(65-84)tensorrt_llm/_torch/auto_deploy/llm_args.py (1)
LlmArgs(302-411)
tensorrt_llm/configure/profile.py (2)
tensorrt_llm/configure/scenario.py (2)
BenchmarkScenario(32-49)ThroughputLatencySLAScenario(52-75)tensorrt_llm/_torch/auto_deploy/llm_args.py (1)
LlmArgs(302-411)
tensorrt_llm/commands/configure.py (1)
tensorrt_llm/configure/cli.py (3)
TRTLLMConfigure(43-84)main(87-88)run(65-84)
tensorrt_llm/configure/cli.py (1)
tensorrt_llm/configure/profile.py (5)
InferenceMaxProfile(22-26)ThroughputLatencySLAProfile(29-33)get_config(19-19)get_config(24-26)get_config(31-33)
tensorrt_llm/configure/scenario.py (1)
tensorrt_llm/llmapi/llm_args.py (1)
Field(63-90)
🪛 Ruff (0.14.4)
tensorrt_llm/configure/cli.py
26-26: Avoid specifying long messages outside the exception class
(TRY003)
28-28: Avoid specifying long messages outside the exception class
(TRY003)
47-47: Unused noqa directive (non-enabled: D205)
Remove unused noqa directive
(RUF100)
tensorrt_llm/configure/scenario.py
72-74: Avoid specifying long messages outside the exception class
(TRY003)
🔇 Additional comments (6)
setup.py (1)
280-288: Console script wiring fortrtllm-configurelooks consistentThe new
trtllm-configure=tensorrt_llm.commands.configure:mainentry aligns with the existingtrtllm-*console scripts and correctly targets the new command module.tensorrt_llm/commands/configure.py (1)
1-9: Thin command shim fortrtllm-configureis appropriateThis module cleanly delegates to
TRTLLMConfigure().run()and provides a standardmain()plus__main__guard, matching the existingtensorrt_llm.commands.*pattern.tensorrt_llm/configure/cli.py (4)
32-40: LGTM!The subcommand class structure is well-designed. The multiple inheritance pattern (profile + common options) provides a clean separation between business logic and CLI configuration.
72-73: LGTM!Good use of
exclude_unset=Trueandexclude_default=Trueto produce a clean, minimal config file containing only explicitly set values. The use ofyaml.safe_dumpis the secure choice for YAML serialization.
87-92: LGTM!The
main()function and__main__guard follow standard Python conventions. This enables both direct execution of the module and import/invocation from the console script entry point defined insetup.py.
84-84: Themodelfield is correctly accessible and no issues exist.The
modelfield is defined inBaseScenario(scenario.py:27) and is properly inherited through the full class hierarchy:
InferenceMaxSubCommand→InferenceMaxProfile→BenchmarkScenario→BaseScenario✓ hasmodelThroughputLatencySLASubCommand→ThroughputLatencySLAProfile→ThroughputLatencySLAScenario→BaseScenario✓ hasmodelBoth subcommand types have full access to the
modelfield through Pydantic's inheritance mechanism.
Signed-off-by: Anish Shanbhag <[email protected]>
|
/bot run |
|
PR_Github #24528 [ run ] triggered by Bot. Commit: |
| if self.output.suffix != ".yaml": | ||
| raise ValueError(f"Output file must be a YAML file. Got '{self.output}'.") | ||
| if self.output.exists(): | ||
| raise ValueError(f"Output file '{self.output}' already exists.") |
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.
if there's an easy way to parametrize and expose a --force-overwrite or something, it would help in avoiding a potential user gripe of having to explicitly delete the file everytime - but P1 feel free to ignore
|
PR_Github #24528 [ run ] completed with state |
| config = subcommand.get_config() | ||
|
|
||
| # exclude_unset and exclude_default are explicitly used to avoid including default values | ||
| config_dict = config.model_dump(exclude_unset=True, exclude_default=True) |
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.
nit: do we want to exclude unset and default? I can think of a scenario where the defaults change in newer versions and suddenly you get perf changes on the same config, compared to when you ran it on the version where it was originally generated. However, being overly explicit also has it's problems, so I'm not sure what's the best option here. What do you think?
| tps_per_gpu: PositiveFloat = Field( | ||
| description="Target throughput per GPU in tokens per second", | ||
| validation_alias=AliasChoices("tps_per_gpu", "target_tps_per_gpu", "min_tps_per_gpu"), | ||
| ) |
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.
nit: shouldn't all be optional and at least one specified? for example, low concurrency workloads with a fixed amount of gpus where a user is only interested in TTFT and ITL
Description
Adds the initial version of the
trtllm-configureCLI tool. Also defines the schemas forProfile/Scenario.Summary by CodeRabbit
Release Notes
trtllm-configurecommand-line utility for generating LLM configuration filesTest Coverage
PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...Provide a user friendly way for developers to interact with a Jenkins server.
Run
/bot [-h|--help]to print this help message.See details below for each supported subcommand.
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.