KEMBAR78
[TRTLLM-8070][test] add generation logits case for llama3 by crazydemo · Pull Request #7759 · NVIDIA/TensorRT-LLM · GitHub
Skip to content

Conversation

@crazydemo
Copy link
Collaborator

@crazydemo crazydemo commented Sep 16, 2025

These cases can pass locally on 8xA100

Summary by CodeRabbit

  • Tests
    • Added end-to-end scenarios validating text generation with and without logits across multiple model sizes, including streaming, varied sequence lengths, and tensor-parallel configurations.
    • Improves reliability on multi-GPU and lower-memory setups, enhancing confidence in generation outputs and stability before release.
    • Updated QA test lists to include these scenarios for continuous coverage.
    • No user-facing functionality changed.

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 the stage-list parameter 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.md
and the scripts/test_to_stage_mapping.py helper.

kill

kill

Kill all running builds associated with pull request.

skip

skip --comment COMMENT

Skip 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-pipeline

Reuse 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.

@crazydemo
Copy link
Collaborator Author

/bot run

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 16, 2025

📝 Walkthrough

Walkthrough

Adds a new parameterized async integration test (test_llmapi_generation_logits) to exercise LLM generate_async with optional generation logits and streaming for Llama models. Updates the QA test list with four corresponding entries. The new test block appears twice in the same file.

Changes

Cohort / File(s) Summary
Integration test: async logits generation
tests/integration/defs/test_e2e.py
Adds test_llmapi_generation_logits with skip guards, parametrized over model_path and return_generation_logits. Builds tensorrt_llm LLM and SamplingParams, runs generate_async with streaming, asserts output, and shuts down. The test block is duplicated in the file.
QA test list updates
tests/integration/test_lists/qa/llm_function_nim.txt
Appends four new entries mapping to the new test permutations for Llama 3.1 8B and 3.3 70B with logits on/off.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant T as Test (pytest)
  participant L as LLM (tensorrt_llm.LLM)
  participant E as Event Loop
  participant S as Stream (async iterator)

  rect rgb(245,248,255)
    note right of T: Parametrize: model_path, return_generation_logits
    T->>L: Construct LLM(tp_size, model_path)
    T->>L: Configure SamplingParams(seq_len, max_tokens, return_generation_logits)
  end

  rect rgb(245,255,245)
    T->>E: run(async_generate())
    activate E
    E->>L: generate_async(prompt_ids, stream=True)
    L-->>S: return async stream
    loop stream tokens/chunks
      S-->>E: yield output chunk (+optional logits)
      E-->>T: collect outputs
    end
    E-->>T: finalize results
    deactivate E
  end

  rect rgb(255,248,245)
    T->>T: assert outputs not empty
    T->>L: shutdown()
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Pre-merge checks

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description Check ⚠️ Warning The PR body is largely the repository template left unfilled; aside from the single line "These cases can pass locally on 8xA100" it lacks a proper PR title per the template, a populated Description that explains the change and motivation, and a Test Coverage section enumerating which tests were added and how they protect the change. The PR Checklist items (dependency/license scan, CODEOWNERS, documentation updates, and adherence to coding guidelines) are not confirmed, so reviewers cannot assess readiness. Because the template fields are empty placeholders the description does not meet the repository's required PR description standards. Please update the PR body to include a title following the repository template, add a concise Description summarizing what was changed and why, and complete the Test Coverage section with exact test names and instructions to run locally and in CI; also confirm PR Checklist items (dependency/license scan, CODEOWNERS, docs, and coding-guidelines adherence). Remove or explain the duplicate test insertion noted in the changes and link to the new/modified test files in the description. After these additions the description can be re-evaluated for completeness.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "[TRTLLM-8070][test] add generation logits case for llama3" concisely includes the ticket, change type, and primary intent of the changeset (adding generation-logits test cases for Llama3). It directly matches the main change described in the raw summary (new test(s) in tests/integration/defs/test_e2e.py), is specific and readable, and would be understandable to a teammate scanning history. Therefore the title accurately summarizes the primary change without extraneous noise.

@tensorrt-cicd
Copy link
Collaborator

PR_Github #18754 [ run ] triggered by Bot

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (5)
tests/integration/defs/test_e2e.py (5)

3248-3248: Remove unused fixture parameter llm_venv

Ruff flags it (ARG001). It’s not used in this test.

Apply this diff:

-def test_llmapi_generation_logits(llm_venv, model_path, return_generation_logits):
+def test_llmapi_generation_logits(model_path, return_generation_logits):

3311-3312: Prefer asyncio.run to manage the event loop

Avoids reuse of a possibly closed loop and is cleaner in pytest.

Apply this diff:

-    loop = asyncio.get_event_loop()
-    loop.run_until_complete(async_generation_test())
+    asyncio.run(async_generation_test())

3256-3260: Right-size seq_len/max_tokens to keep CI stable

131072/100000 can be excessive and flaky in CI even with memory skips. Smaller bounds still exercise the path.

Apply this diff:

-    seq_len, max_tokens = 131072, 100000
+    seq_len, max_tokens = 4096, 64
     if return_generation_logits:
-        # use short seq_len and max_tokens for testing when return_generation_logits is True
-        seq_len, max_tokens = 1024, 1000
+        # keep logits case short to cap tensor sizes
+        seq_len, max_tokens = 1024, 64

3263-3276: Trim unused/odd options in params (batch size, guided decoding)

  • cuda_graph batch_sizes=512 doesn’t match batch=1 here; set to 1.
  • guided_decoding_backend is unused; drop to avoid unnecessary deps.

Apply this diff:

-        "cuda_graph_config": {
-            "batch_sizes": [512]
-        },
-        "enable_chunked_prefill": True,
-        "guided_decoding_backend": "xgrammar",
+        "cuda_graph_config": {"batch_sizes": [1]},
+        "enable_chunked_prefill": True,

3291-3309: Use context manager for LLM lifecycle

Simplifies cleanup and avoids manual shutdown logic.

Apply this diff:

-        llm = LLM(**params, model=model_path_full, tokenizer=model_path_full)
-        
-        try:
-            outputs = []
-            async for output in llm.generate_async(
-                prompt,
-                sampling_params,
-                streaming=True,
-            ):
-                outputs.append(output)
-                print(f"Generated: {output}")
-            
-            # Verify that we got some output
-            assert len(outputs) > 0, "No output generated"
-            print(f"Successfully generated {len(outputs)} streaming outputs")
-            
-        finally:
-            llm.shutdown()
+        outputs = []
+        with LLM(**params, model=model_path_full, tokenizer=model_path_full) as llm:
+            async for output in llm.generate_async(
+                prompt,
+                sampling_params,
+                streaming=True,
+            ):
+                outputs.append(output)
+                print(f"Generated: {output}")
+
+        # Verify that we got some output
+        assert len(outputs) > 0, "No output generated"
+        print(f"Successfully generated {len(outputs)} streaming outputs")
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6eef192 and d819af2.

📒 Files selected for processing (2)
  • tests/integration/defs/test_e2e.py (1 hunks)
  • tests/integration/test_lists/qa/llm_function_nim.txt (1 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/integration/defs/test_e2e.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/integration/defs/test_e2e.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/integration/defs/test_e2e.py
🧠 Learnings (5)
📓 Common learnings
Learnt from: fredricz-20070104
PR: NVIDIA/TensorRT-LLM#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.
Learnt from: moraxu
PR: NVIDIA/TensorRT-LLM#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.
📚 Learning: 2025-09-09T09:40:45.658Z
Learnt from: fredricz-20070104
PR: NVIDIA/TensorRT-LLM#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_nim.txt
📚 Learning: 2025-07-28T17:06:08.621Z
Learnt from: moraxu
PR: NVIDIA/TensorRT-LLM#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_nim.txt
  • tests/integration/defs/test_e2e.py
📚 Learning: 2025-08-26T09:49:04.956Z
Learnt from: pengbowang-nv
PR: NVIDIA/TensorRT-LLM#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/test_lists/qa/llm_function_nim.txt
📚 Learning: 2025-08-06T13:58:07.506Z
Learnt from: galagam
PR: NVIDIA/TensorRT-LLM#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_nim.txt
🧬 Code graph analysis (1)
tests/integration/defs/test_e2e.py (3)
tests/integration/defs/conftest.py (1)
  • llm_models_root (77-82)
tensorrt_llm/llmapi/llm.py (6)
  • LLM (1022-1038)
  • prompt (81-82)
  • tokenizer (700-704)
  • tokenizer (707-708)
  • generate_async (319-459)
  • shutdown (711-718)
tensorrt_llm/sampling_params.py (1)
  • SamplingParams (125-486)
🪛 Ruff (0.12.2)
tests/integration/defs/test_e2e.py

3248-3248: Unused function argument: llm_venv

(ARG001)

⏰ 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 (1)
tests/integration/test_lists/qa/llm_function_nim.txt (1)

175-178: LGTM: test entries wired into NIM list correctly

The four parametrized cases map 1:1 to the new test and follow existing naming. No duplication concerns.

@tensorrt-cicd
Copy link
Collaborator

PR_Github #18754 [ run ] completed with state FAILURE
/LLM/main/L0_MergeRequest_PR pipeline #14060 completed with status: 'FAILURE'

@crazydemo
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #18865 [ run ] triggered by Bot

@crazydemo
Copy link
Collaborator Author

/bot kill

@tensorrt-cicd
Copy link
Collaborator

PR_Github #18866 [ kill ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #18865 [ run ] completed with state ABORTED
LLM/main/L0_MergeRequest_PR #14141 (Blue Ocean) completed with status: ABORTED

@tensorrt-cicd
Copy link
Collaborator

PR_Github #18866 [ kill ] completed with state SUCCESS
Successfully killed previous jobs for commit 0fdab58

@crazydemo
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #18869 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #18869 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #14144 completed with status: 'FAILURE'

@crazydemo
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #18897 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #18897 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #14166 completed with status: 'FAILURE'

Signed-off-by: Ivy Zhang <25222398+crazydemo@users.noreply.github.com>
@crazydemo
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #19069 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #19069 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #14306 completed with status: 'SUCCESS'

@StanleySun639 StanleySun639 merged commit 26d50eb into NVIDIA:main Sep 18, 2025
5 checks passed
Wong4j pushed a commit to Wong4j/TensorRT-LLM that referenced this pull request Sep 20, 2025
Signed-off-by: Ivy Zhang <25222398+crazydemo@users.noreply.github.com>
MrGeva pushed a commit to nv-auto-deploy/TensorRT-LLM that referenced this pull request Sep 21, 2025
Signed-off-by: Ivy Zhang <25222398+crazydemo@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants