Skip to content

Commit 9b1592f

Browse files
committed
Adding more tests
Signed-off-by: Patrice Castonguay <[email protected]>
1 parent c3a62a8 commit 9b1592f

File tree

4 files changed

+45
-10
lines changed

4 files changed

+45
-10
lines changed

cpp/tensorrt_llm/nanobind/executor/executorConfig.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ void initConfigBindings(nb::module_& m)
125125
nb::cast<bool>(state[6]), nb::cast<std::optional<float>>(state[7]),
126126
nb::cast<std::optional<tle::RetentionPriority>>(state[8]), nb::cast<size_t>(state[9]),
127127
nb::cast<bool>(state[10]), nb::cast<bool>(state[11]), nb::cast<bool>(state[12]),
128-
nb::cast<SizeTyp32>(state[13]));
128+
nb::cast<SizeType32>(state[13]));
129129
};
130130
nb::class_<tle::KvCacheConfig>(m, "KvCacheConfig")
131131
.def(nb::init<bool, std::optional<SizeType32> const&, std::optional<std::vector<SizeType32>> const&,

cpp/tests/unit_tests/batch_manager/kvCacheEventManagerTest.cpp

Whitespace-only changes.

cpp/tests/unit_tests/executor/serializeUtilsTest.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,40 @@ void compareKvCacheEvents(texec::KVCacheEvent const& kvCacheEvent, texec::KVCach
915915
}
916916
}
917917

918+
TEST(SerializeUtilsTest, KvCacheEventsDeque)
919+
{
920+
// Created event
921+
texec::KVCacheCreatedData kvCacheCreatedData{{1, 2}};
922+
texec::KVCacheEvent kvCacheCreatedEvent(1, kvCacheCreatedData, 32);
923+
924+
// Removed event
925+
texec::KVCacheEvent kvCacheRemovedEvent(1, texec::KVCacheRemovedData{{3, 4}}, 32);
926+
927+
// Stored event
928+
auto storedBlockData1 = texec::KVCacheStoredBlockData(77, {{1, 2}, {3, 4}, {5, 6}}, 88, 0, 99);
929+
auto storedBlockData2 = texec::KVCacheStoredBlockData(99, {{11, 12}, {3, 4}, {15, 6}}, 77, 1, 101);
930+
texec::KVCacheStoredData kvCacheStoredData{177, {storedBlockData1, storedBlockData2}};
931+
texec::KVCacheEvent kvCacheStoredEvent(1, kvCacheStoredData, 32);
932+
933+
// Updated event
934+
texec::KVCacheEventDiff<texec::SizeType32> diff{0, 1};
935+
texec::KVCacheEventDiff<texec::SizeType32> diff2{90, 99};
936+
texec::KVCacheUpdatedData kvCacheUpdatedData(999, diff, diff2);
937+
texec::KVCacheEvent kvCacheEvent(1, kvCacheUpdatedData, 32);
938+
939+
std::deque<texec::KVCacheEvent> kvCacheEvents{
940+
kvCacheCreatedEvent, kvCacheRemovedEvent, kvCacheStoredEvent, kvCacheEvent};
941+
942+
auto serializedEvents = texec::Serialization::serialize(kvCacheEvents);
943+
auto kvCacheEvents2 = texec::Serialization::deserializeKVCacheEvents(serializedEvents);
944+
945+
EXPECT_EQ(kvCacheEvents.size(), kvCacheEvents2.size());
946+
for (size_t i = 0; i < kvCacheEvents.size(); ++i)
947+
{
948+
compareKvCacheEvents(kvCacheEvents[i], kvCacheEvents2[i]);
949+
}
950+
}
951+
918952
// Test for KVCacheEvent with KVCacheCreatedData
919953
TEST(SerializeUtilsTest, KVCacheCreatedEvent)
920954
{

tensorrt_llm/_torch/pyexecutor/resource_manager.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -301,15 +301,16 @@ def append_to_kv_heads_per_layer(num_kv_heads_per_layer: List[int],
301301
}
302302
if self.event_buffer_max_size > 0:
303303
if mapping.enable_attention_dp:
304-
kwargs['event_manager'] = KVCacheEventManagerCpp(
305-
max_kv_event_entries=self.event_buffer_max_size,
306-
attention_dp_rank=mapping.rank,
307-
attention_dp_size=mapping.world_size,
308-
attention_dp_events_gather_period_ms=self.attention_dp_events_gather_period_ms,
309-
)
310-
else:
311-
kwargs['event_manager'] = KVCacheEventManagerCpp(
312-
max_kv_event_entries=self.event_buffer_max_size)
304+
kwargs['event_manager'] = KVCacheEventManagerCpp(
305+
max_kv_event_entries=self.event_buffer_max_size,
306+
attention_dp_rank=mapping.rank,
307+
attention_dp_size=mapping.world_size,
308+
attention_dp_events_gather_period_ms=self.
309+
attention_dp_events_gather_period_ms,
310+
)
311+
else:
312+
kwargs['event_manager'] = KVCacheEventManagerCpp(
313+
max_kv_event_entries=self.event_buffer_max_size)
313314

314315
self.impl = KVCacheManagerCpp(**kwargs)
315316

0 commit comments

Comments
 (0)