Repository navigation
Migrate from SimSIMD to NumKong - #128293
thevar1able wants to merge 4 commits into
Conversation
`SimSIMD` was renamed to `NumKong` upstream. Replace `contrib/SimSIMD` (the ClickHouse fork at v6.5.15) with upstream `NumKong` v7.8.6, unpatched: the fork's patches (MSan unpoisoning, `unistd.h` for ARM capability detection, data race on lazy dispatch initialization) are covered upstream, where the dispatch table is filled by a load-time constructor. Bump `usearch` to v2.26.6, which uses `NumKong` instead of `SimSIMD` and no longer needs `FP16`, so `contrib/FP16` is removed. The ClickHouse patches are carried in ClickHouse/usearch#15. `NumKong` with dynamic dispatch compiles kernels only for the instruction sets enabled explicitly, so `contrib/NumKong-cmake` lists them. SVE stays disabled because MemorySanitizer cannot instrument it. Port `distanceTransposed` to the `nk_*` API. `NumKong` kernels write the result in a type that depends on the input type (`f64`, `f32` or `i32`), so it is converted to `Float64`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [a7c456b] Summary: ❌
AI ReviewSummaryReplaces Findings
Tests
Final VerdictStatus: |
The Genoa (AVX-512 BF16) `bf16` squared Euclidean distance computes `a^2 + b^2 - 2ab` in `f32`, which cancels catastrophically for close vectors (`[32768, 1]` and `[32768, 2]` give 0 instead of 1) and overflows to NaN for identical vectors with huge components. Without it, `bf16` falls back to the Haswell kernels, which subtract before squaring, as `SimSIMD` did. Also fix the clang-tidy errors in `distanceTransposed`: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=128293&sha=837a64c18aebe7ecfbb49f78bbdc822890e8a223&name_0=PR&name_1=Build%20%28arm_tidy%2C%201%2F4%29 #128293 Co-Authored-By: Claude Opus 5.5 <[email protected]>
`striped_locks_gt`, new in `usearch` v2.26, was not included in `index_gt::memory_usage`, which the vector similarity index cache uses as the entry weight: about 4 MiB per index on a 64-core server. ClickHouse/usearch#16 Co-Authored-By: Claude Opus 5.5 <[email protected]>
| @@ -1 +1 @@ | |||
| Subproject commit 6bd13d4c69a1baef1f668e652c3ca26028970f12 | |||
| Subproject commit 78b5cbf5df91ff2aa7a07f5b732996acd8a00f8d | |||
There was a problem hiding this comment.
[P2] Preserve ClickHouse's thread limits when constructing indexes
The new index_dense_gt::make reserves hardware_concurrency() threads by default, but USearchIndexWithSerialization still calls make(metric, config) without initial limits at src/Storages/MergeTree/MergeTreeIndexVectorSimilarity.cpp:130. Both reservation layers now retain the maximum thread count, so the later builder reservation using max_build_vector_similarity_index_thread_pool_size and loader reservation using 2 * getNumberOfCPUCoresToUse cannot reduce it.
On a 192-thread host with a two-CPU container quota, loaded indexes therefore retain 192 thread slots instead of four. With the default connectivity, their striped locks alone consume 8,388,736 bytes per granule instead of 131,200, reducing the number of small parts fitting in the cache and increasing index-loading allocations. A standalone probe on this two-thread host confirms the change: after reserving one thread, the old revision retains one slot and the new revision retains two; supplying the initial limit to make restores one.
Please adapt the caller to pass explicit, small nonzero initial thread limits through the new fourth argument, allowing the existing build/load reservations to grow them. Using unreserved alone does not cover loading: load_from_stream replaces zero thread counts with hardware defaults. Verify both build and load paths with the configured CPU/thread count below the host count.
SimSIMDwas renamed toNumKongupstream, andusearchv2.25+ depends onNumKonginstead ofSimSIMD. This PR migrates both.contrib/SimSIMD(ClickHouse fork at v6.5.15) is replaced by upstreamNumKongv7.8.6, unpatched. Our fork's patches are covered upstream: MSan unpoisoning of dispatch results,unistd.hfor ARM capability detection, and the data race on lazy dispatch initialization (the dispatch table is now filled by a load-time constructor).usearchis bumped from v2.24.0 to v2.26.6. The ClickHouse patches are carried on theClickHouse/v2.26.6branch of the fork (Carry the ClickHouse patches from v2.24.0 onto v2.26.6 usearch#15), plus a fix to count the new striped locks inmemory_usage, which the vector similarity index cache uses as the entry weight (Account for the striped locks inindex_gt::memory_usageusearch#16).usearchno longer usesFP16, socontrib/FP16is removed.contrib/NumKong-cmakebuilds the dynamic-dispatch library. It enables the instruction sets explicitly: without that,NumKongcompiles only the baseline ISA. SVE stays disabled, as before, because MemorySanitizer cannot instrument it. AMX, SME, AVX10.2 and NEON FP8 are also disabled (matrix-only kernels, or not supported by the minimum Clang). Genoa (AVX-512 BF16) is disabled because itsbf16L2 kernel computesa² + b² − 2abinf32and cancels catastrophically;bf16uses the Haswell kernels instead, which subtract first.distanceTransposedis ported to thenk_*API.NumKongkernels write the result in a type that depends on the input (f64forFloat32/Float64,f32forBFloat16and theInt8L2/cosine,i32for theInt8dot product), so it is converted toFloat64. As a result, the last digits of someBFloat16andInt8distances may differ.USE_SIMSIMD/ch_contrib::simsimdare renamed toUSE_NUMKONG/ch_contrib::numkong.Related: ClickHouse/usearch#15
Related: ClickHouse/usearch#16
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Replace
SimSIMDwithNumKong7.8.6 and updateusearchto 2.26.6.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/128293]