Skip to content

Conversation

@yuantailing
Copy link
Member

@yuantailing yuantailing commented Dec 23, 2025

Summary by CodeRabbit

Release Notes

  • New Features

    • Added support for additional model architectures in benchmarking tools
    • Enhanced HTML reporting with improved formatting and column handling
  • Improvements

    • Streamlined benchmark workflow with consolidated configuration steps
    • Improved environment and container management for distributed runs
    • Added optional developer utilities for reduced startup times and enhanced profiling
  • Documentation

    • Updated benchmark documentation with revised command examples and environment setup instructions

✏️ Tip: You can customize this high-level summary in your review settings.

Description

  1. Support balanced expert selection for TEP
  2. Polish Slurm scripts
    1. Add interactive shell instructions to README
    2. Support to launch from a different dir
  3. Minor updates
    1. Use a standalone runner for prefilling
    2. Polish parser cmdline and HTML

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.

Details

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.

@yuantailing yuantailing requested a review from a team as a code owner December 23, 2025 11:22
@yuantailing yuantailing requested review from QiJune and kaiyux December 23, 2025 11:22
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 23, 2025

📝 Walkthrough

Walkthrough

This PR enhances the layer-wise benchmarks system with SLURM environment isolation, autotuner caching support, dynamic file path parsing, refactored MoE routing with explicit DP/EP parameters, prefill KV cache workflows, and HTML rendering improvements. No breaking public API changes.

Changes

Cohort / File(s) Summary
Configuration & Build
\.gitignore
Added ignore rule for /examples/layer_wise_benchmarks/autotuner_cache/ directory
Documentation
examples/layer_wise_benchmarks/README\.md
Added autotuner cache path export, consolidated benchmark run commands, removed balance-method NotModified usage, updated Slurm guidance (SLURM_JOB_ID export, container steps), added interactive shell subsection and Developer utilities section with startup/profiling tips, standardized variable usage and file-path references
Script Infrastructure
examples/layer_wise_benchmarks/{middleware/exclude_slurm_envs, mpi_launch.sh, slurm_*.sh, run.sh}
Created exclude_slurm_envs to filter SLURM/MPI environment variables; enhanced mpi_launch.sh with conditional TLLM_AUTOTUNER_CACHE_PATH propagation; refactored slurm_init_containers.sh to use TRTLLM_ROOT for path handling and simplified env var checks; tightened SLURM_JOB_ID validation in slurm_launch.sh; added upfront validation and error handling for container discovery in slurm_query_container_name.sh; modified run.sh to compute SCRIPT_PATH dynamically and use pipefail
Core Benchmark Scripts
examples/layer_wise_benchmarks/{parse.py, run.py}
parse.py: Added --file-path option with exclusive validation against --world-size, dynamic path resolution with nsys-rep validation, altered SQL JOIN condition for runtime capture, added router_gemm kernel mapping, redirected warnings to stderr, reworked header config generation with nested structures for batch/sequence parameters, improved HTML formatting. run.py: Added autotune integration, prefill KV cache workflow with synthetic setup and alltoall patching for GEN runs, simplified warmup loop via product iteration, added mock imports for testing
Routing & Marker Logic
tensorrt_llm/tools/layer_wise_benchmarks/{mark_utils.py, runner_utils.py}
mark_utils.py: Added Deepseekv3MoE import and nvtx annotation. runner_utils.py: Refactored routing signatures to use explicit dp_size, dp_rank, ep_size instead of world_size/rank; replaced static rank-based balancing with vectorized DP-aware calculations; introduced make_balanced_run_moe and make_forward_impl_check for TRTLLMGenFusedMoE support; added routing result tracking via _routing_results_replaced_at; enhanced replace_routing_method_ctx with new MoE module handling and restoration logic
UI & Templates
examples/layer_wise_benchmarks/template\.html
Changed numCols declaration from const to mutable variable for reuse; added formatted value titles to table cells when non-zero; set table minimum width dynamically based on column count; removed console.log statement; ensured total row/column calculations align with updated numCols
Tests
tests/unittest/tools/test_layer_wise_benchmarks\.py
Removed --balance-method=NotModified CLI argument from test_deepseek_r1_ctx_tep and test_qwen3_next_gen_tep invocations

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • chzblych
  • nv-guomingz
  • kaiyux

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description check ❓ Inconclusive The description covers all major areas: TEP balance support, Slurm script polish, and minor updates. However, Test Coverage section is empty, which is a required template section. Add test coverage details listing relevant tests safeguarding these changes, or explicitly state that existing tests cover the changes.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary changes: TEP balance support and Slurm script improvements, directly matching the changeset's major objectives.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • 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

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: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
examples/layer_wise_benchmarks/slurm_query_container_name.sh (1)

11-17: Bug: wc -l returns 1 for empty string, not 0.

When $matches is empty, printf "%s\n" "" outputs a single newline, so wc -l returns 1, not 0. The count -eq 0 check will never be true. Consider checking if $matches is empty directly.

🔎 Proposed fix
 prefix="pyxis_${SLURM_JOB_ID}_"
 matches=$(printf "%s\n" "$(srun -N 1 enroot list)" | grep "^${prefix}" || true)
-count=$(printf "%s\n" "$matches" | wc -l)

-if [ "$count" -eq 0 ]; then
+if [ -z "$matches" ]; then
     echo "Error: No container found" >&2
     exit 1
 fi

+count=$(printf "%s\n" "$matches" | wc -l)
+
 if [ "$count" -gt 1 ]; then
🧹 Nitpick comments (9)
examples/layer_wise_benchmarks/run.py (2)

5-5: Consider extracting mock to test utilities or documenting its production use.

Using unittest.mock in production code (line 190-192) is unconventional. While it works for patching select_alltoall_method_type, consider adding a brief comment explaining why mocking is preferred over a configuration parameter, or extracting this pattern to a utility function.


208-209: Simplify redundant assertion.

ctx_seq_len_q + 0 is equivalent to ctx_seq_len_q. The + 0 appears to represent seq_len_kv_cache=0, but this is implicit and could be clearer with a comment or removal.

🔎 Proposed simplification
     assert ctx_batch_size <= args.max_batch_size
-    assert ctx_seq_len_q + 0 <= args.max_seq_len
+    assert ctx_seq_len_q <= args.max_seq_len  # seq_len_kv_cache=0 for prefill
examples/layer_wise_benchmarks/slurm_launch.sh (1)

17-23: Consider validating NODES and NP before use.

The script uses NODES and NP in arithmetic and srun arguments without validation. If unset, line 19's arithmetic will fail with an obscure error under set -u.

🔎 Suggested validation
 if [ -z "${SLURM_JOB_ID:-}" ]; then
     echo "Please set SLURM_JOB_ID"
     exit 1
 fi
+
+if [ -z "${NODES:-}" ] || [ -z "${NP:-}" ]; then
+    echo "Please set NODES and NP"
+    exit 1
+fi
 
 WORKDIR=$(realpath "$(pwd)")
examples/layer_wise_benchmarks/parse.py (2)

102-108: Consider using Path.stem and with_suffix for cleaner path manipulation.

The current string slicing approach works but is less idiomatic than using pathlib methods.

🔎 Cleaner alternative using pathlib
-sqlite_file_path = nsys_rep_file_path.parent / (
-    nsys_rep_file_path.name[: -len(".nsys-rep")] + ".sqlite"
-)
-csv_file_path = nsys_rep_file_path.parent / (nsys_rep_file_path.name[: -len(".nsys-rep")] + ".csv")
-html_file_path = nsys_rep_file_path.parent / (
-    nsys_rep_file_path.name[: -len(".nsys-rep")] + ".html"
-)
+base_path = nsys_rep_file_path.with_suffix("")  # Removes .nsys-rep
+sqlite_file_path = base_path.with_suffix(".sqlite")
+csv_file_path = base_path.with_suffix(".csv")
+html_file_path = base_path.with_suffix(".html")

Note: This works because .nsys-rep is treated as the suffix by pathlib.


527-528: Static analysis: Jinja2 autoescape disabled.

Ruff flags S701 because autoescape=False by default. Since this generates local HTML reports (not served to browsers from untrusted input), the risk is low. However, enabling autoescape is a good defensive practice.

🔎 Optional: Enable autoescape
 loader = jinja2.FileSystemLoader(Path(__file__).parent)
-template = jinja2.Environment(loader=loader).get_template("template.html")
+template = jinja2.Environment(loader=loader, autoescape=True).get_template("template.html")
tensorrt_llm/tools/layer_wise_benchmarks/runner_utils.py (4)

59-103: Test coverage is thorough, consider extracting validation helpers.

The expanded test comprehensively validates balanced routing across DP/EP configurations. The nested validation logic is sound but dense.

💡 Optional: Extract validation helpers for readability

Consider extracting the four validation checks into helper functions:

  • validate_no_duplicate_experts(token_selected_experts, dp_rank)
  • validate_balanced_tokens_per_rank(token_selected_experts, experts_per_rank, dp_rank, ep_size)
  • validate_balanced_unique_tokens(token_selected_experts, experts_per_rank, dp_rank, ep_size)
  • validate_balanced_tokens_per_expert(tokens_per_expert)

This would improve maintainability and make test failures easier to diagnose.


238-326: Workaround for TRTLLMGenFusedMoE bug requires tracking.

The function correctly handles the TEP special case, but line 320 documents a workaround for a bug where TRTLLMGenFusedMoE returns incorrect token_final_scales.

Do you want me to open an issue to track this bug so the workaround can be removed once the underlying issue is fixed?

Based on the comment at line 320.


329-339: Improve assertion message for better debugging.

The guard correctly validates routing replacement, but the assertion message could be more descriptive.

🔍 More descriptive assertion message
-        assert moe_module._routing_results_replaced_at is not None, (
-            "Routing results are not replaced"
-        )
+        assert moe_module._routing_results_replaced_at is not None, (
+            f"Routing results were not replaced by any method. Expected replacement via "
+            f"make_balanced_routing_method or make_balanced_run_moe for balance_method={balance_method}"
+        )

Note: You'll need to pass balance_method to this function or capture it in the closure.


541-608: Well-structured context manager for routing replacement.

The refactored logic correctly handles multiple replacement points (routing_method.apply, run_moe, forward_impl) and safely restores originals in the finally block.

🔒 Add strict=True to zip() for safety

At line 601, add strict=True to catch length mismatches:

-            for layer, (apply_method_orig, run_moe_orig, forward_impl_orig) in zip(
-                self.layers, original_methods
-            ):
+            for layer, (apply_method_orig, run_moe_orig, forward_impl_orig) in zip(
+                self.layers, original_methods, strict=True
+            ):

While both lists are derived from self.layers and should match, explicit validation prevents subtle bugs if the code is refactored.

📜 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 871c6b4 and b083c3e.

📒 Files selected for processing (14)
  • .gitignore
  • examples/layer_wise_benchmarks/README.md
  • examples/layer_wise_benchmarks/middleware/exclude_slurm_envs
  • examples/layer_wise_benchmarks/mpi_launch.sh
  • examples/layer_wise_benchmarks/parse.py
  • examples/layer_wise_benchmarks/run.py
  • examples/layer_wise_benchmarks/run.sh
  • examples/layer_wise_benchmarks/slurm_init_containers.sh
  • examples/layer_wise_benchmarks/slurm_launch.sh
  • examples/layer_wise_benchmarks/slurm_query_container_name.sh
  • examples/layer_wise_benchmarks/template.html
  • tensorrt_llm/tools/layer_wise_benchmarks/mark_utils.py
  • tensorrt_llm/tools/layer_wise_benchmarks/runner_utils.py
  • tests/unittest/tools/test_layer_wise_benchmarks.py
💤 Files with no reviewable changes (1)
  • tests/unittest/tools/test_layer_wise_benchmarks.py
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.py: Code developed for TensorRT-LLM should conform to Python 3.8+
Indent Python code with 4 spaces. Do not use tabs
Always maintain the namespace when importing in Python, even if only one class or function from a module is used
Python files should use snake_case naming: some_file.py
Python classes should use PascalCase naming: class SomeClass
Python functions and methods should use snake_case naming: def my_awesome_function():
Python local variables should use snake_case naming: my_variable = ...
Python variable names that start with a number should be prefixed with 'k': k_99th_percentile = ...
Python global variables should use upper snake_case with prefix 'G': G_MY_GLOBAL = ...
Python constants should use upper snake_case naming: MY_CONSTANT = ...
Avoid shadowing variables declared in an outer scope in Python
Initialize all externally visible members of a Python class in the constructor
For Python interfaces that may be used outside a file, prefer docstrings over comments
Python comments should be reserved for code within a function, or interfaces that are local to a file
Use Google style docstrings in Python for classes and functions, which can be parsed by Sphinx
Python attributes and variables can be documented inline with type and description
Avoid using reflection in Python when functionality can be easily achieved without reflection
When using try-except blocks in Python, limit the except to the smallest set of errors possible
When using try-except blocks in Python to handle multiple possible variable types (duck-typing), keep the body of the try as small as possible, using the else block for logic

Files:

  • examples/layer_wise_benchmarks/run.py
  • tensorrt_llm/tools/layer_wise_benchmarks/mark_utils.py
  • examples/layer_wise_benchmarks/parse.py
  • tensorrt_llm/tools/layer_wise_benchmarks/runner_utils.py
**/*.{cpp,h,cu,cuh,py}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

All TensorRT-LLM Open Source Software code should contain an NVIDIA copyright header that includes the year of its latest meaningful modification

Files:

  • examples/layer_wise_benchmarks/run.py
  • tensorrt_llm/tools/layer_wise_benchmarks/mark_utils.py
  • examples/layer_wise_benchmarks/parse.py
  • tensorrt_llm/tools/layer_wise_benchmarks/runner_utils.py
🧠 Learnings (18)
📓 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.
📚 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:

  • .gitignore
  • examples/layer_wise_benchmarks/slurm_launch.sh
📚 Learning: 2025-08-01T15:14:45.673Z
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.

Applied to files:

  • .gitignore
📚 Learning: 2025-08-11T20:09:24.389Z
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.

Applied to files:

  • examples/layer_wise_benchmarks/slurm_launch.sh
  • examples/layer_wise_benchmarks/README.md
📚 Learning: 2025-11-27T09:23:18.742Z
Learnt from: fredricz-20070104
Repo: NVIDIA/TensorRT-LLM PR: 9511
File: tests/integration/defs/examples/serve/test_serve.py:136-186
Timestamp: 2025-11-27T09:23:18.742Z
Learning: In TensorRT-LLM testing, when adding test cases based on RCCA commands, the command format should be copied exactly as it appears in the RCCA case, even if it differs from existing tests. For example, some RCCA commands for trtllm-serve may omit the "serve" subcommand while others include it.

Applied to files:

  • examples/layer_wise_benchmarks/slurm_launch.sh
📚 Learning: 2025-08-14T06:36:40.701Z
Learnt from: timlee0212
Repo: NVIDIA/TensorRT-LLM PR: 6886
File: tensorrt_llm/_torch/models/modeling_deepseekv3.py:0-0
Timestamp: 2025-08-14T06:36:40.701Z
Learning: In DeepSeek V3 model (tensorrt_llm/_torch/models/modeling_deepseekv3.py), the disagreement between AllReduce.__init__ guard and _compute_mlp_tp_size logic for MNNVL usage is expected by design. The AllReduce component and MLP TP-size computation intentionally use different criteria for MNNVL availability decisions.

Applied to files:

  • examples/layer_wise_benchmarks/README.md
  • tensorrt_llm/tools/layer_wise_benchmarks/mark_utils.py
📚 Learning: 2025-08-20T07:43:36.447Z
Learnt from: ChristinaZ
Repo: NVIDIA/TensorRT-LLM PR: 7068
File: cpp/tensorrt_llm/kernels/moeTopKFuncs.cuh:169-172
Timestamp: 2025-08-20T07:43:36.447Z
Learning: In TensorRT-LLM MOE kernels, when processing up to 128 experts across 32 threads, each thread handles at most 4 experts (N < 5 constraint), where N represents candidates per thread rather than total system capacity.

Applied to files:

  • examples/layer_wise_benchmarks/README.md
📚 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:

  • examples/layer_wise_benchmarks/README.md
📚 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:

  • examples/layer_wise_benchmarks/README.md
📚 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:

  • examples/layer_wise_benchmarks/README.md
📚 Learning: 2025-08-21T02:39:12.009Z
Learnt from: djns99
Repo: NVIDIA/TensorRT-LLM PR: 7104
File: cpp/tensorrt_llm/kernels/cutlass_kernels/moe_gemm/moe_kernels.cu:1475-1480
Timestamp: 2025-08-21T02:39:12.009Z
Learning: The min latency mode functionality in TensorRT-LLM MOE kernels (cpp/tensorrt_llm/kernels/cutlass_kernels/moe_gemm/moe_kernels.cu) is deprecated and no longer being maintained/updated, as confirmed by djns99. Bug reports and optimization suggestions for the computeStridesTmaWarpSpecializedLowLatencyKernel and related min latency code paths should be deprioritized.

Applied to files:

  • tensorrt_llm/tools/layer_wise_benchmarks/mark_utils.py
📚 Learning: 2025-10-20T17:07:18.745Z
Learnt from: nvchenghaoz
Repo: NVIDIA/TensorRT-LLM PR: 8469
File: tensorrt_llm/_torch/auto_deploy/models/patches/nemotron_h.py:98-116
Timestamp: 2025-10-20T17:07:18.745Z
Learning: In NemotronH models (tensorrt_llm/_torch/auto_deploy/models/patches/nemotron_h.py), the gate (self.gate) returns topk_indices and topk_weights that are already in the correct shape to be passed directly to torch_ops.auto_deploy.torch_moe without needing to reshape them when hidden_states is flattened.

Applied to files:

  • tensorrt_llm/tools/layer_wise_benchmarks/mark_utils.py
📚 Learning: 2025-09-19T21:28:13.751Z
Learnt from: jhaotingc
Repo: NVIDIA/TensorRT-LLM PR: 7856
File: cpp/tensorrt_llm/thop/fp8BlockScaleMoe.cpp:159-166
Timestamp: 2025-09-19T21:28:13.751Z
Learning: In TensorRT-LLM blockScaleMoe routing (cpp/tensorrt_llm/kernels/trtllmGenKernels/blockScaleMoe/runner.cu), the DeepSeek routing method performs reinterpret_cast<float*>(routingLogits) at line 89, which could cause issues if routing_logits are BF16. However, Qwen3-FP8 models use RenormalizeNaive routing method and are not affected by this dtype casting issue.

Applied to files:

  • tensorrt_llm/tools/layer_wise_benchmarks/runner_utils.py
📚 Learning: 2025-08-26T06:07:02.166Z
Learnt from: shaharmor98
Repo: NVIDIA/TensorRT-LLM PR: 7231
File: tensorrt_llm/_torch/pyexecutor/_util.py:504-509
Timestamp: 2025-08-26T06:07:02.166Z
Learning: In tensorrt_llm/_torch/pyexecutor/_util.py, when calling model_engine.set_lora_model_config(), pass model_binding_config.mlp_hidden_size directly without multiplying by mapping.tp_size, as the mlp_hidden_size from get_bindings_model_config() is already the per-TP rank value needed for LoRA weight packaging.

Applied to files:

  • tensorrt_llm/tools/layer_wise_benchmarks/runner_utils.py
📚 Learning: 2025-09-23T14:58:05.372Z
Learnt from: nv-lschneider
Repo: NVIDIA/TensorRT-LLM PR: 7910
File: cpp/tensorrt_llm/kernels/nccl_device/config.cu:42-49
Timestamp: 2025-09-23T14:58:05.372Z
Learning: In TensorRT-LLM NCCL device kernels (cpp/tensorrt_llm/kernels/nccl_device/), the token partitioning intentionally uses ceil-like distribution (same token_per_rank for all ranks) to ensure all ranks launch the same number of blocks. This is required for optimal NCCL device API barrier performance, even though it may launch extra blocks for non-existent tokens on later ranks. Runtime bounds checking in the kernel (blockID validation) handles the overshoot cases.

Applied to files:

  • tensorrt_llm/tools/layer_wise_benchmarks/runner_utils.py
📚 Learning: 2025-08-21T00:16:56.457Z
Learnt from: farshadghodsian
Repo: NVIDIA/TensorRT-LLM PR: 7101
File: docs/source/blogs/tech_blog/blog9_Deploying_GPT_OSS_on_TRTLLM.md:36-36
Timestamp: 2025-08-21T00:16:56.457Z
Learning: TensorRT-LLM container release tags in documentation should only reference published NGC container images. The README badge version may be ahead of the actual published container versions.

Applied to files:

  • examples/layer_wise_benchmarks/slurm_init_containers.sh
📚 Learning: 2025-08-20T15:04:42.885Z
Learnt from: dbari
Repo: NVIDIA/TensorRT-LLM PR: 7095
File: docker/Dockerfile.multi:168-168
Timestamp: 2025-08-20T15:04:42.885Z
Learning: In docker/Dockerfile.multi, wildcard COPY for benchmarks (${CPP_BUILD_DIR}/benchmarks/*Benchmark) is intentionally used instead of directory copy because the benchmarks directory contains various other build artifacts during C++ builds, and only specific benchmark executables should be copied to the final image.

Applied to files:

  • examples/layer_wise_benchmarks/slurm_init_containers.sh
📚 Learning: 2025-08-18T09:08:07.687Z
Learnt from: tongyuantongyu
Repo: NVIDIA/TensorRT-LLM PR: 6984
File: cpp/tensorrt_llm/CMakeLists.txt:297-299
Timestamp: 2025-08-18T09:08:07.687Z
Learning: In the TensorRT-LLM project, artifacts are manually copied rather than installed via `cmake --install`, so INSTALL_RPATH properties are not needed - only BUILD_RPATH affects the final artifacts.

Applied to files:

  • examples/layer_wise_benchmarks/slurm_init_containers.sh
🧬 Code graph analysis (2)
tensorrt_llm/tools/layer_wise_benchmarks/mark_utils.py (1)
tensorrt_llm/_torch/models/modeling_deepseekv3.py (2)
  • DeepseekV3Gate (655-728)
  • Deepseekv3MoE (731-942)
tensorrt_llm/tools/layer_wise_benchmarks/runner_utils.py (4)
tensorrt_llm/mapping.py (1)
  • dp_size (238-239)
tensorrt_llm/llmapi/llm_args.py (1)
  • ep_size (389-393)
tensorrt_llm/tools/layer_wise_benchmarks/runner_interface.py (1)
  • BalanceMethod (10-14)
tensorrt_llm/logger.py (1)
  • warning_once (135-136)
🪛 markdownlint-cli2 (0.18.1)
examples/layer_wise_benchmarks/README.md

96-96: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

🪛 Ruff (0.14.10)
examples/layer_wise_benchmarks/parse.py

528-528: By default, jinja2 sets autoescape to False. Consider using autoescape=True or the select_autoescape function to mitigate XSS vulnerabilities.

(S701)

tensorrt_llm/tools/layer_wise_benchmarks/runner_utils.py

43-43: Unused function argument: dp_size

(ARG001)


77-77: Avoid specifying long messages outside the exception class

(TRY003)


85-85: Avoid specifying long messages outside the exception class

(TRY003)


95-97: Avoid specifying long messages outside the exception class

(TRY003)


102-102: Avoid specifying long messages outside the exception class

(TRY003)


132-134: Avoid specifying long messages outside the exception class

(TRY003)


601-603: zip() without an explicit strict= parameter

Add explicit value for parameter strict=

(B905)

🪛 Shellcheck (0.11.0)
examples/layer_wise_benchmarks/mpi_launch.sh

[warning] 6-6: Quote this to prevent word splitting.

(SC2046)

⏰ 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 (38)
tensorrt_llm/tools/layer_wise_benchmarks/mark_utils.py (2)

3-3: LGTM! Import correctly extends to include Deepseekv3MoE.

The import addition is correct and necessary for the nvtx annotation added at line 15. Both classes now imported from the same module align with the PR's objective to enhance MoE benchmarking support.


15-15: LGTM! nvtx annotation correctly added for MoE profiling.

The annotation follows the established pattern in this file and enables profiling of the Deepseekv3MoE.forward method, which aligns with the PR's layer-wise benchmarking objectives.

.gitignore (1)

79-79: LGTM!

The ignore rule for the autotuner cache directory is appropriately placed in the "Generated files" section and correctly uses an absolute path to avoid unintended matches.

examples/layer_wise_benchmarks/mpi_launch.sh (1)

8-11: LGTM!

The conditional propagation of TLLM_AUTOTUNER_CACHE_PATH via -x flag is correctly implemented using [ -v ... ] to check if the variable is set.

examples/layer_wise_benchmarks/run.sh (1)

43-48: LGTM!

The refactored invocation pattern correctly:

  • Computes SCRIPT_PATH relative to the current directory, enabling launches from different locations.
  • Uses bash -o pipefail with tee to capture output while preserving exit codes.
  • Properly passes positional parameters ($1 for script, $2 for profile dir, ${@:3} for remaining args).
examples/layer_wise_benchmarks/slurm_query_container_name.sh (1)

27-29: LGTM!

The output logic correctly extracts the suffix, prints the container name to stderr for user feedback, and outputs the suffix to stdout for programmatic use.

examples/layer_wise_benchmarks/run.py (3)

164-179: LGTM!

The autotune integration correctly:

  • Creates a run_pack for the maximum batch/sequence configuration.
  • Conditionally wraps execution in autotune() context when enabled.
  • Uses environment variable with None fallback for cache path.

181-227: Verify the hardcoded moe_max_num_tokens=16384 for prefill.

The prefill runner uses hardcoded moe_max_num_tokens=16384 (line 201), while the main runner uses args.moe_max_num_tokens. This could cause issues if the main runner expects a different value. Consider either using the same argument or documenting why a fixed value is appropriate for prefill.


230-256: LGTM!

The restructured warmup loop correctly iterates over all parameter combinations using itertools.product, including balance_ratio, and validates constraints before each run.

examples/layer_wise_benchmarks/template.html (3)

316-316: LGTM!

The introduction of numCols as a module-level variable, assigned during processData(), correctly enables dynamic width calculation and consistent column handling.

Also applies to: 336-336


424-428: LGTM!

Good UX improvement: the title attribute on data cells shows the formatted value on hover when non-zero, aiding readability for truncated or small values.


722-722: LGTM!

The dynamic min-width calculation (220 + 60 * numCols) correctly accounts for the fixed-width first column plus proportional space for data columns, ensuring the table scales appropriately with varying column counts.

examples/layer_wise_benchmarks/slurm_init_containers.sh (4)

7-8: LGTM!

Using TRTLLM_ROOT derived from the script's location ensures consistent path handling regardless of the working directory when the script is invoked.


10-13: LGTM!

The -z "${VAR:-}" pattern correctly checks for unset or empty variables while avoiding errors under set -u (nounset).

Also applies to: 17-17


53-56: LGTM!

The pip install sequence correctly:

  • Changes to the project root passed as $1.
  • Installs packaging first (required for build isolation).
  • Installs requirements with --no-build-isolation to use system packages.
  • Performs editable install of the project.

21-23: The source + echo pattern works correctly with the properties file. The jenkins/current_image_tags.properties file uses shell-compatible assignment syntax (VAR=value), explicitly designed for parsing by sh. The variable values contain only safe characters (URLs with colons, hyphens, dots), so the pattern reliably extracts LLM_DOCKER_IMAGE and LLM_SBSA_DOCKER_IMAGE as intended.

examples/layer_wise_benchmarks/slurm_launch.sh (2)

6-7: LGTM! Clean approach for directory-independent execution.

Using realpath to compute TRTLLM_ROOT from the script's location ensures the script works correctly when launched from any directory, which aligns with the PR objective.


9-12: Robust SLURM_JOB_ID check.

The -z "${SLURM_JOB_ID:-}" pattern correctly handles both unset and empty cases while being compatible with set -u.

examples/layer_wise_benchmarks/parse.py (6)

8-8: Appropriate import for stderr usage.

Adding sys import to enable writing warnings to stderr is correct.


18-33: Well-structured mutual exclusivity for CLI arguments.

The XOR logic (args.file_path is None) == (args.world_size is None) correctly ensures exactly one of the two options is provided, and parser.error() provides a user-friendly error message.


211-212: Verify SQL JOIN condition change is intentional.

The JOIN now requires unified.graphNodeId IS NOT NULL as part of the condition. This changes which rows participate in the runtime capture path—only graph-based kernels will be joined here.

Confirm this correctly separates graph-based kernel events from non-graph kernel events, ensuring the UNION properly partitions the data without missing or duplicating rows.


334-334: New kernel mapping for router_gemm.

The addition aligns with the TEP balance feature mentioned in the PR objectives.


398-401: Good practice: warnings to stderr, exceptions for strict mode.

Redirecting unknown kernel warnings to stderr keeps stdout clean for structured output while preserving the optional strict error mode.


530-535: Improved config text formatting.

The multi-line formatting with clear section headers enhances readability in the HTML output.

examples/layer_wise_benchmarks/README.md (5)

18-20: Good addition: Document autotuner cache configuration.

Setting TLLM_AUTOTUNER_CACHE_PATH upfront prevents repeated autotuning and aligns with the .gitignore update for the cache directory.


75-82: Clearer Slurm workflow with export SLURM_JOB_ID.

The updated instructions using export SLURM_JOB_ID=$(...) are more explicit than capturing and referencing separately.


96-110: Useful addition: Interactive shell instructions.

The optional interactive shell section provides clear guidance for developers who need to build C++ extensions or debug within the Slurm environment. The --overlap and middleware explanations are helpful context.


156-160: Document new --file-path option.

The examples demonstrate both the new --file-path option and the existing --world-size approach, which helps users understand the alternatives.


172-179: Helpful developer utilities section.

The tips for reducing startup time (disabling autotuner/profiling) and capturing additional debug info (GPU metrics, backtraces) are valuable for developers iterating on the benchmarks.

tensorrt_llm/tools/layer_wise_benchmarks/runner_utils.py (9)

3-3: LGTM: New imports are appropriately used.

The itertools import enables comprehensive test coverage, and logger import supports the warning in the TRTLLMGen routing path.

Also applies to: 27-27


42-53: LGTM: Distributed parallel parameters correctly integrated.

The function now properly handles data-parallel and expert-parallel routing by offsetting token IDs based on dp_rank and distributing experts using ep_size. Note: The static analysis hint about unused dp_size is a false positive—it's required for the cached version at line 56.


105-123: LGTM: Balance ratio calculation correctly accounts for data parallelism.

The minimum balanced tokens formula at line 116 properly ensures all experts are activated across the DP dimension.


127-147: LGTM: Selection functions consistently use DP/EP parameters.

Both get_all_to_one_selection and get_balanced_rank_imbalanced_expert_selection correctly incorporate the distributed parallel parameters and maintain consistency with the routing strategy.

Also applies to: 151-174


233-236: LGTM: Efficient cached helper for uniform routing scales.

The function appropriately caches uniform scale tensors for balanced routing scenarios where all top-k experts receive equal weight.


262-266: Helpful warning for execution path differences.

The warning_once call appropriately alerts users that specifying routing results in TEP cases leads to a different execution path, avoiding confusion during debugging.


643-643: LGTM: More explicit parameter passing.

Using num_layers instead of recomputing sum(layer_mask) improves code clarity without changing behavior.


557-559: The manual DP rank calculation is correct. No action needed—the Mapping class does not currently provide a dp_rank property.


177-230: The state tracking mechanism is correct; no constructor initialization is needed.

The _routing_results_replaced_at attribute is intentionally managed on a per-forward-pass basis, not initialized in the MoE module constructor. The make_forward_impl_check wrapper (line 331) explicitly sets it to None at the start of each forward pass and deletes it after completion (line 336). This pattern prevents state leakage between forward passes and ensures the assertion at line 189 finds the attribute in the expected initial state.

Likely an incorrect or invalid review comment.

@yuantailing
Copy link
Member Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #29621 [ run ] triggered by Bot. Commit: 590a64c

@tensorrt-cicd
Copy link
Collaborator

PR_Github #29621 [ run ] completed with state DISABLED
CI server is currently disabled for scheduled maintenance. Estimated completion time: 12 PM PST on 12/23.

@yuantailing yuantailing force-pushed the layer_wise_benchmarks branch from 44f9ad6 to ea21fe6 Compare December 24, 2025 03:12
@yuantailing
Copy link
Member Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #29708 [ run ] triggered by Bot. Commit: ea21fe6

@tensorrt-cicd
Copy link
Collaborator

PR_Github #29708 [ run ] completed with state SUCCESS. Commit: ea21fe6
/LLM/main/L0_MergeRequest_PR pipeline #22823 completed with status: 'FAILURE'

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Signed-off-by: Tailing Yuan <[email protected]>
Signed-off-by: Tailing Yuan <[email protected]>
Signed-off-by: Tailing Yuan <[email protected]>
Signed-off-by: Tailing Yuan <[email protected]>
Signed-off-by: Tailing Yuan <[email protected]>
Signed-off-by: Tailing Yuan <[email protected]>
Signed-off-by: Tailing Yuan <[email protected]>
Signed-off-by: Tailing Yuan <[email protected]>
@yuantailing yuantailing force-pushed the layer_wise_benchmarks branch from ea21fe6 to 7228dd5 Compare December 24, 2025 07:27
@yuantailing
Copy link
Member Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #29762 [ run ] triggered by Bot. Commit: 7228dd5

@tensorrt-cicd
Copy link
Collaborator

PR_Github #29762 [ run ] completed with state SUCCESS. Commit: 7228dd5
/LLM/main/L0_MergeRequest_PR pipeline #22871 completed with status: 'FAILURE'

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

@yuantailing
Copy link
Member Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #29819 [ run ] triggered by Bot. Commit: 7228dd5

@tensorrt-cicd
Copy link
Collaborator

PR_Github #29819 [ run ] completed with state SUCCESS. Commit: 7228dd5
/LLM/main/L0_MergeRequest_PR pipeline #22923 completed with status: 'SUCCESS'

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.

2 participants