-
Notifications
You must be signed in to change notification settings - Fork 2k
[None][feat] Layer-wise benchmarks: support TEP balance, polish slurm scripts #10237
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?
Conversation
📝 WalkthroughWalkthroughThis 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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ 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: 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 -lreturns 1 for empty string, not 0.When
$matchesis empty,printf "%s\n" ""outputs a single newline, sowc -lreturns 1, not 0. Thecount -eq 0check will never be true. Consider checking if$matchesis 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.mockin production code (line 190-192) is unconventional. While it works for patchingselect_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 + 0is equivalent toctx_seq_len_q. The+ 0appears to representseq_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 prefillexamples/layer_wise_benchmarks/slurm_launch.sh (1)
17-23: Consider validatingNODESandNPbefore use.The script uses
NODESandNPin arithmetic and srun arguments without validation. If unset, line 19's arithmetic will fail with an obscure error underset -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 usingPath.stemandwith_suffixfor cleaner path manipulation.The current string slicing approach works but is less idiomatic than using
pathlibmethods.🔎 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-repis treated as the suffix bypathlib.
527-528: Static analysis: Jinja2 autoescape disabled.Ruff flags S701 because
autoescape=Falseby 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
TRTLLMGenFusedMoEreturns incorrecttoken_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_methodto 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=Trueto 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.layersand should match, explicit validation prevents subtle bugs if the code is refactored.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (14)
.gitignoreexamples/layer_wise_benchmarks/README.mdexamples/layer_wise_benchmarks/middleware/exclude_slurm_envsexamples/layer_wise_benchmarks/mpi_launch.shexamples/layer_wise_benchmarks/parse.pyexamples/layer_wise_benchmarks/run.pyexamples/layer_wise_benchmarks/run.shexamples/layer_wise_benchmarks/slurm_init_containers.shexamples/layer_wise_benchmarks/slurm_launch.shexamples/layer_wise_benchmarks/slurm_query_container_name.shexamples/layer_wise_benchmarks/template.htmltensorrt_llm/tools/layer_wise_benchmarks/mark_utils.pytensorrt_llm/tools/layer_wise_benchmarks/runner_utils.pytests/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.pytensorrt_llm/tools/layer_wise_benchmarks/mark_utils.pyexamples/layer_wise_benchmarks/parse.pytensorrt_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.pytensorrt_llm/tools/layer_wise_benchmarks/mark_utils.pyexamples/layer_wise_benchmarks/parse.pytensorrt_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:
.gitignoreexamples/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.shexamples/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.mdtensorrt_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 includeDeepseekv3MoE.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.forwardmethod, 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_PATHvia-xflag 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_PATHrelative to the current directory, enabling launches from different locations.- Uses
bash -o pipefailwithteeto capture output while preserving exit codes.- Properly passes positional parameters (
$1for script,$2for 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
Nonefallback for cache path.
181-227: Verify the hardcodedmoe_max_num_tokens=16384for prefill.The prefill runner uses hardcoded
moe_max_num_tokens=16384(line 201), while the main runner usesargs.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
numColsas a module-level variable, assigned duringprocessData(), correctly enables dynamic width calculation and consistent column handling.Also applies to: 336-336
424-428: LGTM!Good UX improvement: the
titleattribute 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_ROOTderived 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 underset -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-isolationto use system packages.- Performs editable install of the project.
21-23: Thesource+echopattern works correctly with the properties file. Thejenkins/current_image_tags.propertiesfile uses shell-compatible assignment syntax (VAR=value), explicitly designed for parsing bysh. The variable values contain only safe characters (URLs with colons, hyphens, dots), so the pattern reliably extractsLLM_DOCKER_IMAGEandLLM_SBSA_DOCKER_IMAGEas intended.examples/layer_wise_benchmarks/slurm_launch.sh (2)
6-7: LGTM! Clean approach for directory-independent execution.Using
realpathto computeTRTLLM_ROOTfrom 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 withset -u.examples/layer_wise_benchmarks/parse.py (6)
8-8: Appropriate import for stderr usage.Adding
sysimport 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, andparser.error()provides a user-friendly error message.
211-212: Verify SQL JOIN condition change is intentional.The JOIN now requires
unified.graphNodeId IS NOT NULLas 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 forrouter_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_PATHupfront prevents repeated autotuning and aligns with the.gitignoreupdate for the cache directory.
75-82: Clearer Slurm workflow withexport 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
--overlapand middleware explanations are helpful context.
156-160: Document new--file-pathoption.The examples demonstrate both the new
--file-pathoption and the existing--world-sizeapproach, 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
itertoolsimport enables comprehensive test coverage, andloggerimport 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_rankand distributing experts usingep_size. Note: The static analysis hint about unuseddp_sizeis 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_selectionandget_balanced_rank_imbalanced_expert_selectioncorrectly 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_oncecall 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_layersinstead of recomputingsum(layer_mask)improves code clarity without changing behavior.
557-559: The manual DP rank calculation is correct. No action needed—theMappingclass does not currently provide adp_rankproperty.
177-230: The state tracking mechanism is correct; no constructor initialization is needed.The
_routing_results_replaced_atattribute is intentionally managed on a per-forward-pass basis, not initialized in the MoE module constructor. Themake_forward_impl_checkwrapper (line 331) explicitly sets it toNoneat 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.
|
/bot run |
|
PR_Github #29621 [ run ] triggered by Bot. Commit: |
|
PR_Github #29621 [ run ] completed with state |
44f9ad6 to
ea21fe6
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #29708 [ run ] triggered by Bot. Commit: |
|
PR_Github #29708 [ run ] completed with state
|
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]>
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]>
Signed-off-by: Tailing Yuan <[email protected]>
Signed-off-by: Tailing Yuan <[email protected]>
ea21fe6 to
7228dd5
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #29762 [ run ] triggered by Bot. Commit: |
|
PR_Github #29762 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #29819 [ run ] triggered by Bot. Commit: |
|
PR_Github #29819 [ run ] completed with state |
Summary by CodeRabbit
Release Notes
New Features
Improvements
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.
Description
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 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.