Skip to content

[None][feat] Prefer V2 transceiver backend for Gemma and Llama - #16787

Open
moraxu wants to merge 4 commits into
NVIDIA:mainfrom
moraxu:dev-mguzek-use-transceiver-v2-for-llama-and-gemma
Open

[None][feat] Prefer V2 transceiver backend for Gemma and Llama#16787
moraxu wants to merge 4 commits into
NVIDIA:mainfrom
moraxu:dev-mguzek-use-transceiver-v2-for-llama-and-gemma

Conversation

@moraxu

@moraxu moraxu commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Dev Engineer Review

  • Added model-level transceiver runtime preference hooks:
    • Gemma 3 (Gemma3ForCausalLM) and Llama (LlamaForCausalLM) now expose get_preferred_transceiver_runtime(pretrained_config: Any = None) -> Optional[Literal["CPP", "PYTHON"]] and always resolve to "PYTHON".
  • Updated typing imports/annotations for API consistency (Any, Literal) in the affected model files.
  • Adjusted disaggregated integration tests to keep exercising the intended legacy/expected transceiver behavior:
    • test_disaggregated_perf_metrics and test_disaggregated_kv_cache_time_output now force UCX over NIXL via TRTLLM_USE_NIXL_KVCACHE=0 and TRTLLM_USE_UCX_KVCACHE=1.
    • test_disaggregated_single_gpu arbitrary KV transfer cases now force C++-serialized protocol by setting CacheTransceiverConfig(transceiver_runtime="CPP") for the relevant tests.

QA Engineer Review

  • Test code added/modified:
    • tests/unittest/llmapi/test_llm_args.py
      • Added TestTransceiverRuntimeAutoResolution.test_llama_and_gemma_model_preferences_adopted(self, model_cls) to verify _resolve_transceiver_runtime_auto(...) resolves "auto" to "PYTHON" for both LlamaForCausalLM and Gemma3ForCausalLM.
    • tests/integration/defs/disaggregated/test_disaggregated.py
      • Modified test_disaggregated_perf_metrics (perf_metrics mode) to force UCX-over-NIXL for the timing-metrics assertions.
      • Modified test_disaggregated_kv_cache_time_output to also force UCX-over-NIXL while validating TRTLLM_KVCACHE_TIME_OUTPUT_PATH.
    • tests/integration/defs/disaggregated/test_disaggregated_single_gpu.py
      • Modified test_arbitrary_kv_cache_transfer to set transceiver_runtime="CPP".
      • Modified test_arbitrary_kv_cache_transfer_missing_blocks to set transceiver_runtime="CPP".
  • Coverage in tests/integration/test_lists/ (CI/QA lists): Not verified in provided context.
  • Verdict: needs follow-up.

Description

Prefer V2 transceiver backend for Gemma and Llama

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)

  • If PR introduces API changes, an appropriate PR label is added - either api-compatible or api-breaking. For api-breaking, include BREAKING in the PR title.

  • 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

To see a list of available CI bot commands, please comment /bot help.

@moraxu
moraxu requested review from a team as code owners July 23, 2026 07:46
@moraxu
moraxu requested review from QiJune and lori-ren July 23, 2026 07:46
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 6eaf235f-3b20-46ca-9579-192f82540933

📥 Commits

Reviewing files that changed from the base of the PR and between 763bec4 and 8b0a39a.

📒 Files selected for processing (5)
  • tensorrt_llm/_torch/models/modeling_gemma3.py
  • tensorrt_llm/_torch/models/modeling_llama.py
  • tests/integration/defs/disaggregated/test_disaggregated.py
  • tests/integration/defs/disaggregated/test_disaggregated_single_gpu.py
  • tests/unittest/llmapi/test_llm_args.py
🚧 Files skipped from review as they are similar to previous changes (4)
  • tensorrt_llm/_torch/models/modeling_llama.py
  • tensorrt_llm/_torch/models/modeling_gemma3.py
  • tests/integration/defs/disaggregated/test_disaggregated.py
  • tests/unittest/llmapi/test_llm_args.py

Walkthrough

Llama and Gemma causal language model classes now declare Python as their preferred transceiver runtime. Tests cover automatic resolution, while disaggregated tests explicitly select UCX or the C++ serialization protocol.

Changes

Transceiver runtime preferences

Layer / File(s) Summary
Model runtime preference APIs
tensorrt_llm/_torch/models/modeling_gemma3.py, tensorrt_llm/_torch/models/modeling_llama.py
Adds typed get_preferred_transceiver_runtime classmethods to both model classes, returning "PYTHON".
Automatic runtime resolution coverage
tests/unittest/llmapi/test_llm_args.py
Adds parameterized coverage confirming "auto" resolves to "PYTHON" for Llama and Gemma models.
Disaggregated protocol test configuration
tests/integration/defs/disaggregated/test_disaggregated.py, tests/integration/defs/disaggregated/test_disaggregated_single_gpu.py
Forces UCX for performance metrics tests and CPP for arbitrary KV-cache transfer tests.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: api-compatible

Suggested reviewers: qijune, brnguyen2, litaotju

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change to prefer the V2 transceiver backend for Gemma and Llama.
Description check ✅ Passed The description includes a clear summary and checklist, but the Test Coverage section is left empty.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tensorrt_llm/_torch/models/modeling_gemma3.py (1)

279-284: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Document both resolver-facing runtime-preference hooks.

Add matching Google-style docstrings documenting pretrained_config and the returned runtime sentinel:

  • tensorrt_llm/_torch/models/modeling_gemma3.py#L279-L284: document Gemma3ForCausalLM.get_preferred_transceiver_runtime.
  • tensorrt_llm/_torch/models/modeling_llama.py#L1137-L1142: document LlamaForCausalLM.get_preferred_transceiver_runtime.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tensorrt_llm/_torch/models/modeling_gemma3.py` around lines 279 - 284, Add
matching Google-style docstrings to
Gemma3ForCausalLM.get_preferred_transceiver_runtime in
tensorrt_llm/_torch/models/modeling_gemma3.py lines 279-284 and
LlamaForCausalLM.get_preferred_transceiver_runtime in
tensorrt_llm/_torch/models/modeling_llama.py lines 1137-1142, documenting the
pretrained_config parameter and the returned "PYTHON" runtime sentinel while
preserving the existing behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tensorrt_llm/_torch/models/modeling_gemma3.py`:
- Around line 279-284: Add matching Google-style docstrings to
Gemma3ForCausalLM.get_preferred_transceiver_runtime in
tensorrt_llm/_torch/models/modeling_gemma3.py lines 279-284 and
LlamaForCausalLM.get_preferred_transceiver_runtime in
tensorrt_llm/_torch/models/modeling_llama.py lines 1137-1142, documenting the
pretrained_config parameter and the returned "PYTHON" runtime sentinel while
preserving the existing behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 71444888-d1ad-47d4-8c6b-dcf66b86a774

📥 Commits

Reviewing files that changed from the base of the PR and between 93efd33 and 97231af.

📒 Files selected for processing (3)
  • tensorrt_llm/_torch/models/modeling_gemma3.py
  • tensorrt_llm/_torch/models/modeling_llama.py
  • tests/unittest/llmapi/test_llm_args.py

@Shixiaowei02
Shixiaowei02 requested a review from nv-xtf July 23, 2026 08:03
@Shixiaowei02

Copy link
Copy Markdown
Collaborator

Could you please check whether any existing tests need to be adjusted, similar to the changes made in PR 16482?

@nv-xtf

nv-xtf commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Could you please check whether any existing tests need to be adjusted, similar to the changes made in PR 16482?

I checked this, and the situation is slightly different from PR 16482. The existing Kimi test used DEFAULT, which caused the test harness to fall back to UCX/CPP, so it had to be explicitly changed to NIXL + PYTHON. Llama and Gemma already have corresponding NIXL + PYTHON disaggregated accuracy tests, so I don’t think similar test changes are needed here.
The existing test_auto_dtype cases will continue to exercise UCX/CPP and can be retained as legacy coverage.

@Shixiaowei02
Shixiaowei02 force-pushed the dev-mguzek-use-transceiver-v2-for-llama-and-gemma branch from 97231af to 3b8aeaa Compare July 23, 2026 13:02
@Shixiaowei02

Copy link
Copy Markdown
Collaborator

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61293 [ run ] triggered by Bot. Commit: 3b8aeaa Link to invocation

@moraxu
moraxu requested review from a team as code owners July 23, 2026 17:01
@moraxu

moraxu commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator Author

Could you please check whether any existing tests need to be adjusted, similar to the changes made in PR 16482?

I only updated one test using TinyLlama in tests/integration/defs/disaggregated/test_disaggregated.py

@moraxu

moraxu commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61343 [ run ] triggered by Bot. Commit: df03c3a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61293 [ run ] completed with state ABORTED. Commit: 3b8aeaa
/LLM/main/L0_MergeRequest_PR pipeline #49526 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61343 [ run ] completed with state FAILURE. Commit: df03c3a
/LLM/main/L0_MergeRequest_PR pipeline #49570 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@Shixiaowei02

Copy link
Copy Markdown
Collaborator

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61484 [ run ] triggered by Bot. Commit: df03c3a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61484 [ run ] completed with state FAILURE. Commit: df03c3a
/LLM/main/L0_MergeRequest_PR pipeline #49704 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@moraxu

moraxu commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator Author

I think my modified test errors here: https://prod.blsm.nvidia.com/sw-tensorrt-top-1/job/LLM/job/main/job/L0_MergeRequest_PR/49570/testReport/junit/A10-PyTorch-3.disaggregated/test_disaggregated/test_disaggregated_perf_metrics_TinyLlama_1_1B_Chat_v1_0_/ - I will fix it shortly

@moraxu
moraxu force-pushed the dev-mguzek-use-transceiver-v2-for-llama-and-gemma branch from df03c3a to 763bec4 Compare July 24, 2026 17:13
@moraxu

moraxu commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/integration/defs/disaggregated/test_disaggregated.py (1)

1573-1580: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Pair send and receive files by their shared prefix.

Selecting send_files[0] and recv_files[0] independently can select different <instanceId>_<rank> files when multiple outputs exist or one side is missing. Require a common prefix and select both files from that pair.

Proposed fix
-    send_files = sorted(f for f in os.listdir(output_path)
-                        if f.endswith("_send.csv"))
-    recv_files = sorted(f for f in os.listdir(output_path)
-                        if f.endswith("_recv.csv"))
-    assert send_files, f"no *_send.csv in {output_path}: {os.listdir(output_path)}"
-    assert recv_files, f"no *_recv.csv in {output_path}: {os.listdir(output_path)}"
-    send_file = os.path.join(output_path, send_files[0])
-    recv_file = os.path.join(output_path, recv_files[0])
+    send_files = {
+        f.rsplit("_", 1)[0]: f
+        for f in os.listdir(output_path)
+        if f.endswith("_send.csv")
+    }
+    recv_files = {
+        f.rsplit("_", 1)[0]: f
+        for f in os.listdir(output_path)
+        if f.endswith("_recv.csv")
+    }
+    common_prefixes = sorted(send_files.keys() & recv_files.keys())
+    assert common_prefixes, (
+        f"no matching send/recv CSV pair in {output_path}: "
+        f"{os.listdir(output_path)}"
+    )
+    prefix = common_prefixes[0]
+    send_file = os.path.join(output_path, send_files[prefix])
+    recv_file = os.path.join(output_path, recv_files[prefix])
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/integration/defs/disaggregated/test_disaggregated.py` around lines 1573
- 1580, Update the file-selection logic near the send_file and recv_file
assignments to pair files by their shared <instanceId>_<rank> prefix. Derive
prefixes from send_files and recv_files, require at least one prefix present in
both sets, and select the send and receive filenames from the same common prefix
instead of independently choosing index zero.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@tests/integration/defs/disaggregated/test_disaggregated.py`:
- Around line 1573-1580: Update the file-selection logic near the send_file and
recv_file assignments to pair files by their shared <instanceId>_<rank> prefix.
Derive prefixes from send_files and recv_files, require at least one prefix
present in both sets, and select the send and receive filenames from the same
common prefix instead of independently choosing index zero.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 481cddc7-3577-4c1c-8819-184f0f236c2e

📥 Commits

Reviewing files that changed from the base of the PR and between df03c3a and 763bec4.

📒 Files selected for processing (4)
  • tensorrt_llm/_torch/models/modeling_gemma3.py
  • tensorrt_llm/_torch/models/modeling_llama.py
  • tests/integration/defs/disaggregated/test_disaggregated.py
  • tests/unittest/llmapi/test_llm_args.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • tensorrt_llm/_torch/models/modeling_gemma3.py
  • tensorrt_llm/_torch/models/modeling_llama.py
  • tests/unittest/llmapi/test_llm_args.py

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61614 [ run ] triggered by Bot. Commit: 763bec4 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61614 [ run ] completed with state FAILURE. Commit: 763bec4
/LLM/main/L0_MergeRequest_PR pipeline #49821 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

moraxu added 4 commits July 26, 2026 22:31
Signed-off-by: Michal Guzek <mguzek@nvidia.com>
Signed-off-by: Michal Guzek <mguzek@nvidia.com>
Signed-off-by: Michal Guzek <mguzek@nvidia.com>
Signed-off-by: Michal Guzek <mguzek@nvidia.com>
@moraxu
moraxu force-pushed the dev-mguzek-use-transceiver-v2-for-llama-and-gemma branch from 763bec4 to 8b0a39a Compare July 27, 2026 05:31
@moraxu

moraxu commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61818 [ run ] triggered by Bot. Commit: 8b0a39a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61818 [ run ] completed with state FAILURE. Commit: 8b0a39a
/LLM/main/L0_MergeRequest_PR pipeline #50012 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@moraxu

moraxu commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61961 [ run ] triggered by Bot. Commit: 8b0a39a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61961 [ run ] completed with state FAILURE. Commit: 8b0a39a
/LLM/main/L0_MergeRequest_PR pipeline #50149 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@moraxu

moraxu commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61973 [ run ] triggered by Bot. Commit: 8b0a39a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61973 [ run ] completed with state FAILURE. Commit: 8b0a39a
/LLM/main/L0_MergeRequest_PR pipeline #50162 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@moraxu

moraxu commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62014 [ run ] triggered by Bot. Commit: 8b0a39a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62014 [ run ] completed with state FAILURE. Commit: 8b0a39a
/LLM/main/L0_MergeRequest_PR pipeline #50200 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@moraxu

moraxu commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62102 [ run ] triggered by Bot. Commit: 8b0a39a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62102 [ run ] completed with state SUCCESS. Commit: 8b0a39a
/LLM/main/L0_MergeRequest_PR pipeline #50284 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

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.

5 participants