-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[None][feat] Dev scaffolding bench load_generator #8559
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
base: main
Are you sure you want to change the base?
[None][feat] Dev scaffolding bench load_generator #8559
Conversation
📝 WalkthroughWalkthroughThe changes introduce a load generation strategy framework for TensorRT-LLM benchmarking, replacing simple concurrency controls with multiple configurable strategies (synchronous, concurrent, throughput-based, constant-rate, and Poisson-rate). The benchmark function now accepts optional strategies and returns per-request start times alongside execution times. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Benchmark as async_scaffolding_benchmark
participant Strategy as LoadGenerationStrategy
participant Runner as run_scaffolding_llm
participant Processor as process_request
participant Queue as output_queue
Client->>Benchmark: requests, strategy (or concurrency)
Benchmark->>Benchmark: initialize strategy if needed
Benchmark->>Runner: launch with strategy
loop for each request
Runner->>Strategy: request_times() generator
Strategy-->>Runner: target_time
Runner->>Strategy: get_semaphore()
Strategy-->>Runner: semaphore
Runner->>Processor: create task (target_time, semaphore)
Processor->>Processor: wait until target_time
Processor->>Processor: execute request
Processor->>Queue: enqueue (result, request_start_time, request_execution_time)
end
Benchmark->>Benchmark: collect requests_start_time, requests_execution_time
Benchmark-->>Client: (results, requests_start_time, requests_execution_time, total_time)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes The changes introduce a new strategy abstraction framework with multiple implementations, require understanding the refactored benchmark control flow, and necessitate validation of timing semantics across different strategy types. While the individual pieces follow clear patterns, the interconnected changes across three files demand careful review of signature changes, return type modifications, and timing correctness in the test cases. Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
🧹 Nitpick comments (4)
tests/unittest/scaffolding/test_bench.py (3)
64-64: Prefix unused unpacked variables with underscore.The variables
requests_start_timeandtotal_timeare unpacked but never used in this test. Prefix them with underscores to indicate they are intentionally unused.Apply this diff:
- results, requests_start_time, requests_execution_time, total_time = asyncio.run( + results, _requests_start_time, requests_execution_time, _total_time = asyncio.run( async_scaffolding_benchmark(scaffolding_llm, task_collection_types, requests, concurrency))
156-156: Prefix unused unpacked variables with underscore.The variables
results,requests_execution_time, andtotal_timeare unpacked but onlyrequests_start_timeis used for timing verification. Prefix unused variables with underscores.Apply this diff:
- results, requests_start_time, requests_execution_time, total_time = asyncio.run( + _results, requests_start_time, _requests_execution_time, _total_time = asyncio.run( async_scaffolding_benchmark(scaffolding_llm, task_collection_types, requests, strategy=strategy))
165-165: Remove unnecessary f-string prefix.The string has no placeholders, so the
fprefix is unnecessary.Apply this diff:
- print(f"before shutdown") + print("before shutdown")tensorrt_llm/scaffolding/load_generation_strategy.py (1)
295-302: Consider sorting__all__alphabetically.Static analysis suggests alphabetical sorting for consistency. However, the current order (base class first, then strategies) is logical and acceptable.
If you prefer alphabetical sorting:
__all__ = [ + "ConcurrentStrategy", + "ConstantRateStrategy", "LoadGenerationStrategy", + "PoissonRateStrategy", "SynchronousStrategy", - "ConcurrentStrategy", "ThroughputStrategy", - "ConstantRateStrategy", - "PoissonRateStrategy", ]
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
tensorrt_llm/scaffolding/benchmark.py(5 hunks)tensorrt_llm/scaffolding/load_generation_strategy.py(1 hunks)tests/unittest/scaffolding/test_bench.py(3 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{h,hpp,hh,hxx,cpp,cxx,cc,cu,cuh,py}
📄 CodeRabbit inference engine (CODING_GUIDELINES.md)
Use only spaces, no tabs; indent with 4 spaces.
Files:
tests/unittest/scaffolding/test_bench.pytensorrt_llm/scaffolding/load_generation_strategy.pytensorrt_llm/scaffolding/benchmark.py
**/*.py
📄 CodeRabbit inference engine (CODING_GUIDELINES.md)
**/*.py: Python code must target Python 3.8+.
Indent Python code with 4 spaces; do not use tabs.
Maintain module namespace when importing; prefer 'from package.subpackage import foo' then 'foo.SomeClass()' instead of importing the class directly.
Python filenames should be snake_case (e.g., some_file.py).
Python classes use PascalCase names.
Functions and methods use snake_case names.
Local variables use snake_case; prefix 'k' for variables that start with a number (e.g., k_99th_percentile).
Global variables use upper SNAKE_CASE prefixed with 'G' (e.g., G_MY_GLOBAL).
Constants use upper SNAKE_CASE (e.g., MY_CONSTANT).
Avoid shadowing variables from an outer scope.
Initialize all externally visible members of a class in the constructor.
Prefer docstrings for interfaces that may be used outside a file; comments for in-function or file-local interfaces.
Use Google-style docstrings for classes and functions (Sphinx-parsable).
Document attributes and variables inline so they render under the class/function docstring.
Avoid reflection when a simpler, explicit approach suffices (e.g., avoid dict(**locals()) patterns).
In try/except, catch the most specific exceptions possible.
For duck-typing try/except, keep the try body minimal and use else for the main logic.
Files:
tests/unittest/scaffolding/test_bench.pytensorrt_llm/scaffolding/load_generation_strategy.pytensorrt_llm/scaffolding/benchmark.py
**/*.{cpp,cxx,cc,h,hpp,hh,hxx,cu,cuh,py}
📄 CodeRabbit inference engine (CODING_GUIDELINES.md)
Prepend the NVIDIA Apache-2.0 copyright header with current year to the top of all source files (e.g., .cpp, .h, .cu, .py).
Files:
tests/unittest/scaffolding/test_bench.pytensorrt_llm/scaffolding/load_generation_strategy.pytensorrt_llm/scaffolding/benchmark.py
🧬 Code graph analysis (3)
tests/unittest/scaffolding/test_bench.py (7)
tensorrt_llm/executor/request.py (1)
GenerationRequest(84-133)tensorrt_llm/scaffolding/task.py (7)
result(71-72)result(75-76)GenerationTask(30-117)Task(12-20)TaskStatus(23-26)output_str(87-88)output_str(91-93)tensorrt_llm/executor/result.py (2)
GenerationResult(656-830)prompt_token_ids(708-709)tensorrt_llm/scaffolding/benchmark.py (2)
ScaffoldingBenchRequest(15-16)async_scaffolding_benchmark(78-126)tensorrt_llm/scaffolding/scaffolding_llm.py (2)
ScaffoldingLlm(22-237)shutdown(215-237)tensorrt_llm/scaffolding/worker.py (1)
Worker(18-40)tensorrt_llm/scaffolding/load_generation_strategy.py (6)
ConcurrentStrategy(116-147)ConstantRateStrategy(178-229)LoadGenerationStrategy(28-86)PoissonRateStrategy(232-291)SynchronousStrategy(89-113)ThroughputStrategy(150-175)
tensorrt_llm/scaffolding/load_generation_strategy.py (1)
tensorrt_llm/llmapi/llm_args.py (1)
Field(70-97)
tensorrt_llm/scaffolding/benchmark.py (3)
tensorrt_llm/scaffolding/load_generation_strategy.py (6)
LoadGenerationStrategy(28-86)get_semaphore(44-55)get_semaphore(105-108)get_semaphore(136-139)request_times(57-70)ConcurrentStrategy(116-147)tensorrt_llm/scaffolding/scaffolding_llm.py (1)
ScaffoldingLlm(22-237)tensorrt_llm/scaffolding/result.py (1)
ScaffoldingResult(7-80)
🪛 Ruff (0.14.1)
tests/unittest/scaffolding/test_bench.py
64-64: Unpacked variable requests_start_time is never used
Prefix it with an underscore or any other dummy variable pattern
(RUF059)
64-64: Unpacked variable total_time is never used
Prefix it with an underscore or any other dummy variable pattern
(RUF059)
156-156: Unpacked variable results is never used
Prefix it with an underscore or any other dummy variable pattern
(RUF059)
156-156: Unpacked variable requests_execution_time is never used
Prefix it with an underscore or any other dummy variable pattern
(RUF059)
156-156: Unpacked variable total_time is never used
Prefix it with an underscore or any other dummy variable pattern
(RUF059)
165-165: f-string without any placeholders
Remove extraneous f prefix
(F541)
tensorrt_llm/scaffolding/load_generation_strategy.py
282-282: Standard pseudo-random generators are not suitable for cryptographic purposes
(S311)
295-302: __all__ is not sorted
Apply an isort-style sorting to __all__
(RUF022)
tensorrt_llm/scaffolding/benchmark.py
87-87: Avoid specifying long messages outside the exception class
(TRY003)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Pre-commit Check
🔇 Additional comments (18)
tests/unittest/scaffolding/test_bench.py (9)
1-17: LGTM!The new imports (math, numpy, GenerationRequest, GenerationResult, SamplingParams, and strategy types) are appropriate for the expanded test coverage and timing-based validations.
24-30: LGTM!The refactored handler now properly creates a
GenerationResultobject with aGenerationRequestandSamplingParams, marking it as done and populating the output string. This aligns with the updated result structure.
44-45: LGTM!The
after_yieldmethod correctly derives the output length fromresult.output_strinstead of the previous result length, aligning with the newGenerationResultstructure.
70-74: LGTM!The assertions correctly verify the result count, execution time count, output string content, and task collection state.
77-91: LGTM!The helper functions
setup_scaffoldingandcreate_requestsextract common test setup logic, improving maintainability and reducing duplication.
94-102: LGTM!The
calculate_intervalsfunction correctly computes inter-arrival times, excludes the initial burst if configured, and returns the expected interval based on the target rate.
105-138: LGTM!The timing verification correctly validates:
- ConstantRateStrategy: Checks that average, max, and min intervals match the expected constant interval (1/rate).
- PoissonRateStrategy: Verifies the mean interval, standard deviation, and coefficient of variation align with exponential distribution properties (CV ≈ 1.0).
The 30% relative tolerance (rtol=0.3) is reasonable for statistical tests with limited sample sizes.
169-171: LGTM!The main guard allows running the tests directly as a script, which is useful for manual testing and debugging.
141-166: Reusingscaffolding_llmacross multiple benchmark runs is safe.Each benchmark iteration creates fresh requests and isolated task queues. Streaming is not enabled in this test, so the
streaming_eventstate isolation concern does not apply. The shared event loop and task queue properly handle the workload without state pollution between runs.tensorrt_llm/scaffolding/load_generation_strategy.py (5)
1-12: LGTM!The module docstring appropriately credits the inspiration source, and the imports are well-organized and necessary for the implementation.
15-25: LGTM!The
_UnlimitedSemaphoreclass correctly implements the async context manager protocol for strategies that don't need concurrency limits. ReturningFalsefrom__aexit__properly allows exceptions to propagate.
28-86: LGTM!The
LoadGenerationStrategyabstract base class is well-designed:
- Template method pattern ensures consistent
start_timeinitialization.- Extensible via
get_semaphore()override for concurrency control.- Clear separation between public API (
request_times) and subclass implementation (_generate_request_times).- Comprehensive docstrings explain the design.
89-113: LGTM!The
SynchronousStrategycorrectly implements serial execution by returning a semaphore with limit 1, ensuring only one request processes at a time. The docstring clearly explains the characteristics and use case.
116-148: LGTM!The
ConcurrentStrategyproperly implements N-way concurrency:
- Field validation ensures
concurrency > 0.- Semaphore correctly limits concurrent request processing.
- Custom
__str__provides informative representation.tensorrt_llm/scaffolding/benchmark.py (4)
1-12: LGTM!The new imports (
OptionalandLoadGenerationStrategy) are appropriate for the strategy-based benchmark implementation.
26-38: LGTM!The updated
process_requestcorrectly implements rate-based scheduling:
- Waits until
target_timebefore executing (ifwait_time > 0).- If the system falls behind (
wait_time < 0), it proceeds immediately without blocking.- Captures both
request_start_timeandrequest_execution_timefor analysis.
41-61: LGTM!The
run_scaffolding_llmfunction properly integrates with the strategy framework:
- Obtains semaphore and time generator from the strategy.
- Schedules each request at its designated
target_time.- Uses set-based task tracking with done callbacks to prevent memory leaks.
- Correctly waits for all tasks to complete before signaling shutdown.
78-126: LGTM!The
async_scaffolding_benchmarkfunction successfully integrates the strategy framework while maintaining backward compatibility:
- Accepts either
strategyorconcurrencyparameters.- Automatically creates
ConcurrentStrategywhen onlyconcurrencyis provided.- Returns per-request start times for timing analysis.
- Proper validation ensures at least one parameter is provided.
The static analysis hint (TRY003) about the error message is a minor style suggestion and can be safely ignored in this context.
|
/bot run --disable-fail-fast |
|
PR_Github #22110 [ run ] triggered by Bot. Commit: |
|
PR_Github #22110 [ run ] completed with state |
Signed-off-by: Dong Cao <[email protected]>
64f6193 to
30fa528
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #22136 [ run ] triggered by Bot. Commit: |
|
PR_Github #22136 [ run ] completed with state |
|
/bot run --disable-fail-fast |
|
PR_Github #22166 [ run ] triggered by Bot. Commit: |
|
PR_Github #22166 [ run ] completed with state |
Summary by CodeRabbit
New Features
Tests
Description
Test Coverage
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)
Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
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
/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...Provide a user friendly way for developers to interact with a Jenkins server.
Run
/bot [-h|--help]to print this help message.See details below for each supported subcommand.
run [--reuse-test (optional)pipeline-id --disable-fail-fast --skip-test --stage-list "A10-PyTorch-1, xxx" --gpu-type "A30, H100_PCIe" --test-backend "pytorch, cpp" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" --detailed-log --debug(experimental)]Launch build/test pipelines. All previously running jobs will be killed.
--reuse-test (optional)pipeline-id(OPTIONAL) : Allow the new pipeline to reuse build artifacts and skip successful test stages from a specified pipeline or the last pipeline if no pipeline-id is indicated. If the Git commit ID has changed, this option will be always ignored. The DEFAULT behavior of the bot is to reuse build artifacts and successful test results from the last pipeline.--disable-reuse-test(OPTIONAL) : Explicitly prevent the pipeline from reusing build artifacts and skipping successful test stages from a previous pipeline. Ensure that all builds and tests are run regardless of previous successes.--disable-fail-fast(OPTIONAL) : Disable fail fast on build/tests/infra failures.--skip-test(OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.--stage-list "A10-PyTorch-1, xxx"(OPTIONAL) : Only run the specified test stages. Examples: "A10-PyTorch-1, xxx". Note: Does NOT update GitHub check status.--gpu-type "A30, H100_PCIe"(OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.--test-backend "pytorch, cpp"(OPTIONAL) : Skip test stages which don't match the specified backends. Only support [pytorch, cpp, tensorrt, triton]. Examples: "pytorch, cpp" (does not run test stages with tensorrt or triton backend). Note: Does NOT update GitHub pipeline status.--only-multi-gpu-test(OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.--disable-multi-gpu-test(OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.--add-multi-gpu-test(OPTIONAL) : Force run the multi-GPU tests in addition to running L0 pre-merge pipeline.--post-merge(OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.--extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx"(OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx".--detailed-log(OPTIONAL) : Enable flushing out all logs to the Jenkins console. This will significantly increase the log volume and may slow down the job.--debug(OPTIONAL) : Experimental feature. Enable access to the CI container for debugging purpose. Note: Specify exactly one stage in thestage-listparameter to access the appropriate container environment. Note: Does NOT update GitHub check status.For guidance on mapping tests to stage names, see
docs/source/reference/ci-overview.mdand the
scripts/test_to_stage_mapping.pyhelper.kill
killKill all running builds associated with pull request.
skip
skip --comment COMMENTSkip testing for latest commit on pull request.
--comment "Reason for skipping build/test"is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.reuse-pipeline
reuse-pipelineReuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.