Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
f8c8e35
[None][feat] Add DynamicEPLB kernels and runtime integration
JintaoPengCS Oct 13, 2026
e7b385b
[None][fix] Address per-layer dynamic EPLB review feedback
JintaoPengCS Oct 16, 2026
436ff4d
[None][fix] Accept per-layer dynamic EPLB in the serve config schemas
JintaoPengCS Oct 16, 2026
243e3d9
[None][chore] Update vendored cutedsl_megamoe to bangyus main 7832a330
JintaoPengCS Oct 18, 2026
a720fd6
[None][chore] Drop the internal-GitLab MegaMoE vendor lock entries
JintaoPengCS Oct 19, 2026
e6d7424
[None][chore] Follow the cute_dsl_kernels split on main
JintaoPengCS Oct 20, 2026
e2aeb36
[None][chore] Sync the in-tree cutedsl_megamoe copy to upstream f0747157
JintaoPengCS Oct 20, 2026
5029fce
[None][fix] Point the live-plane ABI contract test at moe/kernels
JintaoPengCS Oct 20, 2026
e0f022c
[None][perf] Cut per-layer host overhead of MoE rebalance and MegaMoE…
JintaoPengCS Oct 20, 2026
793deae
[None][feat] Add ENABLE_PERFECT_ROUTER=expert_ids to bound the MoE lo…
JintaoPengCS Oct 20, 2026
0244834
[None][feat] Layer-wise benchmarks: MoE load balancer and mid-model D…
JintaoPengCS Oct 20, 2026
64a085a
[None][perf] Fuse HALO-Q and the in-switch TMA copy into one kernel
JintaoPengCS Oct 20, 2026
a3cb21a
[None][perf] Keep helper experts resident across forwards in per-laye…
JintaoPengCS Oct 20, 2026
3974b66
[None][test] Stub the raw stream switch in the fused-submit contract …
JintaoPengCS Oct 20, 2026
000bd49
[None][doc] Describe both helper-slot modes in the per-layer dynamic …
JintaoPengCS Oct 20, 2026
4b35aae
[None][fix] Size the perfect-router expert-id table once and warn whe…
JintaoPengCS Oct 20, 2026
db17eb6
[None][fix] Layer-wise benchmarks: reject unsupported load-balancer a…
JintaoPengCS Oct 20, 2026
b84467a
[None][fix] Give the HALO-Q scheduler the MoE communication warmup ti…
JintaoPengCS Oct 20, 2026
4e58aa5
[None][chore] Align a copyright header and remove history narration f…
JintaoPengCS Oct 20, 2026
1e6faeb
[None][chore] Describe the dynamic EPLB kernels as they stand and dro…
JintaoPengCS Oct 20, 2026
8145dfe
[None][test] Run the HALO-Q spin-bound test without a GPU
JintaoPengCS Oct 20, 2026
9e6f24e
[None][perf] Keep dynamic EPLB routes alive without an allocator stre…
JintaoPengCS Oct 20, 2026
048117c
[None][perf] Check the bound EPLB reuse authority by identity per layer
JintaoPengCS Oct 20, 2026
7f77973
[None][perf] Reuse MegaMoE launch buffers and their cute views across…
JintaoPengCS Oct 20, 2026
9b5da41
[None][perf] Skip no-op slices, splits and casts in the fused-comm Mo…
JintaoPengCS Oct 20, 2026
000a325
[None][perf] Reuse autotune-opted MegaMoE runners outside tuning mode
JintaoPengCS Oct 20, 2026
fd8a75b
[None][perf] Refuse new dynamic EPLB plans while launched routes are …
JintaoPengCS Oct 20, 2026
bc45882
[None][perf] Use the fused shared-expert kernel on the whole SM100 fa…
JintaoPengCS Oct 20, 2026
68351f9
[None][perf] Keep DeepSeek-V4's shared-expert kernel independent of EPLB
JintaoPengCS Oct 20, 2026
f29e65f
[None][fix] Round the fused shared-expert block scales to UE8M0 at lo…
JintaoPengCS Oct 20, 2026
98ba9e0
[None][perf] Default per-layer dynamic EPLB to four auxiliary SMs
JintaoPengCS Oct 21, 2026
81cfeef
[None][chore] Remove the standalone HALO-Q kernel; keep only the fuse…
JintaoPengCS Oct 21, 2026
21aced3
[None][test] Follow main's executor API changes in the dynamic EPLB c…
JintaoPengCS Oct 23, 2026
325dbde
[None][refactor] Move per-layer dynamic EPLB into its own package nex…
JintaoPengCS Oct 23, 2026
2dd2fb8
[None][refactor] Drive per-layer dynamic EPLB through the existing lo…
JintaoPengCS Oct 23, 2026
84b360e
[None][refactor] Keep per-layer dynamic EPLB state out of the MegaMoE…
JintaoPengCS Oct 23, 2026
e42a2d1
[None][test] Follow main's engine warmup and release API in the dynam…
JintaoPengCS Oct 24, 2026
82a5661
[None][perf] Submit per-layer dynamic EPLB with one native call per l…
JintaoPengCS Oct 25, 2026
58a0d50
[None][perf] Validate shared FC12 weights once per weight set
JintaoPengCS Oct 25, 2026
4d400e4
[None][fix] Raise the HALO-Q serving spin bound
JintaoPengCS Oct 26, 2026
0749cfd
[None][fix] Limit collective executor shutdown to per-layer dynamic EPLB
JintaoPengCS Oct 26, 2026
0e90f70
[None][fix] Keep standard EPLB's finalizer shutdown and check launch …
JintaoPengCS Oct 26, 2026
98030d6
[None][fix] Keep MegaMoE per-expert scalar defaults when binding the …
JintaoPengCS Oct 26, 2026
2d4c3bc
[None][doc] State which draft MoE layers per-layer dynamic EPLB balances
JintaoPengCS Oct 26, 2026
aa4d155
[None][perf] Skip no-op hooks and repeated checks on the per-layer dy…
JintaoPengCS Oct 27, 2026
48d5906
[None][perf] Let the next fused launch order COPY after the per-layer…
JintaoPengCS Oct 27, 2026
cbe3715
[None][perf] Return the launched generation from the per-layer EPLB s…
JintaoPengCS Oct 27, 2026
03d175e
[None][perf] Reuse the lent route view and the MegaMoE tuning op name
JintaoPengCS Oct 27, 2026
92fa326
[None][perf] Cut per-request host overhead on rank 0
JintaoPengCS Oct 27, 2026
8da098c
[None][test] Follow main's executor changes in the dynamic EPLB contr…
JintaoPengCS Oct 27, 2026
770ffd3
[None][chore] Sync the in-tree CuTe DSL MegaMoE kernels with upstream…
JintaoPengCS Oct 28, 2026
7ec3346
[None][perf] Run HALO-Q as one general fused kernel
JintaoPengCS Oct 28, 2026
5f26257
[None][chore] Drop the trtllm-bench GC switch and the duplicate ruff …
JintaoPengCS Oct 29, 2026
0f05d05
[None][test] Give the chunked-forward MoE test mock the perfect-route…
JintaoPengCS Oct 29, 2026
1ea4fa8
[None][fix] Default DeepseekV4MoE's per-layer dynamic EPLB flag on th…
JintaoPengCS Oct 29, 2026
98975b4
[None][fix] Collect garbage before forking postprocess workers
JintaoPengCS Oct 29, 2026
62dc79a
[None][fix] Keep ModelEngine.cleanup rank-local by default
JintaoPengCS Oct 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,7 @@ legacy-files: &legacy_files |
# list; the hook's own `files:` pattern only gates *when* the hook triggers.

# Global exclude: vendored code + trtllm-gen FMHA artifacts (cubin pointers, export headers, cuda_ptx)
exclude: '(^tensorrt_llm/_torch/attention/kernels/blackwell/kimi_k3_kda/kda_chunked_bt16(_small_bh)?\.py$|^cpp/tensorrt_llm/common/sha256/|^triton_kernels/|^tensorrt_llm/_torch/attention/backends/prims_ts/|^tensorrt_llm/_torch/visual_gen/cute_dsl_kernels/blackwell/sol_attn/|trtllmGenKernels/fmha/cubin/kernelMetaInfo\.h$|cubin\.cpp$|cubin\.h$|trtllmGenKernels/fmha/trtllmGen_fmha_export/|trtllmGenKernels/fmha/cuda_ptx/|trtllmGenKernels/batchedGemm/trtllmGen_bmm_export/KernelMetaInfo\.h$|trtllmGenKernels/gemm/trtllmGen_gemm_export/KernelMetaInfo\.h$|\.cubin\.tar\.zst$)'
exclude: '(^tensorrt_llm/_torch/attention/kernels/blackwell/kimi_k3_kda/kda_chunked_bt16(_small_bh)?\.py$|^cpp/tensorrt_llm/common/sha256/|^triton_kernels/|^tensorrt_llm/_torch/attention/backends/prims_ts/|^tensorrt_llm/_torch/visual_gen/cute_dsl_kernels/blackwell/sol_attn/|^tensorrt_llm/_torch/moe/kernels/cutedsl_megamoe/|^tensorrt_llm/_torch/moe/kernels/megamoe_scheduler/|trtllmGenKernels/fmha/cubin/kernelMetaInfo\.h$|cubin\.cpp$|cubin\.h$|trtllmGenKernels/fmha/trtllmGen_fmha_export/|trtllmGenKernels/fmha/cuda_ptx/|trtllmGenKernels/batchedGemm/trtllmGen_bmm_export/KernelMetaInfo\.h$|trtllmGenKernels/gemm/trtllmGen_gemm_export/KernelMetaInfo\.h$|\.cubin\.tar\.zst$)'

default_install_hook_types: [pre-commit, commit-msg]
repos:
Expand Down
5 changes: 4 additions & 1 deletion cpp/tensorrt_llm/kernels/moe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# into kernels_src, exactly as it did before the move.
add_subdirectory(cuteDsl) # cute_dsl_src
add_subdirectory(trtllmGen) # trtllm_gen_fp8_block_scale_moe{,_routing}
add_subdirectory(loadBalance/dynamicEplb) # moe_dynamic_eplb_src
# cutlass/: moe_gemm_src and its per-arch OBJECT libraries are defined in
# ../cutlass_kernels/CMakeLists.txt, next to the CUTLASS instantiation generator
# they depend on.
Expand All @@ -28,7 +29,9 @@ add_subdirectory(trtllmGen) # trtllm_gen_fp8_block_scale_moe{,_routing}
# kernels_src, so the backend directories are named here, next to the
# add_subdirectory() calls they correspond to, and nowhere else.
file(GLOB_RECURSE MOE_SRC *.cpp *.cu)
list(FILTER MOE_SRC EXCLUDE REGEX "/kernels/moe/(cutlass|trtllmGen|cuteDsl)/.*")
list(FILTER MOE_SRC EXCLUDE REGEX
"/kernels/moe/(cutlass|trtllmGen|cuteDsl|loadBalance/dynamicEplb)/.*")
list(APPEND MOE_SRC $<TARGET_OBJECTS:moe_dynamic_eplb_src>)
set(MOE_KERNELS_SRC
${MOE_SRC}
PARENT_SCOPE)
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# 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.

set(DYNAMIC_EPLB_ARCHS)
foreach(ARCH 100 103 107)
if("${ARCH}" IN_LIST CMAKE_CUDA_ARCHITECTURES_ORIG)
list(APPEND DYNAMIC_EPLB_ARCHS ${ARCH})
endif()
endforeach()

set(DYNAMIC_EPLB_SOURCES)
set(DYNAMIC_EPLB_DEFINITIONS)

if(DYNAMIC_EPLB_ARCHS)
list(APPEND DYNAMIC_EPLB_SOURCES moeRebalanceHaloQ.cu)
else()
list(APPEND DYNAMIC_EPLB_SOURCES moeRebalancePlaceholder.cpp)
list(APPEND DYNAMIC_EPLB_DEFINITIONS TRTLLM_DYNAMIC_EPLB_PLACEHOLDER_HALO_Q)
message(
STATUS
"Per-layer dynamic EPLB HALO-Q disabled: none of SM100, SM103, or SM107 was requested"
)
endif()

if(DYNAMIC_EPLB_ARCHS AND CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL
13.1)
list(APPEND DYNAMIC_EPLB_SOURCES moeRebalanceTma.cu)
else()
list(APPEND DYNAMIC_EPLB_SOURCES moeRebalancePlaceholder.cpp)
list(APPEND DYNAMIC_EPLB_DEFINITIONS TRTLLM_DYNAMIC_EPLB_PLACEHOLDER_TMA)
if(CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 13.1)
message(
STATUS
"Per-layer dynamic EPLB TMA disabled: CUDA 13.1 or newer is required (found ${CMAKE_CUDA_COMPILER_VERSION})"
)
else()
message(
STATUS
"Per-layer dynamic EPLB TMA disabled: none of SM100, SM103, or SM107 was requested"
)
endif()
endif()

list(REMOVE_DUPLICATES DYNAMIC_EPLB_SOURCES)
add_library(moe_dynamic_eplb_src OBJECT ${DYNAMIC_EPLB_SOURCES})

if(DYNAMIC_EPLB_ARCHS)
# These kernels use SM100-family PTX. The family target avoids inheriting the
# generic kernels_src SM80/SM90 compilation passes.
set_cuda_architectures(moe_dynamic_eplb_src 100f)
endif()

if(DYNAMIC_EPLB_DEFINITIONS)
target_compile_definitions(moe_dynamic_eplb_src
PRIVATE ${DYNAMIC_EPLB_DEFINITIONS})
endif()

set_property(TARGET moe_dynamic_eplb_src PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET moe_dynamic_eplb_src PROPERTY CUDA_RESOLVE_DEVICE_SYMBOLS
ON)
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved.
*
* 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.
*/

#include "tensorrt_llm/common/assert.h"
#include "tensorrt_llm/kernels/moe/loadBalance/dynamicEplb/moeRebalanceHaloQ.h"
#include "tensorrt_llm/kernels/moe/loadBalance/dynamicEplb/moeRebalanceHaloQKernel.cuh"

#include <climits>

TRTLLM_NAMESPACE_BEGIN

namespace kernels
{

void checkMoeRebalanceHaloQParams(MoeRebalanceHaloQParams const& params)
{
TLLM_CHECK_WITH_INFO((params.routes != nullptr || params.validRouteCount == 0) && params.outSlots != nullptr
&& params.outIds != nullptr && params.outLevels != nullptr && params.outOwners != nullptr
&& params.peerBases != nullptr && params.status != nullptr && params.partial != nullptr
&& params.routeAux != nullptr && params.gridSync != nullptr && params.planWorkspace != nullptr
&& params.routePrefix != nullptr && params.ep >= 2 && params.ep <= kMaxEp && params.ep % 2 == 0
&& params.experts > 0 && params.experts <= kMaxExperts && params.experts % params.ep == 0
&& params.helpers > 0 && params.helpers <= INT_MAX / params.ep - params.experts / params.ep
&& params.localRank >= 0 && params.localRank < params.ep && params.validRouteCount >= 0
&& params.validRouteCount <= params.routeCapacity && params.routeCapacity > 0
&& params.routeCapacity <= INT_MAX / params.ep && params.routeCapacity <= INT_MAX - params.ctas
&& params.ctas > 0 && params.ctas <= 128 && params.threads == 512,
"Invalid HALO-Q scheduler launch parameters");
}

} // namespace kernels

TRTLLM_NAMESPACE_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved.
*
* 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.
*/

#ifndef TRTLLM_KERNELS_MOE_REBALANCE_HALO_Q_H
#define TRTLLM_KERNELS_MOE_REBALANCE_HALO_Q_H

#include "tensorrt_llm/common/config.h"

#include <cstdint>

TRTLLM_NAMESPACE_BEGIN

namespace kernels
{

// The HALO-Q scheduler phase of the fused scheduler + in-switch copy kernel
// (megamoe_tma_copy_submit_fused).
struct MoeRebalanceHaloQParams
{
int const* routes;
int* outSlots;
int* outIds;
int* outLevels;
int* outOwners;
std::uint64_t const* peerBases;
int* status;
int* partial;
int* routeAux;
int* gridSync;
int* planWorkspace;
int* routePrefix;
int ep;
int experts;
int helpers;
int localRank;
int routeCapacity;
int ctas;
int threads;
std::uint64_t spinCycles;
int validRouteCount;
};

// Throws unless params describe a valid scheduler launch.
void checkMoeRebalanceHaloQParams(MoeRebalanceHaloQParams const& params);

} // namespace kernels

TRTLLM_NAMESPACE_END

#endif // TRTLLM_KERNELS_MOE_REBALANCE_HALO_Q_H
Loading
Loading