Skip to content

Commit 4a6dd5a

Browse files
Tomer Shmilovichtshmilnvidia
authored andcommitted
BlockManager copy constructor fix
Remove unwanted copying of BlockManager in UT. Also Delete BlockManager copy constructor & operator= so this mistake is never repeated. Signed-off-by: Tomer Shmilovich <[email protected]>
1 parent a36ac45 commit 4a6dd5a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

cpp/include/tensorrt_llm/batch_manager/kvCacheManager.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,9 @@ class BlockManager
854854
std::shared_ptr<KVCacheEventManager> eventManager = nullptr, bool enableHashKey = false,
855855
bool enablePartialReuse = true, bool copyOnPartialReuse = true);
856856

857+
BlockManager(BlockManager const&) = delete;
858+
BlockManager& operator=(BlockManager const&) = delete;
859+
857860
//! \brief Calculate the proportional share each window size receives of the total memory pool
858861
//! \details Example: (uniqueWindowSizeToLayers={1024: [1], 4096: [0, 4, 5], 8192: [2, 3]})
859862
//! Would Return: {1024: 0.0345, 4096: 0.4138, 8192: 0.5517} [sums to 1.0].

cpp/tests/unit_tests/batch_manager/kvCacheManagerTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2115,7 +2115,7 @@ TEST_F(KVCacheManagerTest, KVCacheManagerLeafBlockWithDependentTest)
21152115
EXPECT_THAT(cacheBlockIds0, ::testing::ElementsAreArray({0, 1, 2}));
21162116

21172117
// Lower priority of middle block to prevent offloading
2118-
auto const blockManager = kvCacheManager.getBlockManager();
2118+
auto const& blockManager = kvCacheManager.getBlockManager();
21192119
auto middleBlock = blockManager.getBlockById(cacheBlockIds0[1], maxAttentionWindow);
21202120
middleBlock->setPriority(0);
21212121

@@ -2215,7 +2215,7 @@ TEST_P(KVCacheManagerTest, DISABLED_KVCacheManagerAllocationTest)
22152215
std::nullopt, nvinfer1::DataType::kHALF, sinkTokenLength, stream, std::nullopt, enableBlockReuse,
22162216
onboardBlocks);
22172217

2218-
auto const blockManager = kvCacheManager.getBlockManager();
2218+
auto const& blockManager = kvCacheManager.getBlockManager();
22192219
auto const& bufferManager = blockManager.getBufferManager(theOnlyWindowSize(kvCacheManager));
22202220
auto const memoryPoolUsedBefore = bufferManager.memoryPoolUsed();
22212221
kvCacheManager.allocatePools(useUvm);

0 commit comments

Comments
 (0)