Skip to content

Conversation

@NVShreyas
Copy link
Collaborator

@NVShreyas NVShreyas commented Nov 18, 2025

Summary by CodeRabbit

Release Notes

  • New Features

    • Added configuration options to enable iteration-level performance statistics and per-request statistics tracking during model inference.
    • Iteration performance tracking is now available across multiple backends.
  • Tests

    • Added verification of iteration log file generation in benchmarking 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 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.

@NVShreyas NVShreyas changed the title [#9237][feat]: enable iter stats in autodeploy [#9237]()[feat]: enable iter stats in autodeploy Nov 18, 2025
@NVShreyas NVShreyas changed the title [#9237]()[feat]: enable iter stats in autodeploy [#9237][feat]: enable iter stats in autodeploy Nov 18, 2025
@NVShreyas
Copy link
Collaborator Author

/bot run

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 18, 2025

📝 Walkthrough

Walkthrough

The 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

Cohort / File(s) Summary
Configuration & Reporting Infrastructure
tensorrt_llm/_torch/auto_deploy/llm_args.py, tensorrt_llm/_torch/auto_deploy/shim/ad_executor.py
Added two boolean config fields (enable_iter_perf_stats, enable_iter_req_stats) to AutoDeployConfig. Introduced ReportingInfo dataclass to encapsulate logging and iteration statistics flags; propagated from build_from_config to ADEngine constructor.
Engine Implementation
tensorrt_llm/_torch/auto_deploy/shim/ad_executor.py
Modified ADEngine.init to accept optional reporting_info parameter and initialize logging/stats flags. Added per-iteration state tracking via iter_counter and iter_states dict. Enhanced _prepare_inputs to track request and token counts per iteration, and incremented iter_counter in forward method.
Benchmark Integration
tensorrt_llm/bench/benchmark/__init__.py
Moved enable_iter_perf_stats flag initialization outside backend-specific branching to apply across all backends when iteration_log is configured.
Tests
tests/unittest/_torch/auto_deploy/unit/singlegpu/test_ad_trtllm_bench.py
Added --iteration_log iteration_log.log to benchmark command arguments and post-execution validation to assert iteration log file exists and contains content.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify field initialization: Ensure enable_iter_perf_stats and enable_iter_req_stats are correctly threaded from llm_args through ReportingInfo to ADEngine.init without missing assignments.
  • State tracking logic: Review counter accumulation in _prepare_inputs (num_ctx_requests, num_ctx_tokens, num_generation_tokens) and iter_counter increment timing in forward to ensure correct per-iteration aggregation.
  • Default parameter handling: Confirm ReportingInfo default construction and optional parameter in ADEngine.init don't introduce unexpected behavior when not provided.
  • Backend consistency: Verify benchmark/init.py change applies iteration_log correctly across all backends.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly references the GitHub issue #9237 and describes the main feature: enabling iteration statistics in autodeploy. It accurately summarizes the primary change.
Description check ✅ Passed The description includes the issue reference, example output, and a checked PR checklist. However, the 'Test Coverage' section is blank, and the 'Description' section explanation is minimal.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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: 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.log is 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_stats states that enable_iter_perf_stats must also be set to true for request stats to work. However, there's no validation enforcing this constraint. Users could set enable_iter_req_stats=True while leaving enable_iter_perf_stats=False, potentially causing confusion or silent failures.

Add a @model_validator to 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 self

Alternatively, if the intent is to auto-enable enable_iter_perf_stats when enable_iter_req_stats is 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

📥 Commits

Reviewing files that changed from the base of the PR and between 7c4344b and 25b5932.

📒 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__.py
  • tensorrt_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 ReportingInfo dataclass 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_states populated in this method is read by py_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()) runs event_loop() sequentially, which is the only call site for forward(). All modifications to iter_counter and iter_states occur within this single thread context. PyExecutor only reads iter_states from 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_stats outside the backend-specific block correctly enables iteration statistics across all backends when iteration_log is 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_log argument enables iteration statistics tracking in the benchmark test.

@tensorrt-cicd
Copy link
Collaborator

PR_Github #24943 [ run ] triggered by Bot. Commit: 25b5932

Copy link
Collaborator

@govind-ramnarayan govind-ramnarayan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tensorrt-cicd
Copy link
Collaborator

PR_Github #24943 [ run ] completed with state SUCCESS. Commit: 25b5932
/LLM/main/L0_MergeRequest_PR pipeline #18841 completed with status: 'FAILURE'

@NVShreyas
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #25068 [ run ] triggered by Bot. Commit: 25b5932

@tensorrt-cicd
Copy link
Collaborator

PR_Github #25068 [ run ] completed with state SUCCESS. Commit: 25b5932
/LLM/main/L0_MergeRequest_PR pipeline #18948 completed with status: 'SUCCESS'

@NVShreyas NVShreyas changed the title [#9237][feat]: enable iter stats in autodeploy [#9237][feat] enable iter stats in autodeploy Nov 19, 2025
@MartinMarciniszyn MartinMarciniszyn merged commit 1eae941 into NVIDIA:main Nov 19, 2025
8 of 17 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in AutoDeploy Board Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Feature]: AutoDeploy: support enable_iter_perf_stats

5 participants