Skip to content

[None][test] Cut the CI time of the layer-wise benchmark tests - #22929

Merged
kaiyux merged 1 commit into
NVIDIA:mainfrom
kaiyux:kaiyu/lwb-ci-time
Nov 27, 2026
Merged

kaiyux merged 1 commit into
NVIDIA:mainfrom
kaiyux:kaiyu/lwb-ci-time

Conversation

@kaiyux

@kaiyux kaiyux commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Dev Engineer Review

  • examples/layer_wise_benchmarks/run.py: With autotune enabled, the script now runs create_run_pack and run_pack() for every combination of batch size, query length, and KV-cache length. It uses autotune(..., skip_dynamic_tuning_buckets=True). This adds run packs and executions compared with the previous single pack. The non-autotune path creates and runs one pack with the maximum batch size and query length and the first KV-cache length. That behavior is unchanged.
  • examples/layer_wise_benchmarks/run.sh: The inner shell runs as env -u BASH_ENV bash. The added comment makes startup-time claims. The diff does not verify them. Confirm that the inherited environment provides all variables the image's startup file exported.
  • tests/integration/test_lists/test-db/l0_b200.yml: Four node IDs now share one list item, separated by spaces. The diff does not show how the test-db parser handles this format. Confirm that it splits into four selectors. test_performance_alignment[1] stays separate.
  • Performance: The CI time reduction is not verified by the diff. No timing results were supplied.

QA Engineer Review

  • Test-list file changed: tests/integration/test_lists/test-db/l0_b200.yml. The four unittest/tools/test_layer_wise_benchmarks.py cases now share one entry. Node IDs and waivers are unchanged. No test function changed.
  • Covered behavior: the autotune sweep and the profiled shell startup.
  • CI results: not available.
  • Verdict: needs follow-up. Confirm that the multi-ID line runs all four cases in CI.

Per-File QA Perspective

  • examples/layer_wise_benchmarks/run.py: Verify the autotune sweep over all shape combinations. Verify that the non-autotune path still runs one pack.
  • examples/layer_wise_benchmarks/run.sh: Verify that the benchmark runs with BASH_ENV unset and that the profiled command still writes its log.
  • tests/integration/test_lists/test-db/l0_b200.yml: Verify that the merged entry runs all four cases in CI.

Description

tests/unittest/tools/test_layer_wise_benchmarks.py runs four single-GPU cases in pre-merge l0_b200, one test-db entry each. On main they take about 762 s of B200 time per pipeline. That figure is the sum of the four entries' CI medians over 2026-11-23 to 11-26:

The three GEN medians come from about 200 runs each. Most of this time goes to setup rather than to the benchmark. This PR makes three changes and keeps every case:

  1. run.sh starts the profiled shell without BASH_ENV.
    • run.sh runs nsys profile ... bash -o pipefail -c 'python3 run.py ... | tee ...'.
    • CI and NGC-based images set BASH_ENV, so this bash first sources the image's shell init.
    • On hosts that are not GCP, the init checks for GCP by running cat on the vendor ID of every PCI device. That is 557 processes on a DGX B200.
    • Under nsys, each of those processes also loads the profiler's injection libraries, which takes about 94 ms. This one shell therefore takes 70-91 s to start.
    • In main's CI logs, every case shows this as the gap between the test calling run.sh and run.py's first log line.
    • Skipping the init loses nothing, because the environment run.sh passes down already carries what the init exports.
    • Later sh processes do not pay this cost: once the init has exported _CUDA_COMPAT_STATUS, the image's /bin/sh runs dash.
  2. run.py tunes only the benchmarked shapes.
    • run.py used to tune one forward pass of the largest shape with the bucket sweep of a serving warmup. That sweep profiles every token-count bucket up to the largest shape, up to 8192 tokens for the CTX case.
    • The timed runs look up only the buckets their own shapes map to, so the rest of that tuning went unused.
    • run.py now runs each benchmarked shape under the autotuner's existing skip_dynamic_tuning_buckets mode, which profiles exactly those buckets.
    • Cache hits are still taken first, for example from a TLLM_AUTOTUNER_CACHE_PATH written by an E2E run as in the README's alignment flow.
  3. One test-db entry for the four cases.
    • Every entry pays about 20 s for the outer wrapper and the inner pytest start, plus about 5 s for the module-scoped nsys check. One entry pays these costs once.
    • Later cases also reuse the kernels that earlier cases JIT-compiled.
    • test_performance_alignment[1] keeps its own entry, so its waive still matches.

The merged entry collects the four node IDs. It has no agg_unit_mem_df.csv row, so it runs serially as before. scripts/test_to_stage_mapping.py still maps each case to DGX_B200-PyTorch-1..9.

Test Coverage

  • tests/unittest/tools/test_layer_wise_benchmarks.py: the four [1] cases, now in one l0_b200.yml entry.

  • Pre-merge CI: the merged entry passed in two pipelines, in 287.9 s (L0 #72560) and 338.7 s (L0 #72770). The table gives inner pytest times per case. The main column holds main's CI medians over 2026-11-23 to 11-26.

    main, 4 entries this PR, L0 #72560 this PR, L0 #72770
    DeepSeek-R1 CTX 164 s 60.7 s 67.6 s
    Nemotron GEN 205 s 115.8 s 152.0 s
    Qwen3-Next GEN 142 s 38.6 s 41.7 s
    Kimi K3 GEN 171 s 51.3 s 59.1 s
    Outer wrapper and inner pytest start about 20 s × 4 21.5 s 18.2 s
    Total 762 s 287.9 s 338.7 s
    • This cuts the cost from 12.7 to 4.8-5.6 B200-minutes per pipeline (−56% to −62%).
    • The two runs differ mostly in Nemotron. Main's cases vary about as much from run to run: over 2026-11-24 to 11-27, the 10th-90th percentiles were 196-249 s for Nemotron, 134-171 s for Qwen3-Next and 163-209 s for Kimi K3. The 12 complete main runs that include [None][test] Enable nvMatmulHeuristics in long-running Blackwell and Rubin functional tests #22565 took 735-958 s.
    • Nemotron is now the largest case. Most of its remaining time is first-use JIT compilation, which the benchmark exercises:
      • the Triton SSD kernels during KV-cache prefill;
      • kernels during autotuning.
  • On a B200 node with the CI image, parse.py reports the same kernel sequence for every case as on main, and the per-iteration totals agree within 1.2%.

    • The one exception is Kimi K3's TRTLLM-gen MoE GEMMs. They take either about 1362 µs or 1813-1826 µs per iteration, depending on the autotuner's tactic, and main's CI history shows both values.

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)

  • If PR introduces API changes, an appropriate PR label is added - either api-compatible or api-breaking. For api-breaking, include BREAKING in the PR title.

  • 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

To see a list of available CI bot commands, please comment /bot help.

🤖 Generated with Claude Code

@kaiyux

kaiyux commented Nov 26, 2026

Copy link
Copy Markdown
Member Author

/bot run

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

With autotuning enabled, the layer-wise benchmark runner creates and executes a run pack for each batch-size, query-length, and KV-cache-length combination. Without autotuning, it creates one maximum-size pack. The launch script unsets BASH_ENV, and the integration test list combines four benchmark cases into one entry.

Changes

Layer-wise benchmarks

Layer / File(s) Summary
Autotuning and run-pack selection
examples/layer_wise_benchmarks/run.py
With autotuning enabled, the runner creates and executes a pack for each batch-size, query-length, and KV-cache-length combination, with skip_dynamic_tuning_buckets=True. Without autotuning, it creates one pack using the maximum batch size and query length and the first KV-cache length.
Benchmark launch and test grouping
examples/layer_wise_benchmarks/run.sh, tests/integration/test_lists/test-db/l0_b200.yml
The launch script adds comments about startup-file and profiler-injection overhead, then unsets BASH_ENV for its child shell. The test list combines four layer-wise benchmark cases into one entry.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Suggested reviewers: bowenfu

Merge Risk: Minimal · up to ee52b

This change speeds up the layer-wise benchmark CI test by tuning each benchmarked shape, unsetting BASH_ENV for the profiled shell, and merging four cases into one test-list entry. No concrete failure was identified in the reviewed code, so the merge risk is minimal.

Architecture risk: Low · up to ee52b

The change affects 2 systems.

Changed systems: examples, tests

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — examples (service) was modified; 2 changed files map to changed impact.
  • observed — tests (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in examples/layer_wise_benchmarks/run.sh: Comments describe the stated startup-file and profiler-injection overhead. The command now unsets BASH_ENV for the child shell; previously it invoked bash directly with the inherited environment.
  • observed — Modified behavior in tests/integration/test_lists/test-db/l0_b200.yml: The four layer-wise benchmark cases were combined into one test-list entry; previously each case had its own entry.
  • observed — Modified behavior in examples/layer_wise_benchmarks/run.py: When autotuning is enabled, setup now creates and executes a run pack for every combination of batch size, query length, and KV-cache length, and skips dynamic tuning buckets. Previously it tuned only one run pack using maximum batch size and query length and the first KV-cache length.
  • observed — Modified behavior in examples/layer_wise_benchmarks/run.py: The non-autotuner branch still creates the maximum-size run pack, using the first KV-cache length; its creation is now explicitly confined to this branch.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "[None][test] Cut the CI time of the layer-wise benchmark tests" matches the template format (ticket [None] and type [test]). It states the main goal of the PR. The changeset makes three cha…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description follows the repository template closely. It includes the Description, Test Coverage, and PR Checklist sections. It explains the problem with measured CI times, lists three concrete cha…
Full details: Title check

Explanation

The title "[None][test] Cut the CI time of the layer-wise benchmark tests" matches the template format (ticket [None] and type [test]). It states the main goal of the PR. The changeset makes three changes that all target CI time for the layer-wise benchmark tests: run.sh drops BASH_ENV, run.py tunes only benchmarked shapes, and the four test-db entries merge into one. The title does not name the mechanisms, but it describes the primary change accurately.

Full details: Description check

Explanation

The description follows the repository template closely. It includes the Description, Test Coverage, and PR Checklist sections. It explains the problem with measured CI times, lists three concrete changes (run.sh without BASH_ENV, run.py tuning only benchmarked shapes, and one merged test-db entry), and reports test evidence from two CI pipelines plus a kernel-sequence comparison on a B200 node. The title is not part of the provided description, so it is not assessed here. The checklist is ticked, but the items are generic and the PR does not state whether it changes any API, so the API label item is not addressed. These gaps are minor and do not block merge.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between d633111 and ee52bdb.

Files selected for processing: 1

  • examples/layer_wise_benchmarks/run.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #87351 [ run ] triggered by Bot. Commit: f38ed57 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #87351 [ run ] completed with state SUCCESS. Commit: f38ed57
/LLM/main/L0_MergeRequest_PR pipeline #72478 completed with status: 'FAILURE'

CI Report

⚠️ 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

CI Agent Failure Analysis

Link to invocation

@kaiyux

kaiyux commented Nov 26, 2026

Copy link
Copy Markdown
Member Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #87443 [ run ] triggered by Bot. Commit: f38ed57 Link to invocation

@kaiyux

kaiyux commented Nov 26, 2026

Copy link
Copy Markdown
Member Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #87448 [ run ] triggered by Bot. Commit: 92d187a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #87443 [ run ] completed with state ABORTED. Commit: f38ed57

Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #87448 [ run ] completed with state SUCCESS. Commit: 92d187a
/LLM/main/L0_MergeRequest_PR pipeline #72560 completed with status: 'FAILURE'

CI Report

⚠️ 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

CI Agent Failure Analysis

Link to invocation

The four single-GPU cases of test_layer_wise_benchmarks.py spent most of
their CI time outside the benchmark:

- run.sh starts its profiled shell under nsys. BASH_ENV makes that bash
  source the image's shell init, which forks one process per PCI device
  to detect GCP; under nsys each one loads the profiler's injection
  libraries, so the shell took over a minute to start. Start it without
  BASH_ENV: the environment it inherits already has what the init exports.
- run.py autotuned every token-count bucket up to the largest
  benchmarked shape. Tune the benchmarked shapes only, with the existing
  skip_dynamic_tuning_buckets mode; they look up the buckets they map to.
- l0_b200.yml ran each case as its own entry. Run the four as one entry
  so they share one inner pytest session and its nsys check.

Signed-off-by: Kaiyu Xie <26294424+kaiyux@users.noreply.github.com>
@kaiyux

kaiyux commented Nov 26, 2026

Copy link
Copy Markdown
Member Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #87522 [ run ] triggered by Bot. Commit: ee52bdb Link to invocation

@nv-guomingz nv-guomingz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@trtllm-agent trtllm-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed from the infra side. The grouped B200 entry keeps all four tests and leaves the waived alignment case separate. I found one input-validation issue in the new autotune loop.

Comment thread examples/layer_wise_benchmarks/run.py Resolved
@github-actions

Copy link
Copy Markdown

Automatically added "ci: full pre-merge approved" because this PR has satisfied the required GitHub review approvals. Unresolved review conversations and other required checks remain independent merge requirements.

@kaiyux

kaiyux commented Nov 27, 2026

Copy link
Copy Markdown
Member Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #87600 [ run ] triggered by Bot. Commit: d633111 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #87522 [ run ] completed with state ABORTED. Commit: ee52bdb

Link to invocation

@kaiyux

kaiyux commented Nov 27, 2026

Copy link
Copy Markdown
Member Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #87602 [ run ] triggered by Bot. Commit: ee52bdb Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #87600 [ run ] completed with state ABORTED. Commit: d633111

Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #87602 [ run ] completed with state SUCCESS. Commit: ee52bdb
/LLM/main/L0_MergeRequest_PR pipeline #72706 completed with status: 'FAILURE'

CI Report

⚠️ 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

CI Agent Failure Analysis

Link to invocation

@kaiyux

kaiyux commented Nov 27, 2026

Copy link
Copy Markdown
Member Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #87650 [ run ] triggered by Bot. Commit: ee52bdb Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #87650 [ run ] completed with state SUCCESS. Commit: ee52bdb
/LLM/main/L0_MergeRequest_PR pipeline #72749 completed with status: 'FAILURE'

CI Report

⚠️ 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

CI Agent Failure Analysis

Link to invocation

@kaiyux

kaiyux commented Nov 27, 2026

Copy link
Copy Markdown
Member Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #87671 [ run ] triggered by Bot. Commit: ee52bdb Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #87671 [ run ] completed with state SUCCESS. Commit: ee52bdb
/LLM/main/L0_MergeRequest_PR pipeline #72770 completed with status: 'SUCCESS'

CI Report

Link to invocation

@kaiyux
kaiyux added this pull request to the merge queue Nov 27, 2026
Merged via the queue into NVIDIA:main with commit ea82a42 Nov 27, 2026
34 checks passed
@kaiyux
kaiyux deleted the kaiyu/lwb-ci-time branch November 27, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants