[None][feat] Add duration-based execution to benchmark - #13385
[None][feat] Add duration-based execution to benchmark#13385weikuo0506 wants to merge 22 commits into
Conversation
Signed-off-by: Kuo Wei <weikuo@google.com>
|
/bot run |
📝 WalkthroughWalkthroughThis PR adds an optional Changes
Sequence DiagramsequenceDiagram
actor CLI
participant async_benchmark
participant LlmManager
participant worker as Worker Loop
participant inbox as Inbox Queue
CLI->>async_benchmark: Call with duration=N seconds
async_benchmark->>LlmManager: Create with duration=N
Note over CLI,LlmManager: Execution Phase
activate worker
worker->>worker: Initialize start_time=None
loop For each request
inbox->>worker: Receive request
worker->>worker: Set start_time on first request
worker->>worker: Calculate elapsed = now() - start_time
alt elapsed < duration
worker->>worker: Process request
else elapsed >= duration
worker->>worker: Log duration reached
worker->>inbox: Drain remaining requests
worker->>worker: Break loop
end
end
deactivate worker
Note over worker: Shutdown Phase
alt stop event is set
worker->>worker: Cancel remaining tasks
else stop event not set
worker->>worker: Wait for in-flight tasks
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/unittest/llmapi/test_bench_async.py (1)
17-17: Remove unused import.The
timemodule is imported but never used in this file.🧹 Proposed fix
import asyncio -import time from unittest.mock import MagicMock🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/unittest/llmapi/test_bench_async.py` at line 17, Remove the unused top-level import "time" from tests/unittest/llmapi/test_bench_async.py; locate the import statement at the top of the file and delete the line "import time" so the file no longer imports an unused module.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tests/unittest/llmapi/test_bench_async.py`:
- Line 17: Remove the unused top-level import "time" from
tests/unittest/llmapi/test_bench_async.py; locate the import statement at the
top of the file and delete the line "import time" so the file no longer imports
an unused module.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 0a86d31f-8f27-450a-8a37-83b52e329f83
📒 Files selected for processing (5)
tensorrt_llm/bench/benchmark/__init__.pytensorrt_llm/bench/benchmark/low_latency.pytensorrt_llm/bench/benchmark/throughput.pytensorrt_llm/bench/benchmark/utils/asynchronous.pytests/unittest/llmapi/test_bench_async.py
Signed-off-by: Kuo Wei <weikuo@google.com>
|
/bot run |
|
@FrankD412 Can you help review this? |
Can do -- will handle it asap 🙂 |
Signed-off-by: Kuo Wei <weikuo@google.com>
…async_benchmark Signed-off-by: Kuo Wei <weikuo@google.com>
Signed-off-by: Kuo Wei <weikuo@google.com>
|
Hi @dc3671 , can you help to review? Thanks |
|
/bot run --disable-fail-fast |
|
PR_Github #53742 [ run ] triggered by Bot. Commit: |
|
PR_Github #53742 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #54496 [ run ] triggered by Bot. Commit: |
|
/bot kill |
|
@weikuo0506, |
|
PR_Github #54501 [ kill ] triggered by Bot. Commit: |
|
PR_Github #54496 [ run ] completed with state |
|
PR_Github #54501 [ kill ] completed with state |
Signed-off-by: Kuo Wei <weikuo@google.com>
|
@karljang @YihuiLu512 — pushed fixes for both of YihuiLu512's findings, plus a third defect that running the tests surfaced ( One change worth flagging: this test file was not in any test list, so CI has never collected it — that's how the defects survived. I registered it in |
# Conflicts: # tests/integration/test_lists/test-db/l0_cpu_x86.yml
YihuiLu512
left a comment
There was a problem hiding this comment.
LGTM
Please address the remaining corner cases as appropriate.
Draining in-flight requests instead of cancelling them is only correct when the duration limit is reached, where the point is to record their statistics. The check used self._stop, which is only set by an explicit shutdown, so a request failure took the drain path too: the worker waited for every outstanding request before surfacing the error, making a failing run slower than it was before duration support was added. Track the duration-triggered exit explicitly and cancel in every other case, restoring the original abort behaviour on failure while keeping the drain semantics on expiry. Add a regression test covering the failure path, which previously had no coverage. Signed-off-by: Kuo Wei <weikuo@google.com>
--duration accepted 0 and negative values. With 0 the deadline is already past once start_time is set for the first request, so every subsequent request is skipped and the benchmark produces almost no data while appearing to run normally. Constrain the option to positive integers so the mistake is reported at the command line instead. Leaving it unset still means no limit. Signed-off-by: Kuo Wei <weikuo@google.com>
|
Thanks @YihuiLu512 — both corner cases are pushed: the failure path now cancels in-flight requests (with a regression test), and On your earlier point about the test not being in the CI list, I corrected it rather than removing it and registered it in |
Draining on duration expiry waits for every in-flight request so their statistics are recorded. A failure during that wait was held back until the slowest sibling finished, so a hung request could delay the error indefinitely. Wait with FIRST_EXCEPTION instead and cancel the remainder as soon as a drained request raises. When every request succeeds the call still waits for all of them, leaving the duration-drain behaviour unchanged. Signed-off-by: Kuo Wei <weikuo@google.com>
# Conflicts: # tests/integration/test_lists/test-db/l0_cpu_arm.yml
|
Marked all conversations as resolved, since all approved the PR. |
|
/bot run |
|
|
|
PR_Github #62592 [ run ] triggered by Bot. Commit: |
|
PR_Github #62592 [ run ] completed with state
|
Signed-off-by: Kanghwan Jang <861393+karljang@users.noreply.github.com>
|
/bot run |
|
PR_Github #62615 [ run ] triggered by Bot. Commit: |
|
The default path is clean and I checked it carefully, since the Two things worth fixing before it lands: 1. A warning isn't enough for a flag whose entire purpose is bounding runtime on long ISL/OSL runs — that's precisely the scenario in your description. I'd make it a validation error when 2. The exact-count assertions will flake in pre-merge CI. Both list entries are The elapsed-time bounds elsewhere are generously slack and fine; it's the exact equalities on either side of the deadline that are the problem. Relaxing them to Minor, non-blocking: the timer starts when the first request coroutine runs, not when the benchmark starts, so enqueue time is excluded from "maximum run time"; a multi-turn request truncated mid-conversation is emitted as an ordinary completed perf item, which mixes partial and complete conversations in duration-mode stats; and the worker logs "finishing" twice on normal exit. Heads-up on a collision, not a review point: #16498 deletes both |
|
PR_Github #62615 [ run ] completed with state
|
fredricz-20070104
left a comment
There was a problem hiding this comment.
Review summary - Approve
Reviewed the full diff; no blocking or major issues found.
Minor, non-blocking notes:
tensorrt_llm/bench/benchmark/utils/asynchronous.py: --duration silently ineffective when concurrency is unbounded (common default)tests/unittest/llmapi/test_bench_async.py: Exact-count assertion is timing-sensitive
Automated review by NVCortex Lite, run by @fredricz-20070104.
Description
This PR adds a duration-based execution feature to the TensorRT-LLM Python benchmark suite (
trtllm-bench). Currently, benchmarks rely on a fixednum_requests, which can lead to excessively long run times for scenarios with high Input Sequence Length (ISL) and Output Sequence Length (OSL).The new
--durationoption (in seconds) allows users to limit the benchmark run time. The implementation uses a wall-clock check in the worker loop to stop pulling new requests after the duration has elapsed, while allowing in-flight requests to drain to ensure valid statistics.This affects both
throughputandlatencycommands as they share the same execution logic.Fixes #13487
Potential Impacts
Test Coverage
test_bench_async.pyto verifyLlmManagerduration logic using mocks.torch,pytest) in the host environment, but the test is designed to be run in the standard container.PR Checklist
[✓] PR description clearly explains what and why.
[✓] PR Follows TRT-LLM CODING GUIDELINES.
[✓] Test cases are provided for new code paths.