refactor(minicpm5): move model-contract tests under tests/models - #706
refactor(minicpm5): move model-contract tests under tests/models#706Aharrypotter wants to merge 4 commits into
Conversation
Follow the test placement introduced by UbiquitousLearning#704: MiniCPM5 configuration, tokenizer, and model-graph tests protect the model contract, not a CPU kernel, so they now live in tests/models/minicpm5 with their own CMake targets and CTest registration (label `minicpm5`). tests/cpu keeps only kernel and backend-op coverage. The config and model tests accept an MLLM_MINICPM5_EXAMPLE_DIR override (same convention as Qwen35ConfigTest) so the binaries can locate the example config when run outside the build host. No change under mllm/; the MiniCPM5 model graph already composes registered nn layers only.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughThe changes add grouped-query attention decode coverage, register MiniCPM5 configuration, tokenizer, and model tests, add environment-based configuration paths, and register two NN-focused CTest cases. ChangesGrouped-query attention decode tests
MiniCPM5 test suite
NN focused test registration
Estimated code review effort: 4 (Complex) | ~45 minutes Merge Risk: ⚪ Minimal · up to This change reorganizes and registers MiniCPM5 and NN test coverage while adding focused GQA decode validation; no current merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The native KV-head grouped-query-attention decode kernel (gqa_decode/fwd_bhsd.hpp) shipped with MiniCPM5 without kernel-level coverage; only the public nn::GroupedQueryAttention tests exercised it. Add GqaDecodeKernelTest.hpp following the neighbouring fixture shape: - independent double-accumulating scalar reference over a focused geometry matrix (scalar path, exact NEON blocks, qk/value tails, single KV head, 128-dim heads at several cache fills); - native static-cache view plus transposed [B, 1, H, D] query strides must match the contiguous computation bitwise; - grouped (batch, kv-head) slices must match per-head single-KV calls bitwise, proving scratch rows do not leak across heads or batches; - repeat stability and rejection of invalid geometry, null buffers, and unsupported strides without touching the output. Register the cases in KernelTest.cpp and extend the CPUKernelFocused filter so CTest runs them.
…Test Both public-operation test executables introduced with MiniCPM5 were built but never registered, so `ctest` skipped them. Register them the same way as GatedDeltaRuleFocused, under the `nn-op` label.
Replace the Run state bag and invoke() wrapper with a StridedView (storage plus the [B, H, S, D] strides under test), purpose-named view builders for the contiguous, static-cache, and transposed layouts, and explicit fwdBhsdFp32 calls in every case so the kernel contract is visible at the call site. Make the fixture class forward through non-static members with namespace-qualified types, matching GatedDeltaRuleKernelTest and CausalDepthwiseConvCurrentFirstKernelTest. Case names and assertions are unchanged.
Split the branch-local Ling3KDATest into the layers that the repository now maintains separately (UbiquitousLearning#704/UbiquitousLearning#706): - tests/cpu/KimiDeltaAttentionKernelTest.hpp: scalar-reference fixture for the KDA kernel (both gate variants, NEON lane blocks and tails, bitwise prefill-vs-tokenwise and serial-vs-parallel checks, argument validation), registered in KernelTest.cpp and the CPUKernelFocused ctest filter. - tests/nn/KimiDeltaAttentionTest.cpp: public nn::KimiDeltaAttention contract through a Module (eager reference match including the 16x128 production head geometry, in-place vs copied state, chunked prefill/decode equivalence, invalid geometry/options, trace plus option serialization round trip), registered with add_test. - tests/models/ling3: config, tokenizer and RoPE tests with add_test registration, the `ling3` label, and an MLLM_LING3_EXAMPLE_DIR override for on-device runs. The causal-convolution contract is covered by the upstream tests/nn/CausalDepthwiseConv1DTest.cpp and the CausalDepthwiseConv kernel suites, so the branch-local copies are removed. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Split the branch-local Ling3KDATest into the layers that the repository now maintains separately (UbiquitousLearning#704/UbiquitousLearning#706): - tests/cpu/KimiDeltaAttentionKernelTest.hpp: scalar-reference fixture for the KDA kernel (both gate variants, NEON lane blocks and tails, bitwise prefill-vs-tokenwise and serial-vs-parallel checks, argument validation), registered in KernelTest.cpp and the CPUKernelFocused ctest filter. - tests/nn/KimiDeltaAttentionTest.cpp: public nn::KimiDeltaAttention contract through a Module (eager reference match including the 16x128 production head geometry, in-place vs copied state, chunked prefill/decode equivalence, invalid geometry/options, trace plus option serialization round trip), registered with add_test. - tests/models/ling3: config, tokenizer and RoPE tests with add_test registration, the `ling3` label, and an MLLM_LING3_EXAMPLE_DIR override for on-device runs. The causal-convolution contract is covered by the upstream tests/nn/CausalDepthwiseConv1DTest.cpp and the CausalDepthwiseConv kernel suites, so the branch-local copies are removed.
Summary
Moves the MiniCPM5-1B model-contract tests out of
tests/cpuintotests/models/minicpm5, following the test placement introduced by #704 for Qwen3.5.This PR:
MiniCPM5ConfigTest,MiniCPM5TokenizerTest, andMiniCPM5ModelTesttotests/models/minicpm5with their own CMake targets and CTest registration (labelminicpm5);tests/cpu/CMakeLists.txt, which now holds only kernel and backend-op coverage;MLLM_MINICPM5_EXAMPLE_DIRoverride (same convention asQwen35ConfigTest) so the same binaries can find the example config when executed on a device;GqaDecodeKernelTestto the unified CPU kernel suite: the native KV-head grouped-query-attention decode kernel shipped with MiniCPM5 previously had only public-op coverage intests/nn, no kernel-level oracle intests/cpu;Mllm-Test-Nn-GroupedQueryAttentionandMllm-Test-Nn-KVHeadStaticCacheexecutables with CTest (labelnn-op); they were built but never run byctest;mllm/.Test placement
MiniCPM5ConfigTesttests/cputests/models/minicpm5MiniCPM5TokenizerTesttests/cputests/models/minicpm5MiniCPM5ModelTesttests/cputests/models/minicpm5Kernel coverage added to
tests/cpuMatchesScalarReferenceAcrossFocusedMatrixNativeCacheViewAndTransposedQueryMatchContiguousBitwise[B, Hkv, max_len, D]static cache plus a transposed[B, 1, Hq, D]query/output is addressed through the strides and is bitwise identical to the contiguous computationGroupedSlicesMatchSingleHeadCallsBitwise(batch, kv-head)group reproduces the per-head single-KV call bitwise, so the grouped scratch rows do not leak across heads or batchesRepeatedCallsAreBitwiseStableRejectsInvalidGeometryAndStridesfalsewithout touching the outputThe cases are registered in
tests/cpu/KernelTest.cppand added to theCPUKernelFocusedCTest filter. The fixture follows the neighbouringGatedDeltaRuleKernelTest.hppshape: agqa_decode_kernel_testnamespace with the reference, aStridedView(storage plus the[B, H, S, D]strides under test) built by purpose-named helpers for the contiguous, static-cache, and transposed layouts, explicitfwdBhsdFp32calls in every case, and a thin forwarding fixture class. Public-op behaviour (trace, serialization, fallback, product geometries) stays covered by the existingtests/nn/GroupedQueryAttentionTest.cpp.The MiniCPM5 model graph in
mllm/models/minicpm5/modeling_minicpm5.hppalready composes registerednnlayers only (GroupedQueryAttention,KVHeadStaticCache,RoPE,RMSNorm,Linear) and includes no backend kernel header, so the operation-registration half of #704 does not apply here.Review map
tests/cpu/CMakeLists.txt(removals),tests/models/CMakeLists.txt,tests/models/minicpm5/CMakeLists.txt.exampleDir()intests/models/minicpm5/MiniCPM5ConfigTest.cppandMiniCPM5ModelTest.cpp.tests/cpu/GqaDecodeKernelTest.hpp(reference, strided run builders, case functions) and theTEST_Fentries intests/cpu/KernelTest.cpp.add_testlines intests/nn/CMakeLists.txt.Validation
Validation is bound to commit
7c4223ce1debfacb0c1acee760352d3aecb43b17(four commits on top ofUbiquitousLearning/mllm:main@eef7dc2be28f54d5ee5d8079a8d3d1989878d31d). The model-test rows ran on the first commitd1a1a280, whosetests/modelsfiles are unchanged since; thectest -L nn-oprow ran ondf85620d, whose registration lines are unchanged since; the kernel-test rows (host, NDK cross-build, device) were rerun on the exact7c4223cetree after the fixture restructure. All gates are ARM.Validation (PASS) — macOS Apple Silicon host, Android NDK r28b cross-builds, and OnePlus 13T device runs for both the model tests and the kernel suite
git diff --check,clang-format --dry-runtests/MiniCPM5{Config,Tokenizer,Model}Focusedare registered fromtests/models/minicpm5and pass;ctest -Nshows no MiniCPM5 target left undertests/cpuMLLM_MINICPM5_TOKENIZER_JSONset, pinned token IDs and the 200-token demo prompt match-march=armv8.2-a+fp16+fp16fml+dotprod+i8mm, OpenMP)mllm-minicpm5-runnerconfigure, compile, and link; 8/8 artifacts are AArch64 ELF, 4/4 executables request/system/bin/linker64, NEEDED entries auditedMLLM_MINICPM5_EXAMPLE_DIRpointing at the shipped example config and the official tokenizer; an invalid override directory makes the config test fail, proving the override is honoredMllm-Test-CPUKernelGqaDecodeKernelTest.*5/5;CPUKernelFocusedCTest PASSMllm-Test-CPUKernellibMllmRT.so/libMllmCPUBackend.socompile and link; 5/5 artifacts AArch64, executable requests/system/bin/linker64, ISA flags present in the compile databaseMllm-Test-CPUKernelGqaDecodeKernelTest.*5/5; focused filter 18/18 across 4 suitesctest -L nn-opDependencies for the cross-build came from a verified offline mirror (cache-assisted); product source, flags, and targets were unchanged.
Supported scope and limits
Changed by this PR: test file locations, CMake targets and CTest labels, the example-directory override in two tests, one new kernel-test fixture plus its registry entries, and CTest registration for two existing public-op tests.
Not changed: MiniCPM5 model graph, configuration, tokenizer, runner, conversion, CPU kernels, or any other model's tests.
Not claimed: new model capability, full-model generation on this commit (runtime bytes are unchanged from
main), model-quality or performance results, or upstream CI (not run on this commit).🤖 Generated with Claude Code
Summary by CodeRabbit