Skip to content

[TRTLLM-13948][feat] Set DeepSeekV3 to use Python KV-cache transceiver V2 by default - #16908

Open
asfiyab-nvidia wants to merge 4 commits into
NVIDIA:mainfrom
asfiyab-nvidia:asfiyab/ds-transceiver-v2
Open

[TRTLLM-13948][feat] Set DeepSeekV3 to use Python KV-cache transceiver V2 by default#16908
asfiyab-nvidia wants to merge 4 commits into
NVIDIA:mainfrom
asfiyab-nvidia:asfiyab/ds-transceiver-v2

Conversation

@asfiyab-nvidia

@asfiyab-nvidia asfiyab-nvidia commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Description

Built on top of #16344 and #16669 (per-model transceiver runtime auto selection): opt DeepSeekV3.2/R1/V3-Lite into the Python KV-cache transceiver by default.

DeepseekV32ForCausalLM and DeepseekV3ForCausalLM now overrides get_preferred_transceiver_runtime() to return "PYTHON". Disaggregated deployments that leave transceiver_runtime at its default auto (backend NIXL/DEFAULT) use the Python transceiver (KvCacheTransceiverV2) out of the box. Explicit user settings always take precedence, and incompatible backends fall back to the C++ transceiver per the #16164 resolution semantics. No effect on non-disaggregated deployments.

Additionally set the below configs to use the CPP Transceiver while PR #16834 addresses the perf regression observed during migration of the transceiver from CPP to PYTHON.

gb300_deepseek-r1-fp4_8k1k_con4096_ctx1_dep4_gen1_dep16_eplb0_mtp1_ccb-NIXL.yaml
gb300_deepseek-r1-fp4_128k8k_con256_ctx1_pp4_gen1_dep8_eplb0_mtp1_ccb-NIXL.yaml

Test Coverage

  • Updates the test class TestGlm5TransceiverPreference to TestDeepseekTransceiverPreference
  • Updates the following tests: test_preference_per_architecture
  • Replaces the following tests: test_no_config_defers_to_cpp -> test_prefers_python_without_config and test_glm5_resolves_auto_to_python_on_nixl -> test_deepseek_resolves_auto_to_python_on_nixl

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.

Dev Engineer Review

  • DeepSeek V3, V3.2, and GLM MoE DSA now consistently prefer the Python KV-cache transceiver under automatic runtime selection.
  • Explicit runtime settings remain respected, while incompatible backends can fall back appropriately; non-disaggregated deployments are unaffected.
  • Updated unit tests cover supported architectures, missing configuration, and DeepSeek-on-NIXL resolution.
  • Four DeepSeek R1 disaggregated benchmark configurations explicitly select transceiver_runtime: CPP for both context and generation workers, preserving the intended performance baseline.
  • No apparent API, error-handling, or configuration consistency issues were identified.

QA Engineer Review

  • Modified test code: transceiver preference tests in tests/unittest/llmapi/test_llm_args.py; the suite was renamed/reworked from GLM-5-focused coverage to DeepSeek/GLM coverage.
  • Updated coverage includes:
    • Python runtime preference for supported DeepSeek V3, DeepSeek V3.2, and GLM architectures.
    • Python preference when no pretrained configuration is provided.
    • Automatic DeepSeek-on-NIXL runtime resolution.
  • No tests/integration/test_lists/, test-db/, or qa/ files were modified, so CI/manual test-list coverage is not represented.
  • Reported affected unit tests passed; remaining CI failures were unrelated to this PR.

Verdict: needs follow-up — test-list coverage data is unavailable.

@asfiyab-nvidia
asfiyab-nvidia requested review from a team as code owners July 27, 2026 19:09
@asfiyab-nvidia

Copy link
Copy Markdown
Contributor Author

/bot run --extra-stage "A10-PyTorch-1,A10-PyTorch-2,A10-PyTorch-3"

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

DeepSeekV3 transceiver preference resolution now unconditionally selects the Python runtime. Unit tests cover the updated architectures and NIXL auto-resolution, while four disaggregated benchmark configurations explicitly select the CPP runtime.

Changes

DeepSeek transceiver preference

Layer / File(s) Summary
Unconditional Python preference
tensorrt_llm/_torch/models/modeling_deepseekv3.py
get_preferred_transceiver_runtime now always returns "PYTHON".
Preference resolution tests
tests/unittest/llmapi/test_llm_args.py
Tests now expect Python for supported architectures, missing configurations, and the DeepSeekV3 NIXL auto-resolution path.
Explicit benchmark runtime configurations
tests/scripts/perf*/disaggregated/gb300_deepseek-r1-*.yaml
Generation and context worker cache transceiver configurations now set transceiver_runtime: CPP.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: bowenfu

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Title check ✅ Passed The title is concise, correctly formatted, and summarizes the main change to DeepSeekV3 transceiver defaults.
Description check ✅ Passed The description matches the template and includes clear Description, Test Coverage, and PR Checklist sections.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Fix failing CI checks
🧪 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.

Actionable comments posted: 1

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

1897-1907: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Narrow the override return type and document pretrained_config.
get_preferred_transceiver_runtime() always returns "PYTHON", so Optional[Literal["PYTHON"]] can be Literal["PYTHON"]. Add an Args: entry for pretrained_config to match the hook doc style.

🤖 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_deepseekv3.py` around lines 1897 - 1907,
Update get_preferred_transceiver_runtime to return Literal["PYTHON"] instead of
Optional[Literal["PYTHON"]], and add an Args entry documenting the
pretrained_config parameter in its docstring 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.

Inline comments:
In `@tests/unittest/llmapi/test_llm_args.py`:
- Around line 3407-3429: Update the three test
methods—test_preference_per_architecture, test_prefers_python_without_config,
and test_deepseek_resolves_auto_to_python_on_nixl—to include explicit -> None
return annotations; add the appropriate types for the architectures and
model_type parameters in test_preference_per_architecture.

---

Nitpick comments:
In `@tensorrt_llm/_torch/models/modeling_deepseekv3.py`:
- Around line 1897-1907: Update get_preferred_transceiver_runtime to return
Literal["PYTHON"] instead of Optional[Literal["PYTHON"]], and add an Args entry
documenting the pretrained_config parameter in its docstring while preserving
the existing behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 1d535ade-6c5d-4531-a58f-aa4d096b1032

📥 Commits

Reviewing files that changed from the base of the PR and between 9fe5853 and c1977e1.

📒 Files selected for processing (2)
  • tensorrt_llm/_torch/models/modeling_deepseekv3.py
  • tests/unittest/llmapi/test_llm_args.py

Comment thread tests/unittest/llmapi/test_llm_args.py Outdated
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61983 [ run ] triggered by Bot. Commit: c1977e1 Link to invocation

@asfiyab-nvidia
asfiyab-nvidia marked this pull request as draft July 27, 2026 19:57
@asfiyab-nvidia
asfiyab-nvidia marked this pull request as ready for review July 27, 2026 20:05

@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/unittest/llmapi/test_llm_args.py (1)

3402-3432: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add the new tests to the integration lists. None of test_preference_per_architecture, test_prefers_python_without_config, or test_deepseek_resolves_auto_to_python_on_nixl appears under tests/integration/test_lists/test-db/ or tests/integration/test_lists/qa/, so CI/manual QA won’t pick them up.

🤖 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/unittest/llmapi/test_llm_args.py` around lines 3402 - 3432, Add
test-list entries for test_preference_per_architecture,
test_prefers_python_without_config, and
test_deepseek_resolves_auto_to_python_on_nixl under both
tests/integration/test_lists/test-db/ and tests/integration/test_lists/qa/,
following the existing list syntax and grouping conventions.

Source: Path instructions

🤖 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/unittest/llmapi/test_llm_args.py`:
- Around line 3402-3432: Add test-list entries for
test_preference_per_architecture, test_prefers_python_without_config, and
test_deepseek_resolves_auto_to_python_on_nixl under both
tests/integration/test_lists/test-db/ and tests/integration/test_lists/qa/,
following the existing list syntax and grouping conventions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 4130b30e-6fd2-4789-9624-723e47fa2f75

📥 Commits

Reviewing files that changed from the base of the PR and between c1977e1 and e64161f.

📒 Files selected for processing (1)
  • tests/unittest/llmapi/test_llm_args.py

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61983 [ run ] completed with state SUCCESS. Commit: c1977e1
/LLM/main/L0_MergeRequest_PR pipeline #50172 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

@asfiyab-nvidia

Copy link
Copy Markdown
Contributor Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62029 [ run ] triggered by Bot. Commit: e64161f Link to invocation

pretrained_config, 'model_type', None) == 'glm_moe_dsa'):
return "PYTHON"
return None
return "PYTHON"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This change silently flips two GB300 perf configs that were deliberately reverted to the V1 transceiver. When #16669 migrated the DeepSeek R1/V3.2 disagg perf cases to transceiver_runtime: PYTHON, gb300_deepseek-r1-fp4_128k8k_con256_ctx1_pp4... and gb300_deepseek-r1-fp4_8k1k_con4096_ctx1_dep4... (4 files across tests/scripts/perf-sanity/disaggregated/ and tests/scripts/perf/disaggregated/) were intentionally left unpinned, relying on the then-current "auto → C++" resolution to stay on V1. This PR changes what auto resolves to for DeepSeek, so those 4 configs will silently switch to the V2 path they were reverted away from. If the GB300 issue is not yet resolved, please pin transceiver_runtime: CPP in those 4 files as part of this PR; if it is resolved, please state that in the description.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the catch. Pushed the change and updated the description accordingly

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62029 [ run ] completed with state SUCCESS. Commit: e64161f
/LLM/main/L0_MergeRequest_PR pipeline #50216 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

@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/scripts/perf-sanity/disaggregated/Untitled (1)

1-2: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add the required NVIDIA copyright header.

This new file must include the repository-standard NVIDIA copyright header before the manifest entry.

🤖 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/scripts/perf-sanity/disaggregated/Untitled` around lines 1 - 2, Add the
repository-standard NVIDIA copyright header at the beginning of the new manifest
file, before the existing YAML filename entry.

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.

Outside diff comments:
In `@tests/scripts/perf-sanity/disaggregated/Untitled`:
- Around line 1-2: Add the repository-standard NVIDIA copyright header at the
beginning of the new manifest file, before the existing YAML filename entry.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 5b959064-6798-4834-8abb-ae86193c0b51

📥 Commits

Reviewing files that changed from the base of the PR and between e64161f and eacf2ea.

📒 Files selected for processing (5)
  • tests/scripts/perf-sanity/disaggregated/Untitled
  • tests/scripts/perf-sanity/disaggregated/gb300_deepseek-r1-fp4_128k8k_con256_ctx1_pp4_gen1_dep8_eplb0_mtp1_ccb-NIXL.yaml
  • tests/scripts/perf-sanity/disaggregated/gb300_deepseek-r1-fp4_8k1k_con4096_ctx1_dep4_gen1_dep16_eplb0_mtp1_ccb-NIXL.yaml
  • tests/scripts/perf/disaggregated/gb300_deepseek-r1-fp4_128k8k_con256_ctx1_pp4_gen1_dep8_eplb0_mtp1_ccb-NIXL.yaml
  • tests/scripts/perf/disaggregated/gb300_deepseek-r1-fp4_8k1k_con4096_ctx1_dep4_gen1_dep16_eplb0_mtp1_ccb-NIXL.yaml

@asfiyab-nvidia

Copy link
Copy Markdown
Contributor Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62255 [ run ] triggered by Bot. Commit: f95fc15 Link to invocation

@nv-xtf nv-xtf left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@Shixiaowei02

Copy link
Copy Markdown
Collaborator

Could you please confirm whether the DeepSeek unit tests have been fully replaced? Thanks!

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62255 [ run ] completed with state SUCCESS. Commit: f95fc15
/LLM/main/L0_MergeRequest_PR pipeline #50424 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

@asfiyab-nvidia

Copy link
Copy Markdown
Contributor Author

@asfiyab-nvidia

Copy link
Copy Markdown
Contributor Author

Could you please confirm whether the DeepSeek unit tests have been fully replaced? Thanks!

Here is a link to the replaced tests: https://prod.blsm.nvidia.com/sw-tensorrt-top-1/job/LLM/job/main/job/L0_MergeRequest_PR/50424/testReport/A10-PyTorch-2.unittest.llmapi.test_llm_args/TestDeepseekTransceiverPreference/

@nv-xtf

nv-xtf commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62645 [ run ] triggered by Bot. Commit: f95fc15 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62645 [ run ] completed with state SUCCESS. Commit: f95fc15
/LLM/main/L0_MergeRequest_PR pipeline #50785 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

…er by default

Signed-off-by: Asfiya Baig <asfiyab@nvidia.com>
Signed-off-by: Asfiya Baig <asfiyab@nvidia.com>
…ython transceiver

Signed-off-by: Asfiya Baig <asfiyab@nvidia.com>
Signed-off-by: Asfiya Baig <asfiyab@nvidia.com>
@nv-xtf
nv-xtf force-pushed the asfiyab/ds-transceiver-v2 branch from f95fc15 to ea04c72 Compare July 30, 2026 05:43
@nv-xtf nv-xtf changed the title [[TRTLLM-13948][feat] Set DeepSeekV3 to use Python KV-cache transceiver V2 by default [TRTLLM-13948][feat] Set DeepSeekV3 to use Python KV-cache transceiver V2 by default Jul 30, 2026
@nv-xtf

nv-xtf commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

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

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

1900-1907: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Document pretrained_config in the public docstring.

The rewritten public-interface docstring omits its argument and does not use the required Google-style Args:/Returns: sections. Add those sections while documenting that the preference does not inspect pretrained_config.

Suggested documentation update
         and the backend is NIXL.
+
+        Args:
+            pretrained_config: Loaded Hugging Face configuration, if available.
+                This implementation does not inspect it.
+
+        Returns:
+            The preferred KV-cache transceiver runtime, ``"PYTHON"``.
         """
🤖 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_deepseekv3.py` around lines 1900 - 1907,
The public docstring for the transceiver-preference method must use Google-style
Args and Returns sections. Document the pretrained_config argument and
explicitly state that the preference does not inspect it, while preserving the
existing explanation and "PYTHON" return 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_deepseekv3.py`:
- Around line 1900-1907: The public docstring for the transceiver-preference
method must use Google-style Args and Returns sections. Document the
pretrained_config argument and explicitly state that the preference does not
inspect it, while preserving the existing explanation and "PYTHON" return
behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: f09550f9-391c-4ba8-aa20-7ccf3e2da2a7

📥 Commits

Reviewing files that changed from the base of the PR and between eacf2ea and ea04c72.

📒 Files selected for processing (5)
  • tensorrt_llm/_torch/models/modeling_deepseekv3.py
  • tests/scripts/perf-sanity/disaggregated/gb300_deepseek-r1-fp4_128k8k_con256_ctx1_pp4_gen1_dep8_eplb0_mtp1_ccb-NIXL.yaml
  • tests/scripts/perf-sanity/disaggregated/gb300_deepseek-r1-fp4_8k1k_con4096_ctx1_dep4_gen1_dep16_eplb0_mtp1_ccb-NIXL.yaml
  • tests/scripts/perf/disaggregated/gb300_deepseek-r1-fp4_128k8k_con256_ctx1_pp4_gen1_dep8_eplb0_mtp1_ccb-NIXL.yaml
  • tests/scripts/perf/disaggregated/gb300_deepseek-r1-fp4_8k1k_con4096_ctx1_dep4_gen1_dep16_eplb0_mtp1_ccb-NIXL.yaml

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62713 [ run ] triggered by Bot. Commit: ea04c72 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