Repository navigation
[None][feat] Add duration-based execution to benchmark #13385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+644
−11
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
abb477e
[None][feat] Add duration-based execution to benchmark
weikuo0506 00c7a53
[None][chore] Improve docstring coverage in asynchronous.py
weikuo0506 1d1ca51
[None][chore] Remove unused import in test_bench_async.py
weikuo0506 16c8c70
[None][fix] Allow partial request completion when duration is set in …
weikuo0506 a18ac06
[None][chore] Add informative log when duration limit is reached
weikuo0506 7446e94
[None][chore] Merge upstream/main into feat/duration-bench
weikuo0506 50c1888
[None][chore] Merge upstream/main into feat/duration-bench
weikuo0506 46d92f7
[None][chore] Fix pre-commit formatting and lint issues
weikuo0506 a151001
Merge branch 'main' into feat/duration-bench
weikuo0506 023495a
Merge branch 'main' into feat/duration-bench
weikuo0506 d43056f
Merge branch 'main' into feat/duration-bench
weikuo0506 2bb54c3
Merge branch 'main' into feat/duration-bench
weikuo0506 fc15032
[None][fix] Enforce benchmark duration at execution time
weikuo0506 acd262b
[None][test] Set concurrency=1 in test_async_benchmark_duration
weikuo0506 4a411b0
[None][test] Fix broken imports and assertions in test_bench_async
weikuo0506 52ba205
[None][test] Register test_bench_async in the CPU CI stages
weikuo0506 1192f23
Merge remote-tracking branch 'origin/main' into feat/duration-bench
weikuo0506 f8e0c31
[None][fix] Cancel in-flight requests when a benchmark request fails
weikuo0506 77eb354
[None][fix] Reject non-positive --duration values
weikuo0506 af78879
[None][fix] Stop draining in-flight requests once one fails
weikuo0506 6d74e9b
Merge remote-tracking branch 'origin/main' into feat/duration-bench
weikuo0506 eea4060
test: mark benchmark async tests as CPU-only
karljang f3c5a11
[None][fix] Require a concurrency limit when --duration is set
weikuo0506 28983fc
[None][fix] Drop multi-turn requests truncated by the duration limit
weikuo0506 ee8cf46
[None][test] Relax boundary assertions in the duration tests
weikuo0506 bcc4ab0
Merge remote-tracking branch 'origin/main' into feat/duration-bench
weikuo0506 f8f8b90
Merge remote-tracking branch 'origin/main' into feat/duration-bench
weikuo0506 69ac657
[None][chore] Document the reporting scope of --duration
weikuo0506 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2023-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import asyncio | ||
| import time | ||
| from unittest.mock import MagicMock | ||
|
|
||
| import pytest | ||
|
|
||
| from tensorrt_llm import SamplingParams | ||
| from tensorrt_llm._tensorrt_engine import LLM | ||
| from tensorrt_llm.bench.benchmark.utils.asynchronous import LlmManager | ||
| from tensorrt_llm.bench.dataclasses.general import InferenceRequest | ||
| from tensorrt_llm.executor.postproc_worker import PostprocParams | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_llm_manager_duration(): | ||
| # Mock LLM | ||
| mock_llm = MagicMock(spec=LLM) | ||
| mock_llm.args = MagicMock() | ||
| mock_llm.args.parallel_config = MagicMock() | ||
| mock_llm.args.parallel_config.world_size = 1 | ||
|
|
||
| # Mock generate_async to return a mock output | ||
| mock_output = MagicMock() | ||
| mock_output.prompt_token_ids = [1, 2, 3] | ||
| mock_output.outputs = [MagicMock(token_ids=[4, 5])] | ||
| mock_output.finished = True | ||
| mock_output.id = 1 | ||
| mock_output.decoding_iter = 1 | ||
|
|
||
| # We need to mock aresult() which is an async method | ||
| async def mock_aresult(): | ||
| await asyncio.sleep(0.6) # Make it take time | ||
| return mock_output | ||
|
|
||
| mock_output.aresult = mock_aresult | ||
| mock_llm.generate_async.return_value = mock_output | ||
|
|
||
| outbox = asyncio.Queue() | ||
|
|
||
| manager = LlmManager( | ||
| llm=mock_llm, | ||
| outbox=outbox, | ||
| streaming=False, | ||
| concurrency=1, | ||
| duration=1, # 1 second | ||
| ) | ||
|
|
||
| req = InferenceRequest(input_ids=[1, 2, 3], output_tokens=10) | ||
| sampling_params = SamplingParams() | ||
| post_proc_params = PostprocParams() | ||
|
|
||
| # Enqueue 3 requests. Each takes 0.6s. | ||
| # Total time if all processed: 1.8s. | ||
| # With duration=1, it should stop after processing 2 requests. | ||
| await manager.enqueue(req, sampling_params, post_proc_params) | ||
| await manager.enqueue(req, sampling_params, post_proc_params) | ||
| await manager.enqueue(req, sampling_params, post_proc_params) | ||
|
|
||
| manager.run() | ||
|
|
||
| # Wait for more than 1 second (e.g., 1.5s) | ||
| await asyncio.sleep(1.5) | ||
|
|
||
| # The worker should have stopped and cleared the inbox. | ||
| assert manager._inbox.empty() | ||
|
|
||
| # 2 requests should have been processed and put into outbox. | ||
| assert outbox.qsize() == 2 | ||
|
|
||
| await manager.stop() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.