Skip to content

[None][fix] Prevent hang in disagg gen-only benchmark when KV cache is insufficient - #12157

Closed
qiaoxj07 wants to merge 3 commits into
NVIDIA:mainfrom
qiaoxj07:fix/disagg-benchmark-kvcache-stall
Closed

[None][fix] Prevent hang in disagg gen-only benchmark when KV cache is insufficient#12157
qiaoxj07 wants to merge 3 commits into
NVIDIA:mainfrom
qiaoxj07:fix/disagg-benchmark-kvcache-stall

Conversation

@qiaoxj07

@qiaoxj07 qiaoxj07 commented Mar 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • In gen-only benchmark mode, the GEN server waits for benchmark_req_queues_size generation requests to be scheduled before starting the forward pass. If the KV cache cannot hold that many requests, the scheduled count plateaus and the wait loop hangs forever (sleeping 10s indefinitely).
  • Fix: track the scheduled gen count across iterations. After 10 consecutive iterations with no increase, lower benchmark_req_queues_size to the actual scheduled capacity and proceed with the forward pass.
  • Applies to both the attention-DP path (allgathered total_gen_count) and the non-attention-DP path (scheduled_batch.num_generation_requests).

Test plan

  • Run disagg gen-only benchmark with TLLM_BENCHMARK_REQ_QUEUES_SIZE set higher than available KV cache capacity and verify the server proceeds instead of hanging
  • Run disagg gen-only benchmark with sufficient KV cache and verify normal behavior is unchanged
  • Verify the warning log message appears when the target is lowered

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced runtime monitoring and automatic queue adjustment during overlapping execution to prevent saturation and maintain stable performance under high workloads.

…s insufficient

In gen-only benchmark mode, the GEN server waits for
benchmark_req_queues_size generation requests to be scheduled before
starting the forward pass. If the KV cache cannot hold that many
requests, the scheduled count plateaus and the loop hangs forever.

Detect KV cache saturation by tracking the scheduled gen count across
iterations. After 10 consecutive iterations with no increase, lower
benchmark_req_queues_size to the actual scheduled capacity and proceed.
This applies to both the attention-DP (allgathered total) and
non-attention-DP paths.

Signed-off-by: Xianjie <5410381+qiaoxj07@users.noreply.github.com>
@qiaoxj07
qiaoxj07 requested a review from a team as a code owner March 12, 2026 10:06
@qiaoxj07
qiaoxj07 requested a review from joyang-nv March 12, 2026 10:06
@coderabbitai

coderabbitai Bot commented Mar 12, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds KV-cache saturation detection to the executor loop with tracking variables (prev_gen_count, stall_count, max_stall_iterations) that identify consecutive iterations where scheduled generation count stagnates. Upon saturation detection, the benchmark_req_queues_size is dynamically lowered to the observed total_gen_count and forwarding is allowed. This logic is applied consistently across two codepaths in the _executor_loop_overlap method.

Changes

Cohort / File(s) Summary
KV-Cache Saturation Detection
tensorrt_llm/_torch/pyexecutor/py_executor.py
Adds saturation detection mechanism with tracking variables (prev_gen_count, stall_count, max_stall_iterations) to monitor consecutive iterations where scheduled generation count doesn't grow. When saturation is detected, dynamically lowers benchmark_req_queues_size and enables forwarding. Applied in two codepaths within _executor_loop_overlap method with warning logging.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the primary fix: preventing hangs in disagg gen-only benchmark when KV cache is insufficient, which matches the main change in the code.
Description check ✅ Passed The pull request description clearly explains the problem, solution, and test plan, matching the required template structure with Summary and Test Coverage sections.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

@qiaoxj07

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #38713 [ run ] triggered by Bot. Commit: f8960be Link to invocation

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.

Can we have a test to verify gen-only benchmarking? It seems like we've had a few issues not caught in pre-merge lately. Thanks.
@Tabrizian

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I only have a test case for R1, but I think It's too large to putinto pre-merge.
Is there any other solution?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Had a chat with @chienchunhung and he kindly agreed to add a test for this.

Comment thread tensorrt_llm/_torch/pyexecutor/py_executor.py Outdated
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #38713 [ run ] completed with state SUCCESS. Commit: f8960be
/LLM/main/L0_MergeRequest_PR pipeline #30031 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

Link to invocation

@schetlur-nv
schetlur-nv self-requested a review March 12, 2026 21:51
…stall helper

Deduplicate the KV cache saturation detection code that was repeated in
both the attention-DP and non-attention-DP branches of
_executor_loop_overlap. No behavior change.

Signed-off-by: Xianjie <5410381+qiaoxj07@users.noreply.github.com>
@qiaoxj07

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #38828 [ run ] triggered by Bot. Commit: 437bbec Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #38827 Bot args parsing error: usage: /bot [-h]
{run,kill,skip,submit,reviewers,reuse-pipeline,reuse-review} ...
/bot: error: unrecognized arguments: --disable-failfast

Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #38828 [ run ] completed with state SUCCESS. Commit: 437bbec
/LLM/main/L0_MergeRequest_PR pipeline #30139 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

Link to invocation

@qiaoxj07

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #38878 [ run ] triggered by Bot. Commit: 437bbec Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #38878 [ run ] completed with state SUCCESS. Commit: 437bbec
/LLM/main/L0_MergeRequest_PR pipeline #30187 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

Link to invocation

@qiaoxj07

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #38929 [ run ] triggered by Bot. Commit: 437bbec Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #38929 [ run ] completed with state DISABLED
CI server is currently disabled for scheduled maintenance. Estimated completion time: 9 PM PST on 3/14.

Link to invocation

@qiaoxj07

Copy link
Copy Markdown
Collaborator Author

Closed, another PR will fix this issue.
#12206

@qiaoxj07 qiaoxj07 closed this Mar 16, 2026
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