Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 1 addition & 17 deletions tests/cpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,6 @@ add_executable(Mllm-Test-KaiW4A32Pack KaiW4A32PackTest.cpp)
target_link_libraries(Mllm-Test-KaiW4A32Pack PRIVATE gtest_main MllmCPUBackend)
target_include_directories(Mllm-Test-KaiW4A32Pack PRIVATE ${MLLM_INCLUDE_DIR})

add_executable(Mllm-Test-MiniCPM5-Config MiniCPM5ConfigTest.cpp)
target_link_libraries(Mllm-Test-MiniCPM5-Config PRIVATE gtest_main MllmCPUBackend)
target_include_directories(Mllm-Test-MiniCPM5-Config PRIVATE ${MLLM_INCLUDE_DIR})
target_compile_definitions(Mllm-Test-MiniCPM5-Config
PRIVATE MINICPM5_EXAMPLE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/../../examples/minicpm5")

add_executable(Mllm-Test-MiniCPM5-Tokenizer MiniCPM5TokenizerTest.cpp)
target_link_libraries(Mllm-Test-MiniCPM5-Tokenizer PRIVATE gtest_main MllmCPUBackend)
target_include_directories(Mllm-Test-MiniCPM5-Tokenizer PRIVATE ${MLLM_INCLUDE_DIR})

add_executable(Mllm-Test-MiniCPM5-Model MiniCPM5ModelTest.cpp)
target_link_libraries(Mllm-Test-MiniCPM5-Model PRIVATE gtest_main MllmCPUBackend)
target_include_directories(Mllm-Test-MiniCPM5-Model PRIVATE ${MLLM_INCLUDE_DIR})
target_compile_definitions(Mllm-Test-MiniCPM5-Model
PRIVATE MINICPM5_EXAMPLE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/../../examples/minicpm5")

add_executable(Mllm-Test-CPUContiguousOp ContiguousOpTest.cpp)
target_link_libraries(Mllm-Test-CPUContiguousOp PRIVATE gtest_main MllmRT MllmCPUBackend)
target_include_directories(Mllm-Test-CPUContiguousOp PRIVATE ${MLLM_INCLUDE_DIR})
Expand All @@ -31,5 +15,5 @@ add_test(
NAME CPUKernelFocused
COMMAND
Mllm-Test-CPUKernel
--gtest_filter=CausalDepthwiseConvKernelTest.*:CausalDepthwiseConvCurrentFirstKernelTest.*:GatedDeltaRuleKernelTest.*)
--gtest_filter=CausalDepthwiseConvKernelTest.*:CausalDepthwiseConvCurrentFirstKernelTest.*:GatedDeltaRuleKernelTest.*:GqaDecodeKernelTest.*)
set_tests_properties(CPUKernelFocused PROPERTIES LABELS cpu-kernel)
399 changes: 399 additions & 0 deletions tests/cpu/GqaDecodeKernelTest.hpp

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions tests/cpu/KernelTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,49 @@ TEST_F(GatedDeltaRuleKernelTest, ProductionGroupedHeadGeometry8LaneIsBitwiseStab
/*repeats=*/24));
}

//===----------------------------------------------------------------------===//
// Grouped-query attention decode (native KV-head cache views)
//===----------------------------------------------------------------------===//
#include "GqaDecodeKernelTest.hpp"
TEST_F(GqaDecodeKernelTest, MatchesScalarReferenceAcrossFocusedMatrix) {
EXPECT_NO_FATAL_FAILURE(testMatchesScalarReference({
// Scalar path and single KV head.
{1, 1, 1, 1, 1, 1},
{1, 2, 1, 3, 3, 3},
{2, 4, 1, 5, 4, 4},
// Exact NEON vector blocks, group size 1 and 2.
{1, 2, 2, 7, 8, 8},
{1, 4, 2, 16, 16, 16},
// Vector loop with scalar tails in qk and value dims.
{1, 4, 2, 9, 5, 7},
{2, 6, 3, 11, 13, 6},
{1, 8, 2, 33, 127, 130},
// Production 128-dim heads at several cache fills.
{1, 8, 2, 1, 128, 128},
{1, 16, 2, 69, 128, 128},
{1, 16, 2, 517, 128, 128},
{2, 16, 2, 40, 128, 128},
}));
}

TEST_F(GqaDecodeKernelTest, NativeCacheViewAndTransposedQueryMatchContiguousBitwise) {
EXPECT_NO_FATAL_FAILURE(testNativeCacheAndTransposedQueryStrides({1, 16, 2, 69, 128, 128}, /*cache_capacity=*/2048));
EXPECT_NO_FATAL_FAILURE(testNativeCacheAndTransposedQueryStrides({2, 6, 3, 11, 13, 6}, /*cache_capacity=*/32));
}

TEST_F(GqaDecodeKernelTest, GroupedSlicesMatchSingleHeadCallsBitwise) {
EXPECT_NO_FATAL_FAILURE(testGroupedSlicesMatchSingleHeadCallsBitwise({2, 16, 2, 69, 128, 128}));
EXPECT_NO_FATAL_FAILURE(testGroupedSlicesMatchSingleHeadCallsBitwise({1, 6, 3, 11, 13, 6}));
}

TEST_F(GqaDecodeKernelTest, RepeatedCallsAreBitwiseStable) {
EXPECT_NO_FATAL_FAILURE(testRepeatedCallsAreBitwiseStable({1, 16, 2, 517, 128, 128}, /*repeats=*/8));
}

TEST_F(GqaDecodeKernelTest, RejectsInvalidGeometryAndStrides) {
EXPECT_NO_FATAL_FAILURE(testRejectsInvalidGeometryAndStrides());
}

//===----------------------------------------------------------------------===//
// Parallel linear
//===----------------------------------------------------------------------===//
Expand Down
1 change: 1 addition & 0 deletions tests/models/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
add_subdirectory(qwen3_5)
add_subdirectory(minicpm5)
20 changes: 20 additions & 0 deletions tests/models/minicpm5/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
add_executable(Mllm-Test-MiniCPM5-Config MiniCPM5ConfigTest.cpp)
target_link_libraries(Mllm-Test-MiniCPM5-Config PRIVATE gtest_main MllmCPUBackend)
target_include_directories(Mllm-Test-MiniCPM5-Config PRIVATE ${MLLM_INCLUDE_DIR})
target_compile_definitions(Mllm-Test-MiniCPM5-Config
PRIVATE MINICPM5_EXAMPLE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/../../../examples/minicpm5")

add_executable(Mllm-Test-MiniCPM5-Tokenizer MiniCPM5TokenizerTest.cpp)
target_link_libraries(Mllm-Test-MiniCPM5-Tokenizer PRIVATE gtest_main MllmCPUBackend)
target_include_directories(Mllm-Test-MiniCPM5-Tokenizer PRIVATE ${MLLM_INCLUDE_DIR})

add_executable(Mllm-Test-MiniCPM5-Model MiniCPM5ModelTest.cpp)
target_link_libraries(Mllm-Test-MiniCPM5-Model PRIVATE gtest_main MllmCPUBackend)
target_include_directories(Mllm-Test-MiniCPM5-Model PRIVATE ${MLLM_INCLUDE_DIR})
target_compile_definitions(Mllm-Test-MiniCPM5-Model
PRIVATE MINICPM5_EXAMPLE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/../../../examples/minicpm5")

add_test(NAME MiniCPM5ConfigFocused COMMAND Mllm-Test-MiniCPM5-Config)
add_test(NAME MiniCPM5TokenizerFocused COMMAND Mllm-Test-MiniCPM5-Tokenizer)
add_test(NAME MiniCPM5ModelFocused COMMAND Mllm-Test-MiniCPM5-Model)
set_tests_properties(MiniCPM5ConfigFocused MiniCPM5TokenizerFocused MiniCPM5ModelFocused PROPERTIES LABELS minicpm5)
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@

#include <gtest/gtest.h>

#include <cstdlib>
#include <string>
#include <vector>

#include "mllm/models/minicpm5/configuration_minicpm5.hpp"

namespace {

auto exampleDir() -> std::string {
const char* example_dir_override = std::getenv("MLLM_MINICPM5_EXAMPLE_DIR");
return example_dir_override == nullptr ? std::string(MINICPM5_EXAMPLE_DIR) : std::string(example_dir_override);
}

auto loadConfig() -> mllm::models::minicpm5::MiniCPM5Config {
return mllm::models::minicpm5::MiniCPM5Config(std::string(MINICPM5_EXAMPLE_DIR) + "/config_1B_w4a32_kai.json");
return mllm::models::minicpm5::MiniCPM5Config(exampleDir() + "/config_1B_w4a32_kai.json");
}

auto parameterFile(mllm::ModelFileVersion version, const std::vector<int32_t>& embedding_shape, bool include_lm_head = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,24 @@

#include <gtest/gtest.h>

#include <cstdlib>
#include <string>

#include "mllm/mllm.hpp"
#include "mllm/models/minicpm5/modeling_minicpm5.hpp"

namespace {

auto exampleDir() -> std::string {
const char* example_dir_override = std::getenv("MLLM_MINICPM5_EXAMPLE_DIR");
return example_dir_override == nullptr ? std::string(MINICPM5_EXAMPLE_DIR) : std::string(example_dir_override);
}

} // namespace

TEST(MiniCPM5ModelTest, BuildsNativeKVHeadLogicalSlotsAndResetsThem) {
mllm::initializeContext();
const auto config = mllm::models::minicpm5::MiniCPM5Config(std::string(MINICPM5_EXAMPLE_DIR) + "/config_1B_w4a32_kai.json");
const auto config = mllm::models::minicpm5::MiniCPM5Config(exampleDir() + "/config_1B_w4a32_kai.json");
auto model = mllm::models::minicpm5::MiniCPM5ForCausalLM(config);
auto& cache = model.kvCache();

Expand Down
3 changes: 3 additions & 0 deletions tests/nn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ target_include_directories(Mllm-Test-Nn-GatedDeltaRule PRIVATE ${MLLM_INCLUDE_DI

include(GoogleTest)
add_test(NAME GatedDeltaRuleFocused COMMAND Mllm-Test-Nn-GatedDeltaRule)
add_test(NAME GroupedQueryAttentionFocused COMMAND Mllm-Test-Nn-GroupedQueryAttention)
add_test(NAME KVHeadStaticCacheFocused COMMAND Mllm-Test-Nn-KVHeadStaticCache)
set_tests_properties(GroupedQueryAttentionFocused KVHeadStaticCacheFocused PROPERTIES LABELS nn-op)