Repository navigation
[None][feat] Dense DWDP for Kimi-K3 context servers and a balanced DWDP expert partition #21012
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
Open
zongfeijing
wants to merge
9
commits into
NVIDIA:main
Choose a base branch
from
zongfeijing:user/zongfeij/k3-dense-dwdp
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+15,390
−1,288
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d31422b
[None][fix] Bound the context-only server shutdown: drop in-flight re…
zongfeijing fab4f23
[None][feat] Dense DWDP for Kimi-K3 context servers (env form)
zongfeijing a0ad3f2
[None][feat] Dense DWDP without expert DWDP: standalone on attention-…
zongfeijing c7b363d
[None][fix] DWDP: the only executor gets the DwdpManager when KV-cach…
zongfeijing 9bc1d57
[None][fix] DWDP: commit attached dense DWDP before the expert prefet…
zongfeijing b2c698e
[None][fix] DWDP: set attached dense DWDP up before the final KV cach…
zongfeijing 4631f23
[None][chore] Dense DWDP standalone: copy-mode guidance from the DEP1…
zongfeijing a4a3c94
[None][feat] Expert DWDP: a balanced expert partition when dwdp_size …
zongfeijing 0d53826
[None][fix] Release the attention-DP dummy's draft KV mirror when a s…
zongfeijing File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| """Dense DWDP: row-sharded replicated dense weights, gathered two layers ahead of their use. | ||
|
|
||
| Every rank of the dense group keeps one row of each MoE decoder layer's attention blob ``A(l)`` | ||
| and MoE-dense blob ``D(l)``; the runtime gathers ``L(l+2) = A(l+2) + D(l+2)`` into small staging | ||
| slots on a copy stream. It runs in one of two modes (``types.DenseMode``): with expert DWDP | ||
| (attached) the dense group is the DWDP group and the copies share the expert DWDP copy stream; | ||
| standalone, on an attention-DP instance without expert DWDP, the dense group is the attention-DP | ||
| (tp) group and the copies run on the dense manager's own stream. Submodules: | ||
|
|
||
| * ``config`` -- ``TRTLLM_DWDP_DENSE*`` switches. | ||
| * ``types`` -- shared records, layout, slots, copy plans, CUDA seams, constants, errors. | ||
| * ``layout`` -- collector, checks, blob layout, checksums. | ||
| * ``repoint`` -- repointing module tensors into slots, rollback, release check, teardown. | ||
| * ``runtime`` -- ``DenseDWDP``: slot rings, events and the per-layer hooks. | ||
| * ``plan`` -- per-layer copy plans and their launcher. | ||
| * ``store`` -- the sharded row store (FABRIC and in-process loopback). | ||
| * ``watchdog`` -- the slot checksum watchdog of ``TRTLLM_DWDP_DENSE_DEBUG=2``. | ||
| * ``setup`` -- setup phases P1-P6 over five fixed collectives. | ||
| * ``manager`` -- ``DenseDwdpManager``: owns the committed runtime in both modes, primes it (H0) | ||
| and is what the model's hooks find through ``get_global_dense_dwdp_manager``; standalone it | ||
| also builds the group and the transfer and runs setup. | ||
| * ``gate`` -- the launch gate ``py_executor_creator`` runs before the model is built; it picks | ||
| the mode. | ||
|
|
||
| Import the submodules directly; this package imports none of them. | ||
| """ |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Script executed:
rg -n 'collect_dense_layout|DWDP_DENSE_ATTR_ALLOW|DWDP_DENSE_EXCLUDE|_DENSE_DWDP_MOE_ROOTS' tensorrt_llm/_torch/modules/dwdp/dense tensorrt_llm/_torch/models/modeling_kimi_linear.py tests/unittest/_torch/modules/dwdp/test_dense_kimi_hooks.pyRepository: NVIDIA/TensorRT-LLM
Length of output: 1968
Script executed:
Repository: NVIDIA/TensorRT-LLM
Length of output: 27351
Assert the collected bindings, not only root selection.
The current Kimi fixture contains a non-MoE KDA layer, a KDA MoE layer, and an MLA MoE layer, but its test only checks hook behavior. Add a layout case that passes these actual layers to
collect_dense_layout.Assert the exact expected binding or anchor-path set for the KDA and MLA MoE layers. Include the expected attention and five MoE-dense roots and their allowed attributes. The exact-set assertion must exclude
routed_experts. Also assert that the non-MoE layer has no dense-layout entries. This detects an omitted root, an omittedDWDP_DENSE_ATTR_ALLOWentry, incorrect routed-expert selection, and incorrect non-MoE selection.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.
Added
test_the_collector_moves_every_root_tensor_of_the_moe_layers_and_nothing_elsetotest_dense_kimi_hooks.pyin 10ef5eb. It uses the file's real model:post_load_weightson eachLinear, plus the fused KDA projections and decode constants thatfinalize_decode_weightsbuilds on GPU.collect_dense_layoutover all layers in strict mode with a 1-byte threshold. Only the three MoE layers are covered, so the dense-MLP layer 0 has no entries._DENSE_DWDP_MOE_ROOTS, sorouted_expertsis never a root.DWDP_DENSE_ATTR_ALLOWattribute under those roots thatDWDP_DENSE_EXCLUDEdoes not name, plus their aliases. This catches an omitted root and the routing-bias exclusion._A_log_f32fromDWDP_DENSE_ATTR_ALLOWmakes the test fail.