KEMBAR78
[None] [fix] Minor fixes to slurm and benchmark scripts by kaiyux · Pull Request #7453 · NVIDIA/TensorRT-LLM · GitHub
Skip to content

Conversation

@kaiyux
Copy link
Member

@kaiyux kaiyux commented Sep 1, 2025

Summary by CodeRabbit

  • New Features

    • Generated configs now include a build_config section with batch and token limits.
    • VisionArenaDataset now attaches multimodal content to requests and supports multimodal chat prompts.
  • Bug Fixes

    • RandomDataset sampling now cycles through the dataset to meet large request counts and correctly matches requested input lengths.
    • VisionArenaDataset applies oversampling to reliably reach the requested number of samples.

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

  • 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.

Signed-off-by: Kaiyu Xie <26294424+kaiyux@users.noreply.github.com>
@kaiyux kaiyux requested review from a team as code owners September 1, 2025 22:47
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 1, 2025

📝 Walkthrough

Walkthrough

Adds nested build_config sections to generated worker configs. Refactors sampling logic in RandomDataset to cycle through data and adjust prompt construction. Updates VisionArenaDataset to build multimodal SampleRequest objects with image-derived content and uses post-collection oversampling.

Changes

Cohort / File(s) Summary of changes
Config build_config nesting
examples/disaggregated/slurm/benchmark/gen_worker_config.py
Adds build_config dict under ctx_config and gen_config containing max_batch_size, max_num_tokens, max_seq_len, mirroring existing top-level values. YAML now includes these nested sections.
Benchmark dataset sampling refactor
tensorrt_llm/serve/scripts/benchmark_dataset.py
RandomDataset.sample: cycles dataset with modulo, reconstructs/truncates prompts per input_lens, removes assert on exact count, supports decode option. VisionArenaDataset.sample: constructs SampleRequest with multimodal data via parser/process_image, applies optional multimodal chat transform, then oversamples to num_requests.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Caller
  participant RandomDataset as RandomDataset.sample()
  participant Tokenizer
  Caller->>RandomDataset: sample(num_requests, input_lens, expected_output_lens, ...)
  loop for i in 0..num_requests-1
    RandomDataset->>RandomDataset: dataset_idx = i % dataset_len
    RandomDataset->>RandomDataset: fetch prompt, init_len, cached_ids
    alt init_len > input_lens[i]
      RandomDataset->>RandomDataset: use cached_ids[:input_lens[i]]
    else init_len <= input_lens[i]
      RandomDataset->>Tokenizer: measure prompt len (no special tokens)
      Tokenizer-->>RandomDataset: prompt_len
      RandomDataset->>RandomDataset: repeat/truncate to input_lens[i]
    end
    RandomDataset->>RandomDataset: build final prompt (prefix + input_ids)
    RandomDataset->>RandomDataset: append SampleRequest(total_len, prompt_len, expected_output_len[i])
  end
  RandomDataset-->>Caller: list[SampleRequest]
Loading
sequenceDiagram
  autonumber
  actor Caller
  participant VisionDataset as VisionArenaDataset.sample()
  participant Parser as parser_fn
  participant Img as process_image
  participant Tokenizer
  Caller->>VisionDataset: sample(num_requests, ...)
  loop iterate dataset items
    VisionDataset->>Parser: derive prompt from item
    Parser-->>VisionDataset: prompt
    VisionDataset->>Img: process_image(item.images[0])
    Img-->>VisionDataset: mm_content
    VisionDataset->>Tokenizer: tokenize(prompt) to get prompt_len
    Tokenizer-->>VisionDataset: prompt_len
    alt enable_multimodal_chat
      VisionDataset->>VisionDataset: apply_multimodal_chat_transformation
    end
    VisionDataset->>VisionDataset: SampleRequest(prompt, prompt_len, mm_content, ...)
    VisionDataset->>VisionDataset: sampled_requests.append(...)
  end
  VisionDataset->>VisionDataset: maybe_oversample_requests(...)
  VisionDataset-->>Caller: sampled_requests
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • pcastonguay
  • laikhtewari
  • qiaoxj07
  • Shixiaowei02
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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

Caution

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

⚠️ Outside diff range comments (7)
examples/disaggregated/slurm/benchmark/gen_worker_config.py (2)

25-49: Docstring args are stale/misleading. Update to match function signature.

Current params mention config_path/model_path/etc. This will confuse users and downstream tooling.

-    """
-    Generate configuration YAML file for disaggregated inference.
-
-    Args:
-        config_path: Path to save the config file
-        model_path: Path to the model
-        num_ctx_servers: Number of context servers
-        ctx_tp_size: Tensor parallel size for context servers
-        ctx_pp_size: Pipeline parallel size for context servers
-        ctx_batch_size: Batch size for context servers
-        ctx_max_num_tokens: Max number of tokens for context servers
-        ctx_max_seq_len: Max sequence length for context servers
-        ctx_free_gpu_memory_fraction: Free GPU memory fraction for context servers
-        ctx_enable_attention_dp: Enable attention DP for context servers
-        num_gen_servers: Number of generation servers
-        gen_tp_size: Tensor parallel size for generation servers
-        gen_pp_size: Pipeline parallel size for generation servers
-        gen_batch_size: Batch size for generation servers
-        gen_max_num_tokens: Max number of tokens for generation servers
-        gen_enable_attention_dp: Enable attention DP for generation servers
-        gen_gpu_memory_fraction: GPU memory fraction for generation servers
-        eplb_num_slots: Number of slots for eplb
-        worker_start_port: Start port for workers
-        server_port: Server port
-    """
+    """
+    Generate context/gen YAML configs for disaggregated inference.
+
+    Args:
+        work_dir: Directory to write ctx_config.yaml and gen_config.yaml.
+        ctx_tp_size: TP size for context workers.
+        ctx_pp_size: PP size for context workers.
+        ctx_batch_size: Max batch size for context workers.
+        ctx_max_num_tokens: Max tokens in a request (context).
+        ctx_max_seq_len: Max sequence length (context).
+        ctx_free_gpu_memory_fraction: Fraction of free GPU mem reserved (context).
+        ctx_enable_attention_dp: Whether to enable attention DP (context).
+        gen_tp_size: TP size for generation workers.
+        gen_pp_size: PP size for generation workers.
+        gen_batch_size: Max batch size for generation workers.
+        gen_max_num_tokens: Max tokens in a request (generation).
+        gen_max_seq_len: Max sequence length (generation).
+        gen_enable_attention_dp: Whether to enable attention DP (generation).
+        gen_gpu_memory_fraction: Fraction of GPU mem for KV cache (generation).
+        eplb_num_slots: MoE load balancer slots (0 to disable).
+        mtp_size: Num next-N predict layers for MTP speculative decoding.
+        cache_transceiver_max_num_tokens: Max tokens buffered by cache transceiver.
+    """

76-78: Deduplicate and sort gen CUDA graph batch sizes.

Current list appends gen_batch_size at the end, producing potential duplicates and non-monotonic order (e.g., ... 2048, 256). Some runtimes expect ascending unique sizes.

-    gen_cuda_graph_batch_sizes = [
-        1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 768, 1024, 2048, gen_batch_size
-    ]
+    gen_cuda_graph_batch_sizes = sorted({
+        1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 768, 1024, 2048, gen_batch_size
+    })
tensorrt_llm/serve/scripts/benchmark_dataset.py (5)

521-526: Ensure token counts exclude special tokens; avoid re-encoding loop.

Use tokenizer(..., add_special_tokens=False) for exact length control and to honor the repo learning about skip/add_special_tokens in randomized benchmarks.

-                    prompt = " ".join([prompt] * ratio)
-                    prompt_token_ids_for_truncation = tokenizer.encode(prompt)
-                    while len(prompt_token_ids_for_truncation) < input_lens[i]:
-                        prompt += " " + prompt
-                        prompt_token_ids_for_truncation = tokenizer.encode(
-                            prompt)
+                    prompt = " ".join([prompt] * ratio)
+                    prompt_token_ids_for_truncation = tokenizer(
+                        prompt, add_special_tokens=False).input_ids
+                    while len(prompt_token_ids_for_truncation) < input_lens[i]:
+                        prompt += " " + prompt
+                        prompt_token_ids_for_truncation = tokenizer(
+                            prompt, add_special_tokens=False).input_ids

Note: Based on retrieved learnings for this repo about using add_special_tokens=False/skip_special_tokens=True for length accuracy. [used_retrieved_learnings]


531-531: Decode without special tokens.

Prevents stray special tokens in text prompts.

-                if self.return_text:
-                    prompt = tokenizer.decode(prompt)
+                if self.return_text:
+                    prompt = tokenizer.decode(prompt, skip_special_tokens=True)

541-555: Guarantee num_requests via oversampling for consistency with other datasets.

RandomDataset no longer asserts size; oversample to meet contract.

-        return requests
+        self.maybe_oversample_requests(requests, num_requests)
+        return requests

1134-1151: Fix loop termination; ‘prompts’ is never populated here.

Condition uses len(prompts), so the cap is ineffective.

-        for item in self.data:
-            if len(prompts) >= num_requests:
+        for item in self.data:
+            if len(sampled_requests) >= num_requests:
                 break

1122-1124: Remove unreachable multimodal-chat block or drop the NotImplemented.

Currently you raise NotImplemented when enable_multimodal_chat is True, but also branch on it later. Pick one. Minimal fix: keep NotImplemented and remove the dead branch.

-        if enable_multimodal_chat:
-            raise NotImplementedError
+        if enable_multimodal_chat:
+            raise NotImplementedError
@@
-            if enable_multimodal_chat:
-                prompt = self.apply_multimodal_chat_transformation(
-                    prompt, mm_content)
+            # Multimodal chat not supported here (see NotImplemented above)

Alternatively, if you intend to support it now, remove the NotImplemented and compute prompt_len after transforming (using the model’s chat template).

Also applies to: 1141-1143

🧹 Nitpick comments (4)
examples/disaggregated/slurm/benchmark/gen_worker_config.py (3)

1-1: Add NVIDIA copyright header (2025).

Required by repo guidelines; prepend header at top of file.

+# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.

23-24: Align default cache_transceiver_max_num_tokens with CLI default (8448).

Function default is 4608 while argparse default is 8448. Divergence is a footgun for programmatic calls.

-                    cache_transceiver_max_num_tokens: int = 4608) -> None:
+                    cache_transceiver_max_num_tokens: int = 8448) -> None:

51-56: Keep duplicated max_ keys — both nested build_config and top-level are consumed.*

disagg path reads top-level max_batch_size/max_num_tokens (tensorrt_llm/llmapi/disagg_utils.py:186–192) while engine/runtime code uses build_config.* (tensorrt_llm/runtime/model_runner.py:201–206; tensorrt_llm/llmapi/llm.py:810–813).
Action: leave both in examples/disaggregated/slurm/benchmark/gen_worker_config.py, add a brief TODO comment explaining the duplication, and add tests that assert the disagg consumer and engine/runtime both accept the generated config.

tensorrt_llm/serve/scripts/benchmark_dataset.py (1)

1-5: Add NVIDIA copyright header (2025).

Required by repo guidelines.

+# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
 # Adopted from
 # https://github.com/vllm-project/vllm/blob/200bbf92e8861e2458a6f90bca73f40cc3b1ad1f/benchmarks/benchmark_dataset.py
 # https://github.com/sgl-project/sglang/blob/8321f8e45e07a8539935145d1c76373e457ddc89/python/sglang/bench_serving.py
 # SPDX-License-Identifier: Apache-2.0
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 14af1f0 and f962c91.

📒 Files selected for processing (2)
  • examples/disaggregated/slurm/benchmark/gen_worker_config.py (2 hunks)
  • tensorrt_llm/serve/scripts/benchmark_dataset.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

Filenames compiled into a target must be case-insensitively unique

Files:

  • examples/disaggregated/slurm/benchmark/gen_worker_config.py
  • tensorrt_llm/serve/scripts/benchmark_dataset.py
**/*.{h,hpp,hh,hxx,cc,cpp,cxx,cu,cuh,py}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

Use spaces, not tabs; indent 4 spaces

Files:

  • examples/disaggregated/slurm/benchmark/gen_worker_config.py
  • tensorrt_llm/serve/scripts/benchmark_dataset.py
**/*.py

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.py: Code must target Python 3.8+
Indent with 4 spaces; do not use tabs (Python)
Maintain module namespace on import: prefer from package.subpackage import foo; use foo.Symbol()
Python filenames use snake_case
Python class names use PascalCase
Python functions and methods use snake_case
Python local variables use snake_case; if starting with a number concept, prefix with k (e.g., k_99th_percentile)
Python global variables use G_ prefix with UPPER_SNAKE_CASE
Python constants use UPPER_SNAKE_CASE
Avoid shadowing variables from outer scopes
Initialize all externally visible class members in init
For public interfaces, prefer docstrings over comments; comments should be for in-function or file-local interfaces
Use Google-style docstrings for classes and functions (Sphinx-parsable)
Document attributes and variables inline with docstrings immediately after assignment
Avoid reflection when a non-reflective approach suffices
Limit except clauses to specific exceptions where possible
When using try/except for duck-typing, keep try body minimal and move logic to else

Files:

  • examples/disaggregated/slurm/benchmark/gen_worker_config.py
  • tensorrt_llm/serve/scripts/benchmark_dataset.py
**/*.{cpp,cc,cxx,h,hpp,hh,hxx,cu,cuh,py}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

Prepend NVIDIA copyright header (current year) to all source files

Files:

  • examples/disaggregated/slurm/benchmark/gen_worker_config.py
  • tensorrt_llm/serve/scripts/benchmark_dataset.py
🧠 Learnings (1)
📚 Learning: 2025-08-18T08:42:02.640Z
Learnt from: samuellees
PR: NVIDIA/TensorRT-LLM#6974
File: tensorrt_llm/serve/scripts/benchmark_dataset.py:558-566
Timestamp: 2025-08-18T08:42:02.640Z
Learning: In TensorRT-LLM's RandomDataset (tensorrt_llm/serve/scripts/benchmark_dataset.py), when using --random-token-ids option, sequence length accuracy is prioritized over semantic correctness for benchmarking purposes. The encode/decode operations should use skip_special_tokens=True and add_special_tokens=False to ensure exact target token lengths.

Applied to files:

  • tensorrt_llm/serve/scripts/benchmark_dataset.py
⏰ 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

@chzblych chzblych removed their request for review September 2, 2025 05:26
@kaiyux
Copy link
Member Author

kaiyux commented Sep 2, 2025

/bot skip --comment "slurm scripts and client benchmarking scripts are not protected by CI pipelines"

@kaiyux kaiyux enabled auto-merge (squash) September 2, 2025 05:34
@tensorrt-cicd
Copy link
Collaborator

PR_Github #17306 [ skip ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #17306 [ skip ] completed with state SUCCESS
Skipping testing for commit f962c91

@kaiyux kaiyux merged commit 935c2c1 into NVIDIA:release/1.1.0rc2 Sep 2, 2025
7 of 9 checks passed
kaiyux added a commit to kaiyux/TensorRT-LLM that referenced this pull request Sep 16, 2025
Signed-off-by: Kaiyu Xie <26294424+kaiyux@users.noreply.github.com>
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.

4 participants