Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
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
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ See [CI overview](docs/source/developer-guide/ci-overview.md) for full details.

New C++ unit tests should use `add_tllm_gtest` with explicit `SOURCES`,
`LINK_LIBRARIES`, `OWNER`, and scheduling `LABELS`. Request `FULL_STACK` explicitly
for integration tests and `REQUIRES_GPU` for tests that need a GPU. `google-tests`
for integration tests and include `gpu` in `LABELS` for tests that need a GPU.
CI controls test concurrency through `parallel_run_ctest`. `google-tests`
continues to build all C++ tests; component aggregate targets build migrated tests.

### Advisory semantic review
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations under
# the License.

add_subdirectory(bounce)

# ============================================================================
# NIXL Wrapper Library
# ============================================================================
Expand Down Expand Up @@ -54,37 +56,22 @@ if(NIXL_ROOT)
# CacheTransceiverConfig (agent_bounce_buffer_enable +
# kv_cache_bounce_size_mb, Python (v2) transceiver only).
# ------------------------------------------------------------------------
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(ZMQ libzmq) # optional: bounce is skipped if libzmq is
# absent
endif()
if(ZMQ_FOUND)
target_sources(
if(TARGET tllm_executor_bounce_control)
target_sources(${NIXL_WRAPPER_TARGET} PRIVATE bounce/BounceTransport.cpp)
target_link_libraries(
${NIXL_WRAPPER_TARGET}
PRIVATE bounce/BounceTransferPlan.cpp
bounce/BuddyAllocator.cpp
bounce/CreditScheduler.cpp
bounce/BounceMessage.cpp
bounce/BounceArena.cpp
bounce/ExecPool.cpp
bounce/GatherScatterKernel.cu
bounce/ZmqControlChannel.cpp
bounce/BounceTransport.cpp)
target_include_directories(
${NIXL_WRAPPER_TARGET} PRIVATE ${CMAKE_BINARY_DIR}/_deps/cppzmq-src
${ZMQ_INCLUDE_DIRS})
target_link_libraries(${NIXL_WRAPPER_TARGET} PRIVATE ${ZMQ_LIBRARIES}
${NIXL_BUILD_LIBRARY})
PRIVATE
$<LINK_LIBRARY:WHOLE_ARCHIVE,tllm_executor_bounce_core,tllm_executor_bounce_cuda,tllm_executor_bounce_arena,tllm_executor_bounce_control>
${NIXL_BUILD_LIBRARY})
target_compile_definitions(${NIXL_WRAPPER_TARGET} PRIVATE TLLM_BOUNCE_V2=1)
# The .cu device symbols must resolve into this shared lib.
set_target_properties(${NIXL_WRAPPER_TARGET}
PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON)
message(STATUS "NIXL bounce v2: enabled (libzmq found)")
message(STATUS "NIXL bounce v2: enabled (libzmq and cppzmq found)")
else()
message(
STATUS
"NIXL bounce v2: disabled - libzmq/pkg-config not found; an explicit agent_bounce_buffer_enable opt-in fails at agent construction (on a bounce build, runtime setup failures degrade to standard NIXL with a WARNING)"
"NIXL bounce v2: disabled - libzmq or cppzmq unavailable; an explicit agent_bounce_buffer_enable opt-in fails at agent construction (on a bounce build, runtime setup failures degrade to standard NIXL with a WARNING)"
)
endif()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# 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.

add_library(
tllm_executor_bounce_core STATIC EXCLUDE_FROM_ALL
BuddyAllocator.cpp CreditScheduler.cpp BounceTransferPlan.cpp
BounceMessage.cpp)
add_library(tllm::executor_bounce_core ALIAS tllm_executor_bounce_core)
target_link_libraries(tllm_executor_bounce_core PUBLIC tllm::common_logging
Threads::Threads)
target_compile_features(tllm_executor_bounce_core PUBLIC cxx_std_20)
target_compile_options(tllm_executor_bounce_core PRIVATE -Wno-error)
set_target_properties(tllm_executor_bounce_core
PROPERTIES POSITION_INDEPENDENT_CODE ON)

add_library(tllm_executor_bounce_cuda STATIC EXCLUDE_FROM_ALL
ExecPool.cpp GatherScatterKernel.cu)
add_library(tllm::executor_bounce_cuda ALIAS tllm_executor_bounce_cuda)
target_link_libraries(tllm_executor_bounce_cuda
PUBLIC tllm::executor_bounce_core tllm::common_cuda)
target_compile_features(tllm_executor_bounce_cuda PUBLIC cxx_std_20)
target_compile_options(tllm_executor_bounce_cuda
PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Wno-error>)
set_target_properties(
tllm_executor_bounce_cuda
PROPERTIES POSITION_INDEPENDENT_CODE ON CUDA_STANDARD 20
CUDA_STANDARD_REQUIRED ON CUDA_RESOLVE_DEVICE_SYMBOLS ON)

add_library(tllm_executor_bounce_arena STATIC EXCLUDE_FROM_ALL BounceArena.cpp)
add_library(tllm::executor_bounce_arena ALIAS tllm_executor_bounce_arena)
target_link_libraries(
tllm_executor_bounce_arena
PUBLIC tllm::common_cuda
PRIVATE tllm::kv_cache_legacy)
target_compile_features(tllm_executor_bounce_arena PUBLIC cxx_std_20)
target_compile_options(tllm_executor_bounce_arena PRIVATE -Wno-error)
set_target_properties(tllm_executor_bounce_arena
PROPERTIES POSITION_INDEPENDENT_CODE ON)

find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_check_modules(TLLM_BOUNCE_ZMQ QUIET IMPORTED_TARGET GLOBAL libzmq)
endif()
if(TLLM_BOUNCE_ZMQ_FOUND AND EXISTS ${CMAKE_BINARY_DIR}/_deps/cppzmq-src)
add_library(tllm_executor_bounce_control STATIC EXCLUDE_FROM_ALL
ZmqControlChannel.cpp)
add_library(tllm::executor_bounce_control ALIAS tllm_executor_bounce_control)
target_link_libraries(
tllm_executor_bounce_control PUBLIC tllm::executor_bounce_core
PkgConfig::TLLM_BOUNCE_ZMQ)
target_include_directories(tllm_executor_bounce_control SYSTEM
PUBLIC ${CMAKE_BINARY_DIR}/_deps/cppzmq-src)
target_compile_features(tllm_executor_bounce_control PUBLIC cxx_std_20)
target_compile_options(tllm_executor_bounce_control PRIVATE -Wno-error)
set_target_properties(tllm_executor_bounce_control
PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()
5 changes: 1 addition & 4 deletions cpp/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ foreach(owner common runtime executor batch-manager kernel)
endforeach()

function(add_tllm_gtest test_name)
set(options FULL_STACK NO_GTEST_MAIN REQUIRES_GPU)
set(options FULL_STACK NO_GTEST_MAIN)
set(one_value_args TIMEOUT OWNER)
set(multi_value_args SOURCES LINK_LIBRARIES LABELS)
cmake_parse_arguments(PARSE_ARGV 1 ARG "${options}" "${one_value_args}"
Expand Down Expand Up @@ -82,9 +82,6 @@ function(add_tllm_gtest test_name)
PRIVATE TOP_LEVEL_DIR="${TOP_LEVEL_DIR}")

set(test_properties ENVIRONMENT "CUDA_MODULE_LOADING=LAZY")
if(ARG_REQUIRES_GPU)
list(APPEND test_properties RESOURCE_LOCK gpu)
endif()
if(ARG_TIMEOUT)
list(APPEND test_properties TIMEOUT "${ARG_TIMEOUT}")
endif()
Expand Down
64 changes: 25 additions & 39 deletions cpp/tests/unit_tests/batch_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ add_tllm_gtest(
LINK_LIBRARIES
tllm::kv_cache_legacy
LABELS
"unit;batch-manager;gpu"
REQUIRES_GPU)
"unit;batch-manager;gpu")

add_tllm_gtest(
bufferIndexHolderTest
Expand All @@ -76,8 +75,7 @@ add_tllm_gtest(
LINK_LIBRARIES
tllm::kv_cache_legacy
LABELS
"unit;batch-manager;gpu"
REQUIRES_GPU)
"unit;batch-manager;gpu")

add_tllm_gtest(
capacitySchedulerTest
Expand All @@ -88,8 +86,7 @@ add_tllm_gtest(
LINK_LIBRARIES
tllm::batch_scheduler
LABELS
"unit;batch-manager;gpu"
REQUIRES_GPU)
"unit;batch-manager;gpu")

add_tllm_gtest(
contextProgressTest
Expand All @@ -100,10 +97,11 @@ add_tllm_gtest(
LINK_LIBRARIES
tllm::batch_scheduler
LABELS
"unit;batch-manager;gpu"
REQUIRES_GPU)
"unit;batch-manager;gpu")

add_gtest(contextTransferCoordinatorTest contextTransferCoordinatorTest.cpp)
add_tllm_gtest(
contextTransferCoordinatorTest SOURCES contextTransferCoordinatorTest.cpp
FULL_STACK LABELS "unit;full-stack;host")

add_tllm_gtest(
evictionPolicyTest
Expand All @@ -125,8 +123,7 @@ add_tllm_gtest(
LINK_LIBRARIES
tllm::kv_cache_legacy
LABELS
"unit;batch-manager;gpu"
REQUIRES_GPU)
"unit;batch-manager;gpu")

# GDS partial-copy cases load the NIXL wrapper at runtime.
if(TARGET tensorrt_llm_nixl_wrapper)
Expand All @@ -146,8 +143,7 @@ add_tllm_gtest(
LINK_LIBRARIES
tllm::kv_cache_legacy
LABELS
"unit;batch-manager;gpu"
REQUIRES_GPU)
"unit;batch-manager;gpu")

add_tllm_gtest(
kvCacheManagerV2ConfigTest
Expand All @@ -171,8 +167,7 @@ add_tllm_gtest(
tllm::kv_cache
$<LINK_LIBRARY:WHOLE_ARCHIVE,tllm_kv_cache_test_support>
LABELS
"unit;batch-manager;gpu"
REQUIRES_GPU)
"unit;batch-manager;gpu")

add_tllm_gtest(
kvCacheManagerV2ColdPageTest
Expand All @@ -184,8 +179,7 @@ add_tllm_gtest(
tllm::kv_cache
$<LINK_LIBRARY:WHOLE_ARCHIVE,tllm_kv_cache_test_support>
LABELS
"unit;batch-manager;gpu"
REQUIRES_GPU)
"unit;batch-manager;gpu")

add_tllm_gtest(
coldPageCodecTest
Expand All @@ -196,8 +190,7 @@ add_tllm_gtest(
LINK_LIBRARIES
tllm::kv_cache
LABELS
"unit;batch-manager;gpu"
REQUIRES_GPU)
"unit;batch-manager;gpu")

add_tllm_gtest(
kvCacheManagerV2TypedIndexTest
Expand All @@ -221,8 +214,7 @@ add_tllm_gtest(
tllm::kv_cache
$<LINK_LIBRARY:WHOLE_ARCHIVE,tllm_kv_cache_test_support>
LABELS
"unit;batch-manager;gpu"
REQUIRES_GPU)
"unit;batch-manager;gpu")

add_tllm_gtest(
kvCacheManagerV2HostMemBackingTest
Expand All @@ -234,8 +226,7 @@ add_tllm_gtest(
tllm::kv_cache
$<LINK_LIBRARY:WHOLE_ARCHIVE,tllm_kv_cache_test_support>
LABELS
"unit;batch-manager;gpu"
REQUIRES_GPU)
"unit;batch-manager;gpu")

add_tllm_gtest(
kvCacheManagerV2StagingBufferTest
Expand All @@ -247,8 +238,7 @@ add_tllm_gtest(
tllm::kv_cache
$<LINK_LIBRARY:WHOLE_ARCHIVE,tllm_kv_cache_test_support>
LABELS
"unit;batch-manager;gpu"
REQUIRES_GPU)
"unit;batch-manager;gpu")

add_tllm_gtest(
kvCacheManagerV2StatsTest
Expand All @@ -260,8 +250,7 @@ add_tllm_gtest(
tllm::kv_cache
$<LINK_LIBRARY:WHOLE_ARCHIVE,tllm_kv_cache_test_support>
LABELS
"unit;batch-manager;gpu"
REQUIRES_GPU)
"unit;batch-manager;gpu")

add_tllm_gtest(
kvCacheManagerV2SlotAllocatorTest
Expand Down Expand Up @@ -297,8 +286,7 @@ add_tllm_gtest(
tllm::kv_cache
$<LINK_LIBRARY:WHOLE_ARCHIVE,tllm_kv_cache_test_support>
LABELS
"unit;batch-manager;gpu"
REQUIRES_GPU)
"unit;batch-manager;gpu")

add_tllm_gtest(
kvCacheManagerV2DigestPoolTest
Expand All @@ -321,8 +309,7 @@ add_tllm_gtest(
LINK_LIBRARIES
tllm::kv_cache_legacy
LABELS
"unit;batch-manager;gpu"
REQUIRES_GPU)
"unit;batch-manager;gpu")

add_tllm_gtest(
llmRequestTest
Expand All @@ -333,8 +320,7 @@ add_tllm_gtest(
LINK_LIBRARIES
tllm::kv_cache_legacy
LABELS
"unit;batch-manager;gpu"
REQUIRES_GPU)
"unit;batch-manager;gpu")

add_tllm_gtest(
microBatchSchedulerTest
Expand All @@ -345,12 +331,13 @@ add_tllm_gtest(
LINK_LIBRARIES
tllm::batch_scheduler
LABELS
"unit;batch-manager;gpu"
REQUIRES_GPU)
"unit;batch-manager;gpu")

add_gtest(peftCacheManagerTest peftCacheManagerTest.cpp)
add_tllm_gtest(peftCacheManagerTest SOURCES peftCacheManagerTest.cpp FULL_STACK
LABELS "unit;full-stack;gpu")

add_gtest(rnnCacheFormatterTest rnnCacheFormatterTest.cpp)
add_tllm_gtest(rnnCacheFormatterTest SOURCES rnnCacheFormatterTest.cpp
FULL_STACK LABELS "unit;full-stack;host")

add_tllm_gtest(
agentTreeTest
Expand All @@ -372,5 +359,4 @@ add_tllm_gtest(
LINK_LIBRARIES
tllm::kv_cache_legacy
LABELS
"unit;batch-manager;gpu"
REQUIRES_GPU)
"unit;batch-manager;gpu")
40 changes: 35 additions & 5 deletions cpp/tests/unit_tests/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,30 @@
# License for the specific language governing permissions and limitations under
# the License.

add_gtest(cudaProfilerUtilsTest cudaProfilerUtilsTest.cpp)
add_gtest(cudaUtilsTest cudaUtilsTest.cpp)
add_gtest(attentionWorkspaceTest attentionWorkspaceTest.cpp)
add_gtest(memoryUtilsTest memoryUtilsTest.cu)
add_tllm_gtest(cudaProfilerUtilsTest SOURCES cudaProfilerUtilsTest.cpp
FULL_STACK LABELS "unit;full-stack;host")
add_tllm_gtest(
cudaUtilsTest
OWNER
common
SOURCES
cudaUtilsTest.cpp
LINK_LIBRARIES
tllm::runtime_buffers
LABELS
"unit;common;gpu")
add_tllm_gtest(attentionWorkspaceTest SOURCES attentionWorkspaceTest.cpp
FULL_STACK LABELS "unit;full-stack;gpu")
add_tllm_gtest(
memoryUtilsTest
OWNER
common
SOURCES
memoryUtilsTest.cu
LINK_LIBRARIES
tllm::common_cuda
LABELS
"unit;common;host")
add_tllm_gtest(
optionalRefTest
OWNER
Expand Down Expand Up @@ -78,7 +98,17 @@ add_tllm_gtest(
tllm::common_logging
LABELS
"unit;common;host")
add_gtest(cudaDriverWrapperTest cudaDriverWrapperTest.cpp)
add_tllm_gtest(
cudaDriverWrapperTest
OWNER
common
SOURCES
cudaDriverWrapperTest.cpp
LINK_LIBRARIES
tllm::common_cuda
CUDA::cuda_driver
LABELS
"unit;common;gpu")
add_tllm_gtest(
loggerTest
OWNER
Expand Down
Loading
Loading