-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[TRTLLM-8948][test] Add long bench case #9165
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
[TRTLLM-8948][test] Add long bench case #9165
Conversation
📝 WalkthroughWalkthroughIntroduces LongBench v2 evaluation support for long-context models. Adds CLI options to the evaluation command, defines a new LongBenchV2 test task class with model configuration modifications, includes integration tests for multiple quantization methods, and adds reference accuracy data and test list entries. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI as Eval CLI<br>(longbench_v2.py)
participant Task as LongBenchV2 Task<br>(accuracy_core.py)
participant Eval as Evaluator
participant Validator as Accuracy<br>Validator
User->>CLI: trtllm-eval longbench_v2<br/>(--check_accuracy, --accuracy_threshold)
CLI->>Task: Load task config
Task->>Task: create_modified_model_dir()
Task->>Task: Adjust max_position_embeddings<br/>& model_max_length
Task->>Eval: Run evaluation with<br/>EVALUATOR_KWARGS
Eval->>Eval: Process long-context<br/>dataset
Eval-->>CLI: Return accuracy score
alt check_accuracy enabled
CLI->>Validator: Verify accuracy ≥ threshold
alt Passes
Validator-->>CLI: OK
CLI-->>User: Success
else Fails
Validator-->>CLI: AssertionError
CLI-->>User: Failure
end
else check_accuracy disabled
CLI-->>User: Return results
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Areas requiring extra attention:
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: 2
🧹 Nitpick comments (1)
tests/integration/defs/accuracy/accuracy_core.py (1)
494-571: create_modified_model_dir is functionally correct; minor polish possibleThe helper correctly:
- Creates an isolated temp directory.
- Symlinks all entries except
config.jsonandtokenizer_config.json.- Rewrites those configs with updated
max_position_embeddings/model_max_length.- Logs key steps for traceability.
Two small, optional cleanups:
- You already import
tempfileat module level; you can reuse that instead of re-importing inside the method.- Consider adding a brief guard/error message if
original_model_dirdoes not exist, to fail fast with a clearer error when used outside tests that pre-check the path.No functional changes required for the current test usage.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
tensorrt_llm/evaluate/longbench_v2.py(3 hunks)tests/integration/defs/accuracy/accuracy_core.py(2 hunks)tests/integration/defs/accuracy/references/longbench_v2.yaml(1 hunks)tests/integration/defs/accuracy/test_llm_api_pytorch.py(2 hunks)tests/integration/defs/test_e2e.py(1 hunks)tests/integration/test_lists/qa/llm_function_long_bench.txt(1 hunks)
🧰 Additional context used
🧠 Learnings (9)
📚 Learning: 2025-09-09T09:40:45.658Z
Learnt from: fredricz-20070104
Repo: NVIDIA/TensorRT-LLM PR: 7645
File: tests/integration/test_lists/qa/llm_function_core.txt:648-648
Timestamp: 2025-09-09T09:40:45.658Z
Learning: In TensorRT-LLM test lists, it's common and intentional for the same test to appear in multiple test list files when they serve different purposes (e.g., llm_function_core.txt for comprehensive core functionality testing and llm_function_core_sanity.txt for quick sanity checks). This duplication allows tests to be run in different testing contexts.
Applied to files:
tests/integration/test_lists/qa/llm_function_long_bench.txttests/integration/defs/test_e2e.pytests/integration/defs/accuracy/test_llm_api_pytorch.py
📚 Learning: 2025-07-28T17:06:08.621Z
Learnt from: moraxu
Repo: NVIDIA/TensorRT-LLM PR: 6303
File: tests/integration/test_lists/qa/examples_test_list.txt:494-494
Timestamp: 2025-07-28T17:06:08.621Z
Learning: In TensorRT-LLM testing, it's common to have both CLI flow tests (test_cli_flow.py) and PyTorch API tests (test_llm_api_pytorch.py) for the same model. These serve different purposes: CLI flow tests validate the traditional command-line workflow, while PyTorch API tests validate the newer LLM API backend. Both are legitimate and should coexist.
Applied to files:
tests/integration/test_lists/qa/llm_function_long_bench.txttests/integration/defs/test_e2e.pytests/integration/defs/accuracy/test_llm_api_pytorch.py
📚 Learning: 2025-08-06T13:58:07.506Z
Learnt from: galagam
Repo: NVIDIA/TensorRT-LLM PR: 6487
File: tests/unittest/_torch/auto_deploy/unit/singlegpu/test_ad_trtllm_bench.py:1-12
Timestamp: 2025-08-06T13:58:07.506Z
Learning: In TensorRT-LLM, test files (files under tests/ directories) do not require NVIDIA copyright headers, unlike production source code files. Test files typically start directly with imports, docstrings, or code.
Applied to files:
tests/integration/test_lists/qa/llm_function_long_bench.txttests/integration/defs/test_e2e.pytests/integration/defs/accuracy/test_llm_api_pytorch.py
📚 Learning: 2025-09-17T02:48:52.732Z
Learnt from: tongyuantongyu
Repo: NVIDIA/TensorRT-LLM PR: 7781
File: tests/integration/test_lists/waives.txt:313-313
Timestamp: 2025-09-17T02:48:52.732Z
Learning: In TensorRT-LLM, `tests/integration/test_lists/waives.txt` is specifically for waiving/skipping tests, while other test list files like those in `test-db/` and `qa/` directories are for different test execution contexts (pre-merge, post-merge, QA tests). The same test appearing in both waives.txt and execution list files is intentional - the test is part of test suites but will be skipped due to the waiver.
Applied to files:
tests/integration/test_lists/qa/llm_function_long_bench.txt
📚 Learning: 2025-08-26T09:49:04.956Z
Learnt from: pengbowang-nv
Repo: NVIDIA/TensorRT-LLM PR: 7192
File: tests/integration/test_lists/test-db/l0_dgx_b200.yml:56-72
Timestamp: 2025-08-26T09:49:04.956Z
Learning: In TensorRT-LLM test configuration files, the test scheduling system handles wildcard matching with special rules that prevent duplicate test execution even when the same tests appear in multiple yaml files with overlapping GPU wildcards (e.g., "*b200*" and "*gb200*").
Applied to files:
tests/integration/defs/test_e2e.pytests/integration/defs/accuracy/test_llm_api_pytorch.py
📚 Learning: 2025-08-18T08:42:02.640Z
Learnt from: samuellees
Repo: NVIDIA/TensorRT-LLM PR: 6974
File: tensorrt_llm/serve/scripts/benchmark_dataset.py:558-566
Timestamp: 2025-08-18T08:42:02.640Z
Learning: In TensorRT-LLM's RandomDataset (tensorrt_llm/serve/scripts/benchmark_dataset.py), when using --random-token-ids option, sequence length accuracy is prioritized over semantic correctness for benchmarking purposes. The encode/decode operations should use skip_special_tokens=True and add_special_tokens=False to ensure exact target token lengths.
Applied to files:
tensorrt_llm/evaluate/longbench_v2.py
📚 Learning: 2025-08-26T09:37:10.463Z
Learnt from: jiaganc
Repo: NVIDIA/TensorRT-LLM PR: 7031
File: tensorrt_llm/bench/dataclasses/configuration.py:90-104
Timestamp: 2025-08-26T09:37:10.463Z
Learning: In TensorRT-LLM's bench configuration, the `get_pytorch_perf_config()` method returns `self.pytorch_config` which is a Dict[str, Any] that can contain default values including `cuda_graph_config`, making the fallback `llm_args["cuda_graph_config"]` safe to use.
Applied to files:
tests/integration/defs/accuracy/test_llm_api_pytorch.py
📚 Learning: 2025-08-26T09:37:10.463Z
Learnt from: jiaganc
Repo: NVIDIA/TensorRT-LLM PR: 7031
File: tensorrt_llm/bench/dataclasses/configuration.py:90-104
Timestamp: 2025-08-26T09:37:10.463Z
Learning: In TensorRT-LLM, the `get_pytorch_perf_config()` method returns `self.pytorch_config` which can contain default `cuda_graph_config` values, so `llm_args` may already have this config before the extra options processing.
Applied to files:
tests/integration/defs/accuracy/test_llm_api_pytorch.py
📚 Learning: 2025-08-11T20:09:24.389Z
Learnt from: achartier
Repo: NVIDIA/TensorRT-LLM PR: 6763
File: tests/integration/defs/triton_server/conftest.py:16-22
Timestamp: 2025-08-11T20:09:24.389Z
Learning: In the TensorRT-LLM test infrastructure, the team prefers simple, direct solutions (like hard-coding directory traversal counts) over more complex but robust approaches when dealing with stable directory structures. They accept the maintenance cost of updating tests if the layout changes.
Applied to files:
tests/integration/defs/accuracy/test_llm_api_pytorch.py
🧬 Code graph analysis (4)
tests/integration/defs/test_e2e.py (3)
tests/integration/defs/conftest.py (3)
llm_venv(702-719)llm_models_root(80-94)get_device_count(1986-1988)tensorrt_llm/llmapi/utils.py (3)
get_device_count(133-134)get(415-445)get(498-515)tests/integration/defs/trt_test_alternative.py (1)
check_call(250-258)
tensorrt_llm/evaluate/longbench_v2.py (1)
tensorrt_llm/logger.py (1)
warning(132-133)
tests/integration/defs/accuracy/test_llm_api_pytorch.py (7)
tensorrt_llm/quantization/mode.py (1)
QuantAlgo(23-47)tests/integration/defs/conftest.py (2)
get_device_memory(1991-2022)llm_models_root(80-94)tests/integration/defs/accuracy/accuracy_core.py (2)
LongBenchV2(438-571)create_modified_model_dir(495-571)tensorrt_llm/llmapi/llm_args.py (4)
KvCacheConfig(1261-1405)CudaGraphConfig(102-159)MTPDecodingConfig(808-860)MoeConfig(264-298)tensorrt_llm/llmapi/llm.py (1)
LLM(1101-1117)tensorrt_llm/sampling_params.py (1)
SamplingParams(113-540)tensorrt_llm/logger.py (1)
info(138-139)
tests/integration/defs/accuracy/accuracy_core.py (2)
tensorrt_llm/evaluate/lm_eval.py (3)
evaluate(394-429)apply_chat_template(66-78)apply_chat_template(197-249)tests/integration/defs/conftest.py (1)
llm_models_root(80-94)
🪛 Ruff (0.14.4)
tests/integration/defs/test_e2e.py
3628-3628: f-string without any placeholders
Remove extraneous f prefix
(F541)
3632-3632: Function call with shell=True parameter identified, security issue
(S604)
tests/integration/defs/accuracy/accuracy_core.py
458-458: PEP 484 prohibits implicit Optional
Convert to T | None
(RUF013)
⏰ 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 (14)
tensorrt_llm/evaluate/longbench_v2.py (3)
816-823: LGTM! CLI options are well-defined.The new CLI options are correctly implemented with appropriate types, defaults, and help text.
832-833: LGTM! Function signature correctly updated.The command signature properly accepts the new parameters with correct type hints.
858-867: LGTM! Accuracy check implementation is correct.The evaluation flow is properly structured:
- Run evaluation and capture accuracy score
- Shutdown the LLM
- Optionally verify accuracy meets threshold with clear error message
The deprecation warning appropriately guides users toward the preferred approach of using the LLM API within pytest.
tests/integration/defs/accuracy/references/longbench_v2.yaml (1)
1-9: Verify identical accuracy values for different quantization methods.Both FP8_BLOCK_SCALES and NVFP4 quantization configurations show the same accuracy value (52.093). Please confirm:
- Is this intentional, indicating both methods achieve similar performance?
- Are these actual measured values, or placeholders that need updating?
If these are measured values and truly identical, consider adding a comment in the YAML to clarify this is expected.
tests/integration/test_lists/qa/llm_function_long_bench.txt (1)
1-2: LGTM! Test list entries are correctly formatted.The test list properly references the new LongBenchV2 test methods with appropriate GPU requirements (8 GPUs for FP8, 4 GPUs for NVFP4).
Based on learnings: In TensorRT-LLM testing, it's common to have test entries in multiple test list files for different testing contexts, which is expected and intentional.
tests/integration/defs/test_e2e.py (6)
3503-3516: LGTM! Test setup and validation checks are appropriate.The test is properly configured with:
- Architecture requirements (Blackwell+)
- Memory requirements (183GB)
- Generous timeout (8 hours) for long-context evaluation
- Proper skip conditions for missing models or insufficient GPUs
3517-3537: LGTM! Efficient temporary directory setup with symlinks.The test efficiently creates a modified model directory by:
- Using symlinks for unchanged files (avoiding large copies)
- Excluding config files that need modification
- Using descriptive prefix for temporary directory
3539-3572: LGTM! Config modifications for long-context support.The test correctly modifies configuration files to support 1,280,000 token context length:
- Updates
max_position_embeddingsin config.json- Updates
model_max_lengthin tokenizer_config.json- Provides clear logging of changes
3574-3632: LGTM! Comprehensive test configuration and execution.The test properly configures:
- CUDA graph settings with appropriate batch sizes
- Speculative decoding (MTP) with 3 draft layers
- KV cache with FP8 quantization and block reuse
- Conditional MoE config for non-FP4 variants
- Uses the new
--check_accuracyand--accuracy_thresholdflagsThe 45.0% accuracy threshold is higher than the default 30.0%, which is appropriate for ensuring quality results in this long-context evaluation.
3634-3640: LGTM! Proper cleanup in finally block.The test ensures cleanup happens regardless of test outcome by:
- Placing cleanup in finally block
- Using
ignore_errors=Trueto prevent cleanup failures from masking test errors- Logging the cleanup action
3632-3632: Note:shell=Trueusage is acceptable in this test context.Static analysis flagged
shell=Trueas a potential security issue. However, this is acceptable here because:
- This is test code, not production code
- The command is constructed from controlled inputs (no user-provided data)
- This pattern is consistent with other tests in the file (e.g., lines 183, 218, 276, etc.)
tests/integration/defs/accuracy/test_llm_api_pytorch.py (2)
29-29: New logger and LongBenchV2 imports are appropriate
loggeris used only in the LongBench temp-dir cleanup, andLongBenchV2is used by the new DeepSeek-R1 tests. Imports are minimal and correctly placed alongside existing accuracy harness imports.Also applies to: 37-38
4023-4087: DeepSeek-R1 FP8 LongBenchV2 test structure looks solidTemp-dir lifecycle is handled safely (
temp_dirsentinel +finallycleanup), model availability is checked and skipped gracefully, and the LongBenchV2 task wiring (dataset_path, length, max_* arguments, sampling_params) is consistent with the new accuracy task design. No functional issues stand out.tests/integration/defs/accuracy/accuracy_core.py (1)
438-493: LongBenchV2 task wiring is consistent with existing AccuracyTask patternsUsing a dedicated
LongBenchV2AccuracyTask with per-instanceEVALUATOR_KWARGSand overriddenMAX_INPUT_LEN/MAX_OUTPUT_LENcleanly plugs into the genericAccuracyTask.evaluateflow. Hypothesis-testing defaults (ALPHA/BETA/SIGMA/NUM_SAMPLES) andEVALUATOR_CLS = tensorrt_llm.evaluate.LongBenchV2follow the same conventions as MMLU/GSM8K.Just ensure the
tensorrt_llm.evaluate.LongBenchV2ctor acceptsdataset_path,length,max_len,apply_chat_template, andrandom_seedexactly as provided here so evaluator instantiation does not fail.
2b4f331 to
75ed54d
Compare
19a89a4 to
f2f9ecd
Compare
675259b to
e242c82
Compare
|
/bot run |
|
PR_Github #24705 [ run ] triggered by Bot. Commit: |
|
PR_Github #24705 [ run ] completed with state |
Signed-off-by: Ivy Zhang <25222398+crazydemo@users.noreply.github.com>
Signed-off-by: Ivy Zhang <25222398+crazydemo@users.noreply.github.com>
Signed-off-by: Ivy Zhang <25222398+crazydemo@users.noreply.github.com>
Signed-off-by: Ivy Zhang <25222398+crazydemo@users.noreply.github.com>
Signed-off-by: Ivy Zhang <25222398+crazydemo@users.noreply.github.com>
Signed-off-by: Ivy Zhang <25222398+crazydemo@users.noreply.github.com>
Signed-off-by: Ivy Zhang <25222398+crazydemo@users.noreply.github.com>
e242c82 to
d5c764d
Compare
|
/bot run |
|
PR_Github #24829 [ run ] triggered by Bot. Commit: |
|
PR_Github #24829 [ run ] completed with state |
These cases can pass on B300: https://prod.blsm.nvidia.com/swqa-tensorrt-qa-test/job/LLM_STRESS_TEST_CLUSTER/17/allure/
Summary by CodeRabbit
Release Notes
New Features
--check_accuracyand--accuracy_thresholdCLI options for validation during evaluation.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
Update tava architecture diagram if there is a significant design change in PR.
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.