Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c4e514a
build: link whole-archive components in a foreach loop
Funatiq Oct 23, 2026
953aff3
build: extract profiler configuration utilities into a common component
Funatiq Oct 6, 2026
b3f4c41
build: extract the runtime worker pool and migrate its unit test
Funatiq Oct 6, 2026
15e8e78
build: extract NumPy tensor I/O into a runtime component
Funatiq Oct 26, 2026
6fd2adb
build: extract the GDRCopy runtime wrapper and migrate its test
Funatiq Oct 6, 2026
58e629b
build: extract runtime locality-domain support and migrate its test
Funatiq Oct 6, 2026
1281e73
build: make the IPC/NVLS memory archive component-local
Funatiq Oct 6, 2026
3e11e8a
build: decouple Torch utilities from the inference shared library
Funatiq Oct 6, 2026
08f8322
build: extract host-only transfer agent identity generation
Funatiq Oct 6, 2026
08f5a11
build: extract host context-transfer consensus from the MPI coordinator
Funatiq Oct 6, 2026
1775766
build: extract LoRA modules and request validation into a runtime com…
Funatiq Oct 6, 2026
c8c0b6a
build: extract LoRA cache storage and migrate its unit test
Funatiq Oct 6, 2026
00473d5
build: extract runtime utilities needed by component-local PEFT tests
Funatiq Oct 6, 2026
f5db879
build: extract PEFT cache management and migrate its unit test
Funatiq Oct 6, 2026
be4ebba
build: migrate host-accessible device allocator tests to a runtime co…
Funatiq Oct 6, 2026
217c579
fix: reuse runtime topology in host-accessible memory component
Funatiq Oct 26, 2026
3e5ce2c
build: make executor serialization utility tests component-local
Funatiq Oct 6, 2026
fd0752a
build: migrate user-buffer tests to a focused static kernel component
Funatiq Oct 6, 2026
eae75fc
fixup! build: decouple Torch utilities from the inference shared library
Funatiq Nov 2, 2026
d1540b5
refactor: share facade component targets in CMake
Funatiq Nov 4, 2026
3a2cc51
docs: explain Torch utility C++20 requirement
Funatiq Nov 4, 2026
7269ada
docs: clarify Torch utility consumer link requirements
Funatiq Nov 4, 2026
656325d
build: sort facade component targets lexicographically
Funatiq Nov 4, 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
81 changes: 43 additions & 38 deletions cpp/tensorrt_llm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,6 @@ endif()
find_package(Threads REQUIRED)
add_subdirectory(common)

add_library(ipc_nvls_memory_src STATIC runtime/ipcNvlsMemory.cu)
set_target_properties(
ipc_nvls_memory_src PROPERTIES POSITION_INDEPENDENT_CODE ON
CUDA_RESOLVE_DEVICE_SYMBOLS ON)

add_subdirectory(kernels)
add_subdirectory(runtime)

Expand Down Expand Up @@ -254,7 +249,6 @@ set(TRTLLM_LINK_LIBS
compressorKernels_src
fusedSamplingKernels_src
mhcKernels_src
userbuffers_src
${DECODER_SHARED_TARGET_0}
${DECODER_SHARED_TARGET_1})
if(USING_OSS_CUTLASS_LOW_LATENCY_GEMM)
Expand Down Expand Up @@ -318,15 +312,48 @@ endif()

target_link_libraries(${SHARED_TARGET} PUBLIC ${TRTLLM_LINK_LIBS})

target_link_libraries(
${SHARED_TARGET}
PRIVATE
$<LINK_LIBRARY:WHOLE_ARCHIVE,tllm_common_error,tllm_common_logging,tllm_common_cuda,tllm_executor_types,tllm_executor_serialization,tllm_runtime_memory,tllm_runtime_buffers,tllm_runtime_distributed,tllm_runtime_topology>
$<LINK_LIBRARY:WHOLE_ARCHIVE,tllm_common_environment,tllm_executor_values,tllm_executor_transfer_agent,tllm_kv_cache_host_memory,tllm_kv_cache,tllm_kv_cache_legacy,tllm_batch_scheduler,tllm_kernel_kv_cache_copy>
$<LINK_LIBRARY:WHOLE_ARCHIVE,${BATCH_MANAGER_TARGET}>
$<LINK_LIBRARY:WHOLE_ARCHIVE,${EXECUTOR_TARGET}>
$<LINK_LIBRARY:WHOLE_ARCHIVE,fp8_blockscale_gemm_src>
$<LINK_LIBRARY:WHOLE_ARCHIVE,${INTERNAL_CUTLASS_KERNELS_TARGET}>)
set(TLLM_FACADE_COMPONENT_TARGETS
ipc_nvls_memory_src
tllm_batch_request_info
tllm_batch_scheduler
tllm_common_cuda
tllm_common_environment
tllm_common_error
tllm_common_logging
tllm_common_profiler
tllm_context_transfer_consensus
tllm_executor_agent_name
tllm_executor_memory_desc
tllm_executor_serialization
tllm_executor_transfer_agent
tllm_executor_types
tllm_executor_values
tllm_kernel_kv_cache_copy
tllm_kv_cache
tllm_kv_cache_host_memory
tllm_kv_cache_legacy
tllm_peft_cache
tllm_runtime_buffers
tllm_runtime_distributed
tllm_runtime_gdr
tllm_runtime_host_accessible_memory
tllm_runtime_locality
tllm_runtime_lora
tllm_runtime_lora_cache
tllm_runtime_memory
tllm_runtime_numpy
tllm_runtime_topology
tllm_runtime_utils
tllm_runtime_worker_pool
userbuffers_src)

foreach(
Comment thread
Funatiq marked this conversation as resolved.
Resolved
component
${TLLM_FACADE_COMPONENT_TARGETS} ${BATCH_MANAGER_TARGET} ${EXECUTOR_TARGET}
fp8_blockscale_gemm_src ${INTERNAL_CUTLASS_KERNELS_TARGET})
target_link_libraries(${SHARED_TARGET}
PRIVATE $<LINK_LIBRARY:WHOLE_ARCHIVE,${component}>)
endforeach()

foreach(component IN LISTS TLLM_KERNEL_COMPONENT_TARGETS)
target_link_libraries(${SHARED_TARGET}
Expand All @@ -336,29 +363,7 @@ foreach(component IN LISTS TLLM_KERNEL_COMPONENT_TARGETS)
endforeach()

# Components also link each other normally; retain all component exports here.
set_property(TARGET ${SHARED_TARGET}
PROPERTY LINK_LIBRARY_OVERRIDE_tllm_common_error WHOLE_ARCHIVE)
set_property(TARGET ${SHARED_TARGET}
PROPERTY LINK_LIBRARY_OVERRIDE_tllm_common_logging WHOLE_ARCHIVE)
set_property(TARGET ${SHARED_TARGET}
PROPERTY LINK_LIBRARY_OVERRIDE_tllm_executor_types WHOLE_ARCHIVE)

foreach(
component
tllm_common_cuda
tllm_runtime_memory
tllm_runtime_buffers
tllm_runtime_distributed
tllm_runtime_topology
tllm_executor_serialization
tllm_common_environment
tllm_executor_values
tllm_executor_transfer_agent
tllm_kv_cache_host_memory
tllm_kv_cache
tllm_kv_cache_legacy
tllm_batch_scheduler
tllm_kernel_kv_cache_copy)
foreach(component IN LISTS TLLM_FACADE_COMPONENT_TARGETS)
set_property(TARGET ${SHARED_TARGET}
PROPERTY LINK_LIBRARY_OVERRIDE_${component} WHOLE_ARCHIVE)
endforeach()
Expand Down
39 changes: 36 additions & 3 deletions cpp/tensorrt_llm/batch_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ set(SRCS
kvCacheManagerV2Utils.cpp
kvCacheManagerV2Utils.cu
mlaCacheFormatter.cpp
peftCacheManager.cpp
rnnCacheFormatter.cpp
rnnCacheTransBuffer.cpp)

Expand Down Expand Up @@ -117,6 +116,38 @@ target_link_libraries(tllm_batch_scheduler PUBLIC tllm::kv_cache_legacy)
target_include_directories(tllm_batch_scheduler
PRIVATE ${maybe_nvtx_includedir})

add_library(tllm_context_transfer_consensus STATIC
contextTransferVoteReducer.cpp)
add_library(tllm::context_transfer_consensus ALIAS
tllm_context_transfer_consensus)
target_link_libraries(tllm_context_transfer_consensus PUBLIC tllm::common_error)
target_compile_features(tllm_context_transfer_consensus PUBLIC cxx_std_20)
set_target_properties(
tllm_context_transfer_consensus PROPERTIES CXX_EXTENSIONS OFF
POSITION_INDEPENDENT_CODE ON)

add_library(tllm_batch_request_info STATIC requestInfo.cpp)
add_library(tllm::batch_request_info ALIAS tllm_batch_request_info)
target_link_libraries(
tllm_batch_request_info
PUBLIC tllm::kv_cache_legacy
PRIVATE ${Python3_LIBRARIES})
target_compile_features(tllm_batch_request_info PUBLIC cxx_std_20)
set_target_properties(
tllm_batch_request_info PROPERTIES CXX_EXTENSIONS OFF
POSITION_INDEPENDENT_CODE ON)

add_library(tllm_peft_cache STATIC peftCacheManager.cpp)
add_library(tllm::peft_cache ALIAS tllm_peft_cache)
target_link_libraries(
tllm_peft_cache
PUBLIC tllm::runtime_lora_cache tllm::kv_cache_legacy
tllm::runtime_worker_pool
PRIVATE tllm::runtime_numpy tllm::runtime_utils)
target_compile_features(tllm_peft_cache PUBLIC cxx_std_20)
set_target_properties(tllm_peft_cache PROPERTIES CXX_EXTENSIONS OFF
POSITION_INDEPENDENT_CODE ON)

foreach(component tllm_kv_cache_host_memory tllm_kv_cache tllm_kv_cache_legacy
tllm_batch_scheduler)
target_compile_features(${component} PUBLIC cxx_std_20)
Expand All @@ -129,8 +160,10 @@ target_compile_options(
add_cuda_architectures(tllm_kv_cache 89)

add_library(${BATCH_MANAGER_STATIC_TARGET} STATIC ${SRCS})
target_link_libraries(${BATCH_MANAGER_STATIC_TARGET}
PUBLIC tllm::kv_cache tllm::batch_scheduler)
target_link_libraries(
${BATCH_MANAGER_STATIC_TARGET}
PUBLIC tllm::kv_cache tllm::batch_scheduler tllm::context_transfer_consensus
tllm::peft_cache tllm::batch_request_info)
target_include_directories(
${BATCH_MANAGER_STATIC_TARGET}
PUBLIC ${KV_CACHE_MANAGER_V2_INCLUDE_DIR}
Expand Down
73 changes: 0 additions & 73 deletions cpp/tensorrt_llm/batch_manager/contextTransferCoordinator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,79 +32,6 @@
namespace tensorrt_llm::batch_manager
{

ContextTransferVoteReducer::ContextTransferVoteReducer(int const participantCount)
: mParticipantCount(participantCount)
{
TLLM_CHECK_WITH_INFO(participantCount > 0, "Context-transfer consensus requires at least one participant.");
}

void ContextTransferVoteReducer::recordVote(
int const participantRank, std::uint64_t const requestId, ContextTransferVote const vote)
{
TLLM_CHECK_WITH_INFO(participantRank >= 0 && participantRank < mParticipantCount,
"Context-transfer consensus participant rank is out of range.");
TLLM_CHECK_WITH_INFO(vote == ContextTransferVote::kCompleted || vote == ContextTransferVote::kFailed,
"Context-transfer consensus received an invalid vote.");

auto [requestIt, inserted] = mRequestVotes.try_emplace(requestId, mParticipantCount);
static_cast<void>(inserted);
auto& requestVotes = requestIt->second;
auto& recordedVote = requestVotes.votes.at(static_cast<std::size_t>(participantRank));
auto const packedVote = static_cast<std::uint64_t>(vote);
if (recordedVote != 0)
{
TLLM_CHECK_WITH_INFO(
recordedVote == packedVote, "Context-transfer participant changed its terminal vote for a request.");
return;
}

recordedVote = packedVote;
++requestVotes.terminalCount;
requestVotes.failed = requestVotes.failed || vote == ContextTransferVote::kFailed;
}

void ContextTransferVoteReducer::recordTimeout(std::uint64_t const requestId)
{
auto [requestIt, inserted] = mRequestVotes.try_emplace(requestId, mParticipantCount);
static_cast<void>(inserted);
auto& requestVotes = requestIt->second;
if (!requestVotes.timedOut)
{
requestVotes.timedOut = true;
requestVotes.timeoutPending = true;
}
}

ContextTransferConsensusResult ContextTransferVoteReducer::takeReady()
{
ContextTransferConsensusResult result;
for (auto requestIt = mRequestVotes.begin(); requestIt != mRequestVotes.end();)
{
auto& requestVotes = requestIt->second;
if (requestVotes.timeoutPending)
{
result.timedOutRequestIds.insert(requestIt->first);
requestVotes.timeoutPending = false;
}
if (requestVotes.terminalCount != mParticipantCount)
{
++requestIt;
continue;
}

auto& terminalRequestIds
= (requestVotes.failed || requestVotes.timedOut) ? result.failedRequestIds : result.completedRequestIds;
terminalRequestIds.insert(requestIt->first);
requestIt = mRequestVotes.erase(requestIt);
}
return result;
}

void ContextTransferVoteReducer::clear() noexcept
{
mRequestVotes.clear();
}

class ContextTransferCoordinator::Impl
{
public:
Expand Down
98 changes: 98 additions & 0 deletions cpp/tensorrt_llm/batch_manager/contextTransferVoteReducer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* 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.
*/

#include "tensorrt_llm/batch_manager/contextTransferCoordinator.h"

#include "tensorrt_llm/common/assert.h"

namespace tensorrt_llm::batch_manager
{

ContextTransferVoteReducer::ContextTransferVoteReducer(int const participantCount)
: mParticipantCount(participantCount)
{
TLLM_CHECK_WITH_INFO(participantCount > 0, "Context-transfer consensus requires at least one participant.");
}

void ContextTransferVoteReducer::recordVote(
int const participantRank, std::uint64_t const requestId, ContextTransferVote const vote)
{
TLLM_CHECK_WITH_INFO(participantRank >= 0 && participantRank < mParticipantCount,
"Context-transfer consensus participant rank is out of range.");
TLLM_CHECK_WITH_INFO(vote == ContextTransferVote::kCompleted || vote == ContextTransferVote::kFailed,
"Context-transfer consensus received an invalid vote.");

auto [requestIt, inserted] = mRequestVotes.try_emplace(requestId, mParticipantCount);
static_cast<void>(inserted);
auto& requestVotes = requestIt->second;
auto& recordedVote = requestVotes.votes.at(static_cast<std::size_t>(participantRank));
auto const packedVote = static_cast<std::uint64_t>(vote);
if (recordedVote != 0)
{
TLLM_CHECK_WITH_INFO(
recordedVote == packedVote, "Context-transfer participant changed its terminal vote for a request.");
return;
}

recordedVote = packedVote;
++requestVotes.terminalCount;
requestVotes.failed = requestVotes.failed || vote == ContextTransferVote::kFailed;
}

void ContextTransferVoteReducer::recordTimeout(std::uint64_t const requestId)
{
auto [requestIt, inserted] = mRequestVotes.try_emplace(requestId, mParticipantCount);
static_cast<void>(inserted);
auto& requestVotes = requestIt->second;
if (!requestVotes.timedOut)
{
requestVotes.timedOut = true;
requestVotes.timeoutPending = true;
}
}

ContextTransferConsensusResult ContextTransferVoteReducer::takeReady()
{
ContextTransferConsensusResult result;
for (auto requestIt = mRequestVotes.begin(); requestIt != mRequestVotes.end();)
{
auto& requestVotes = requestIt->second;
if (requestVotes.timeoutPending)
{
result.timedOutRequestIds.insert(requestIt->first);
requestVotes.timeoutPending = false;
}
if (requestVotes.terminalCount != mParticipantCount)
{
++requestIt;
continue;
}

auto& terminalRequestIds
= (requestVotes.failed || requestVotes.timedOut) ? result.failedRequestIds : result.completedRequestIds;
terminalRequestIds.insert(requestIt->first);
requestIt = mRequestVotes.erase(requestIt);
}
return result;
}

void ContextTransferVoteReducer::clear() noexcept
{
mRequestVotes.clear();
}

} // namespace tensorrt_llm::batch_manager
Loading
Loading