-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[#9237][feat] enable iter stats in autodeploy #9278
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
[#9237][feat] enable iter stats in autodeploy #9278
Conversation
Signed-off-by: Shreyas Misra <[email protected]>
|
/bot run |
📝 WalkthroughWalkthroughThe changes add iteration-level performance statistics tracking to the AutoDeploy framework. New configuration fields enable per-iteration and per-request stats collection, a ReportingInfo dataclass encapsulates logging settings, and ADEngine is modified to track and store per-iteration metrics through counters and state dictionaries. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. 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: 1
🧹 Nitpick comments (2)
tests/unittest/_torch/auto_deploy/unit/singlegpu/test_ad_trtllm_bench.py (1)
43-47: Consider enhancing validation beyond non-empty check.The current test only verifies that
iteration_log.logis non-empty. For more robust coverage, consider validating:
- JSON structure (if the log is JSON-formatted per the PR description)
- Presence of expected fields (e.g.,
iter,iterLatencyMS,cpuMemUsage,gpuMemUsage)- Basic sanity checks on metric values
Would you like me to generate a more comprehensive validation that checks for the expected JSON schema mentioned in the PR description?
tensorrt_llm/_torch/auto_deploy/llm_args.py (1)
200-209: Consider adding validation for field dependency.The description for
enable_iter_req_statsstates thatenable_iter_perf_statsmust also be set totruefor request stats to work. However, there's no validation enforcing this constraint. Users could setenable_iter_req_stats=Truewhile leavingenable_iter_perf_stats=False, potentially causing confusion or silent failures.Add a
@model_validatorto enforce this dependency:@model_validator(mode="after") def validate_iter_stats_dependency(self): if self.enable_iter_req_stats and not self.enable_iter_perf_stats: raise ValueError( "enable_iter_req_stats requires enable_iter_perf_stats to be True. " "Please set enable_iter_perf_stats=True to enable per-request iteration statistics." ) return selfAlternatively, if the intent is to auto-enable
enable_iter_perf_statswhenenable_iter_req_statsis true, you could use:@model_validator(mode="after") def auto_enable_iter_perf_stats(self): if self.enable_iter_req_stats and not self.enable_iter_perf_stats: self.enable_iter_perf_stats = True ad_logger.info( "Auto-enabling enable_iter_perf_stats because enable_iter_req_stats is True." ) return self
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
tensorrt_llm/_torch/auto_deploy/llm_args.py(1 hunks)tensorrt_llm/_torch/auto_deploy/shim/ad_executor.py(9 hunks)tensorrt_llm/bench/benchmark/__init__.py(1 hunks)tests/unittest/_torch/auto_deploy/unit/singlegpu/test_ad_trtllm_bench.py(1 hunks)
🧰 Additional context used
🧠 Learnings (6)
📚 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/bench/benchmark/__init__.pytensorrt_llm/_torch/auto_deploy/llm_args.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'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.
Applied to files:
tensorrt_llm/bench/benchmark/__init__.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/_torch/auto_deploy/unit/singlegpu/test_ad_trtllm_bench.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/_torch/auto_deploy/unit/singlegpu/test_ad_trtllm_bench.py
📚 Learning: 2025-11-14T11:22:03.729Z
Learnt from: nzmora-nvidia
Repo: NVIDIA/TensorRT-LLM PR: 9163
File: tensorrt_llm/_torch/auto_deploy/custom_ops/quant.py:107-113
Timestamp: 2025-11-14T11:22:03.729Z
Learning: In TensorRT-LLM AutoDeploy custom ops, when adding hardware capability checks to select between kernel implementations (e.g., cuBLAS vs. CUDA kernel), use descriptive variable names that identify the specific GPU architectures or families being targeted (e.g., `is_blackwell_geforce_or_ada`) rather than generic names like `enable_cuda_core`. This makes it clear that the code is selecting an implementation path based on hardware capabilities, not enabling/disabling hardware features.
Applied to files:
tensorrt_llm/_torch/auto_deploy/llm_args.py
📚 Learning: 2025-08-19T12:45:11.997Z
Learnt from: amitz-nv
Repo: NVIDIA/TensorRT-LLM PR: 7033
File: tensorrt_llm/_torch/pyexecutor/model_engine.py:0-0
Timestamp: 2025-08-19T12:45:11.997Z
Learning: In tensorrt_llm/_torch/pyexecutor/model_engine.py, DoRA (Delta Orthogonal Rank Adaptation) functionality was removed from the PyTorch flow to eliminate issues with inverted DoRA detection logic. The original is_dora condition was checking if scaling_vec_pointer == 0, which was potentially incorrect.
Applied to files:
tensorrt_llm/_torch/auto_deploy/shim/ad_executor.py
🧬 Code graph analysis (3)
tests/unittest/_torch/auto_deploy/unit/singlegpu/test_ad_trtllm_bench.py (1)
examples/auto_deploy/build_and_run_ad.py (1)
main(264-309)
tensorrt_llm/_torch/auto_deploy/llm_args.py (1)
tensorrt_llm/llmapi/llm_args.py (1)
Field(63-90)
tensorrt_llm/_torch/auto_deploy/shim/ad_executor.py (1)
tensorrt_llm/_torch/attention_backend/interface.py (1)
num_ctx_tokens(270-271)
🪛 Ruff (0.14.5)
tensorrt_llm/_torch/auto_deploy/shim/ad_executor.py
155-155: Do not perform function call ReportingInfo in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
(B008)
⏰ 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 (5)
tensorrt_llm/_torch/auto_deploy/shim/ad_executor.py (3)
50-55: LGTM!The
ReportingInfodataclass is well-structured for encapsulating iteration logging configuration.Note: The static analysis warning about the mutable default at line 155 is a false positive—dataclasses with only immutable primitive fields are safe to use as default arguments.
215-295: LGTM — iter_states is actively consumed for metrics collection.Verification confirms that
self.iter_statespopulated in this method is read bypy_executor.py(lines 893, 1252, 1478) for inflight batching statistics. The iteration state tracking is correct and properly integrated with the metrics pipeline. The TODO at line 293 appropriately flags future work for extend and draft requests.
155-171: The review comment is based on an incorrect assumption about concurrent access.The code executes in a single-threaded manner from ADEngine's perspective. The worker thread (created once at line 358 via
start_worker()) runsevent_loop()sequentially, which is the only call site forforward(). All modifications toiter_counteranditer_statesoccur within this single thread context. PyExecutor only readsiter_statesfrom within the event loop itself (lines 589, 893, 1252, 1478), never from the main thread. Since all accesses happen in the same execution context, there is no concurrent access and therefore no race condition.Likely an incorrect or invalid review comment.
tensorrt_llm/bench/benchmark/__init__.py (1)
110-111: LGTM!Moving
enable_iter_perf_statsoutside the backend-specific block correctly enables iteration statistics across all backends wheniteration_logis configured. This aligns with the PR objective of supporting iteration stats in AutoDeploy.tests/unittest/_torch/auto_deploy/unit/singlegpu/test_ad_trtllm_bench.py (1)
34-35: LGTM!The addition of the
--iteration_logargument enables iteration statistics tracking in the benchmark test.
|
PR_Github #24943 [ run ] triggered by Bot. Commit: |
govind-ramnarayan
left a 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.
LGTM
|
PR_Github #24943 [ run ] completed with state |
|
/bot run |
|
PR_Github #25068 [ run ] triggered by Bot. Commit: |
|
PR_Github #25068 [ run ] completed with state |
Summary by CodeRabbit
Release Notes
New Features
Tests
Description
Closes #9237 Add config arguments to enable iteration perf and request stats. Outputs look like this -
{'cpuMemUsage': 0, 'gpuMemUsage': 84337360896, 'inflightBatchingStats': {'avgNumDecodedTokensPerIter': 0.0, 'microBatchId': 0, 'numContextRequests': 9, 'numCtxTokens': 8128, 'numGenRequests': 1, 'numPausedRequests': 0, 'numScheduledRequests': 10}, 'iter': 1005, 'iterLatencyMS': 20223.264455795288, 'kvCacheStats': {'allocNewBlocks': 352, 'allocTotalBlocks': 352, 'cacheHitRate': 0.0, 'freeNumBlocks': 61071, 'maxNumBlocks': 61359, 'missedBlocks': 0, 'reusedBlocks': 0, 'tokensPerBlock': 64, 'usedNumBlocks': 288}, 'maxBatchSizeRuntime': 0, 'maxBatchSizeStatic': 0, 'maxBatchSizeTunerRecommended': 0, 'maxNumActiveRequests': 384, 'maxNumTokensRuntime': 0, 'maxNumTokensStatic': 0, 'maxNumTokensTunerRecommended': 0, 'newActiveRequestsQueueLatencyMS': 33.22242760658264, 'numActiveRequests': 256, 'numCompletedRequests': 0, 'numNewActiveRequests': 255, 'numQueuedRequests': 0, 'pinnedMemUsage': 0, 'specDecodingStats': None, 'staticBatchingStats': {'emptyGenSlots': 0, 'numContextRequests': 0, 'numCtxTokens': 0, 'numGenTokens': 0, 'numScheduledRequests': 0}, 'timestamp': '11-18-2025 18:12:23.091437', 'requestStats': [{'allocNewBlocksPerRequest': 16, 'allocTotalBlocksPerRequest': 16, 'avgNumDecodedTokensPerIter': 1.0, 'contextPrefillPosition': 1000, 'disServingStats': None, 'id': 386, 'kvCacheHitRatePerRequest': 0.0, 'missedBlocksPerRequest': 0, 'numGeneratedTokens': 2, 'paused': False, 'reusedBlocksPerRequest': 0, 'scheduled': True, 'stage': 'GENERATION_IN_PROGRESS'}, {'allocNewBlocksPerRequest': 16, 'allocTotalBlocksPerRequest': 16, 'avgNumDecodedTokensPerIter': 1.0, 'contextPrefillPosition': 1000, 'disServingStats': None, 'id': 387, 'kvCacheHitRatePerRequest': 0.0, 'missedBlocksPerRequest': 0, 'numGeneratedTokens': 1, 'paused': False, 'reusedBlocksPerRequest': 0, 'scheduled': True, 'stage': 'GENERATION_IN_PROGRESS'},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
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.