[None][feat] Add duration-based execution to benchmark - #13385
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>
BowenFu
left a comment
There was a problem hiding this comment.
Re-verified on bcc4ab038. With --duration unset every new branch is inert (_duration_exceeded() false, drain_in_flight false, the multi-turn truncated early-return unreachable), and the rewritten worker() finally is equivalent to main's cancel-then-wait — the pending = set(self._tasks) snapshot additionally fixes main's race where _task_done_callback mutates that set while asyncio.wait iterates it.
Both points I raised earlier are addressed, and one better than I asked: --duration without a concurrency limit is now a hard click.UsageError raised before model load on both commands rather than a warning followed by a full-dataset run, so the flag can no longer be a silent no-op on trtllm-bench throughput.
Two things I'm explicitly not blocking on: the duration drain's final await asyncio.wait(pending) has no timeout, so in duration mode a single non-terminating request can hang the run; and requests dropped at the deadline are excluded from StatsKeeper.requests, so a truncated run reports throughput/latency over completed requests only, not the submitted dataset — worth a line in the --duration help text.
|
/bot run --disable-fail-fast |
|
PR_Github #62825 [ run ] triggered by Bot. Commit: |
|
PR_Github #62825 [ run ] completed with state
|
|
@weikuo0506, I regret to inform you that, as @BowenFu mentioned earlier, we’ve encountered conflicts. Could you kindly resolve them? |
# Conflicts: # tests/integration/test_lists/test-db/l0_cpu_x86.yml
Requests dropped at the deadline never reach StatsKeeper, so a duration-bounded run reports throughput and latency over the requests that completed rather than the dataset that was submitted. Say so in the help text, along with the concurrency requirement. Signed-off-by: Kuo Wei <weikuo@google.com>
Head branch was pushed to by a user without write access
|
@karljang Conflict resolved and pushed ( @BowenFu On your two non-blocking notes: I documented the reporting scope in the CI has now failed three times ( |
|
The last failure looks not relevant to this PR. I will retrigger the CI, thank you! |
|
/bot run --disable-fail-fast |
|
/bot run |
|
PR_Github #63055 [ run ] triggered by Bot. Commit: |
|
PR_Github #63056 [ run ] triggered by Bot. Commit: |
|
PR_Github #63055 [ run ] completed with state |
|
PR_Github #63056 [ run ] completed with state
|
|
/bot run |
|
PR_Github #63097 [ run ] triggered by Bot. Commit: |
|
PR_Github #63097 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #63112 [ run ] triggered by Bot. Commit: |
|
PR_Github #63112 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #63189 [ run ] triggered by Bot. Commit: |
|
PR_Github #63189 [ run ] completed with state |
|
@weikuo0506, it’s finally merged! Thank you for your contribution and efforts 👍 |
Signed-off-by: Kuo Wei <weikuo@google.com> Signed-off-by: Kanghwan Jang <861393+karljang@users.noreply.github.com> Co-authored-by: Kanghwan Jang <861393+karljang@users.noreply.github.com>
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.