Skip to content

vector-store: numkong with f32 accumulation on x86 and widening f16 kernels - #645

Merged
ewienik merged 1 commit into
scylladb:masterfrom
swasik:VECTOR-1054-numkong-kernels
Oct 15, 2026
Merged

ewienik merged 1 commit into
scylladb:masterfrom
swasik:VECTOR-1054-numkong-kernels

Conversation

@swasik

@swasik swasik commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

#634 moved Vector Store to usearch 2.26.4 with NumKong's f32 angular kernels accumulating in f32 on NEON and SVE. VECTOR-1054 benchmarked the rest of the matrix against release 1.12.0 (usearch 2.22.0 with #633's SVE detection) and found three gaps:

case 1.12.0 kernel NumKong kernel today searches per second vs 1.12.0
x86 F32 (r7i, Sapphire Rapids) simsimd_cos_f32_skylake nk_angular_f32_skylake, widens every lane to f64 −10%
arm64 F16 (r8g, Graviton4) simsimd_cos_f16_sve nk_angular_f16_svehalf, converts every lane to f32 −17 to −23%
x86 F16 simsimd_cos_f16_sapphire (AVX512-FP16) nk_angular_f16_skylake, converts to f32 −13%

This PR closes most of the first two.

What it does

  • Pins numkong to scylladb/NumKong@23067331 (branch f32-accumulate-angular-f32-x86), two commits on top of the 501e810 that vector-store: usearch 2.26.4 with numkong's f32 angular kernels accumulating in f32 #634 uses:
    • d8277cd9: f16 angular kernels for SVE2 (FMLALB/FMLALT) and FEAT_FHM (FMLAL). They accumulate the half-precision products in f32 with widening multiply-adds instead of converting every lane, at 12 instructions per vector instead of 30. The runtime dispatch prefers them to svehalf and plain NEON. Against a binary128 reference the max error is 3.8–4.6e-7 (svehalf 6.1e-7), and NumKong's angular_f16 tests pass.
    • 23067331: NK_ACCUMULATE_F32_IN_F64=0 now also covers nk_angular_f32_haswell and nk_angular_f32_skylake: two chains of f32 FMAs, no vcvtps2pd, max error 3–4e-7, verified on a Sapphire Rapids node.
  • .cargo/config.toml sets CFLAGS_x86_64_unknown_linux_gnu = "-DNK_ACCUMULATE_F32_IN_F64=0", as it already does for aarch64, and its comment says what the x86 kernels cost.

Measurements

AWS, cohere-1m, COSINE, M=16, ef_construction=128, ef_search=64, k=10, HTTP at concurrency 64, vsbench bench ab in ABBA order with a fresh process and a 240 s settle per switch. The tables, kernel profiles and a per-call kernel microbenchmark run on the nodes are on VECTOR-720.

case before (this master) with this PR recall, 1.12.0 → this PR index build 1M, 1.12.0 / master / PR
x86 F32 −10.2% −4.2% (CV ≤ 0.6%) 93.95% → 93.7% (noise) 110 / 127 / 116 s
arm64 F16 −19% −6.4% ± 2.6% (mean over 8–10 independent index builds per arm) 92.2% → 93.5% 61 / 86 / 70 s
x86 F16 −13% −13% (unchanged) 92.65% → 93.9% 77 / 92 / 92 s
  • x86 F32: on the node, the f32-accumulating kernel costs the same per call as simsimd's, and less on a hot pair: 50.8 vs 60.3 ns at 768-d. The remaining 4% is outside the kernel, somewhere in usearch 2.26.4's search path; it stays open on VECTOR-1054.
  • arm64 F16: the new kernels do the arithmetic 2.1× faster than svehalf, but 13–15% slower than simsimd's kernel, which accumulates in f16. That is also why NumKong's F16 recall is 1.3 points higher.
  • x86 F16 is not addressed: NumKong has no AVX512-FP16 angular kernel for Sapphire Rapids (its diamond kernel needs AVX10.2), and AVX512-FP16 has no widening FMA into f32.

Decision

The performance is still a bit worse than Usearch 2.22.0 but we have other wins:

  • higher recall
  • deletions that does not impact latency of search queries (in 2.22.0 when dataset has over 10M vectors it is easy to exceed 1000 ms search latency while deleting)
  • f16 in general is not recommended - bf16 has much better performance and the same recall

Testing

  • cargo fmt --all -- --check and cargo clippy --all-targets -- -Dwarnings are clean, and cargo test -p vector-store passes on x86_64 (344 unit and 119 integration tests). numkong's build script reports CFLAGS_x86_64_unknown_linux_gnu = Some(-DNK_ACCUMULATE_F32_IN_F64=0).
  • The arm64 build with clang 19 (the release toolchain's) and the amd64 build with bookworm's gcc 12 both pass the vsbench verify gate (GLIBC ≤ 2.34). In the arm64 binary nk_angular_f16_sve2 and nk_angular_f16_neonfhm are present; in the amd64 binary nk_angular_f32_skylake and _haswell contain no vcvtps2pd, against 4 and 2 on master.
  • cargo deny check reports RUSTSEC-2026-0346 and -0347 for rustls 0.23.45. Upstream master reports the same two, so they are unrelated to this change.

Refs: VECTOR-1054
Refs: VECTOR-720

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: QUIET
  • Plan: Advanced
  • Run ID: 0235123b-64c3-480c-afe4-bd9eadd86851
📥 Commits

Reviewing files that changed from the base of the PR and between 6b46461 and 943aa45.

⛔ Files ignored due to path filters: 1
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing: 2
  • .cargo/config.toml
  • Cargo.toml

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

The numkong patch now uses a newer ScyllaDB revision that includes f32 and f16 angular kernel patches. The Cargo configuration adds an x86_64 Linux compiler flag for f32 accumulation and updates comments about kernel coverage and throughput.

Suggested reviewers: ewienik

Priority: ➖ Normal

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 943aa

This change updates the NumKong kernel pin and enables the reported x86_64 accumulation setting. No actionable merge risk is established, so it appears ready for normal checks.

Pre-merge checks: Passed 5
Passed Passed checks: 5 passed
Check name Status Explanation
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly identifies the NumKong update and the two main kernel optimizations for x86 f32 accumulation and widening f16 kernels.
Description check Passed The description directly explains the motivation, implementation, benchmark results, testing, and remaining limitations of the changes.
✨ Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…ernels

scylladb#634 moved to usearch 2.26.4 with numkong's f32 angular kernels
accumulating in f32 on NEON and SVE. Benchmarks for VECTOR-1054 against
release 1.12.0 (usearch 2.22.0) found three gaps the pin left open:

- x86 F32: numkong's Haswell and Skylake f32 angular kernels still widen
  every lane to f64. On an r7i.4xlarge (Sapphire Rapids) that cost 10% of
  the searches per second and 16% of the index build time.
- arm64 F16: nk_angular_f16_svehalf converts every f16 lane to f32 before
  the multiply-add, 30 instructions per vector: 17-23% fewer searches
  per second than 1.12.0 on Graviton4 and a 42% slower index build.
- x86 F16: 13% fewer searches; not addressed here (below).

Pin numkong to scylladb/NumKong 23067331 (branch
f32-accumulate-angular-f32-x86), two commits on top of the 501e810 used
so far:

- f16 angular kernels on SVE2 (FMLALB/FMLALT) and FEAT_FHM (FMLAL) that
  accumulate the half-precision products in f32 with widening
  multiply-adds, 12 instructions per vector; the runtime dispatch prefers
  them to svehalf and plain NEON.
- NK_ACCUMULATE_F32_IN_F64=0 now also covers nk_angular_f32_haswell and
  nk_angular_f32_skylake, and .cargo/config.toml sets it for
  x86_64-unknown-linux-gnu as it does for aarch64.

Measured on AWS (cohere-1m, COSINE, k=10, HTTP at concurrency 64, ABBA
with a fresh process per switch; full tables on VECTOR-720):

- x86 F32: -10.2% -> -4.2% against 1.12.0 (CV <= 0.6%), recall 93.95%
  vs 93.7% (noise), index build 127 s -> 116 s (1.12.0: 110 s). The
  kernel now costs what simsimd's does per call on the node; the
  remaining 4% is in usearch 2.26.4's search path, not the kernel.
- arm64 F16: -19% -> -6.4% +- 2.6% (mean over 8-10 independent index
  builds per arm), at 93.5% recall vs 92.2% for 1.12.0, whose simsimd
  kernel accumulates in f16. Index build 86 s -> 70 s (1.12.0: 61 s).
- x86 F16 stays at -13%: numkong has no AVX512-FP16 angular kernel for
  Sapphire Rapids, so it converts to f32 (recall 93.9% vs 92.65%).

The aarch64 and x86_64 release builds of this tree were checked: the
x86 kernels contain no vcvtps2pd, the f16 SVE2 kernel is in the binary.

Refs: VECTOR-1054
Refs: VECTOR-720

Co-Authored-By: Claude Opus 5.5 <[email protected]>
swasik pushed a commit to swasik/vector-store that referenced this pull request Oct 15, 2026
…lladb#647)

`cargo deny check` fails on master with two new advisories for `rustls`
0.23.45 (seen on scylladb#645):

- [RUSTSEC-2026-0346](https://rustsec.org/advisories/RUSTSEC-2026-0346):
`Debug` impls for client session values expose TLS secrets
- [RUSTSEC-2026-0347](https://rustsec.org/advisories/RUSTSEC-2026-0347):
buffered application data sent to the outer server after ECH rejection

Fixed by:
```
cargo update -p rustls
```

This bumps `rustls` to 0.23.46 and changes no other crate. `cargo deny
check` passes locally.

Fixes: VECTOR-1060

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@swasik
swasik force-pushed the VECTOR-1054-numkong-kernels branch from 943aa45 to 5e564a2 Compare October 15, 2026 07:49
@swasik
swasik requested a review from ewienik October 15, 2026 07:57
@ewienik
ewienik added this pull request to the merge queue Oct 15, 2026
Merged via the queue into scylladb:master with commit f7af1d0 Oct 15, 2026
48 checks passed
m-szymon pushed a commit to m-szymon/vector-store that referenced this pull request Oct 22, 2026
The release workflow announces every release in `#release-announce` with
the same line, `@here ScyllaDB Vector Store *X.Y.Z* is released`. It
doesn't say what changed, what to check before upgrading, or where the
release notes are. 1.13.0 fixed searches stalling during deletes but
lowered search throughput by up to 13% in some configurations, and the
announcement mentioned neither. Other ScyllaDB projects post a curated
summary instead, such as the Java driver's 4.19.2.3 announcement: a
:warning: line for each change to check before upgrading, grouped fixes,
a recommendation and a link.

This lets the release notes carry the announcement in a hidden block
written in Slack mrkdwn. The block is written and reviewed with the
notes when the release is cut. GitHub doesn't render it on the release
page:

```
<!-- slack-announcement
:rocket: ScyllaDB Vector Store 1.13.0 is out! One fix worth upgrading for, and one trade-off to check first:
:warning: Search throughput is lower in some configurations: … (scylladb#634, scylladb#645)
…
-->
```

The `announce` job now:

- reads the notes with `gh release view` when it runs, not from the
release event. A `workflow_dispatch` run then finds them too, and a
re-run after editing them posts the edited text;
- posts the block with `@here`, turns PR numbers into links, and adds a
line linking the release notes;
- posts the old one-liner, plus a link to the notes, when there is no
block. It warns if the notes mention a block it couldn't use;
- fails on a block that is never closed, instead of posting the wrong
text;
- builds the payload with `jq` instead of interpolating into a JSON
string;
- fails when Slack refuses the message. `chat.postMessage` answers HTTP
200 with `"ok": false`, so the old step passed on, for example, an
expired token.

The message also goes to the job summary. `docs/releasing.md` documents
the block, with 1.13.0 rewritten as a worked example.

The text is written by hand rather than generated in CI. The repository
has no LLM API key, and an `@here` message shouldn't go out before
anyone has read it.

## Testing

Both steps were extracted from the workflow and run locally with `gh`
and `curl` stubbed, under gawk and mawk (the runner's `awk`). Each case
behaved as expected:

| Release body | Result |
| --- | --- |
| 1.13.0's real notes (no block) | one-liner with a link to the notes |
| block with CRLF line endings | block posted, PR numbers linked,
"Details:" line added |
| marker lines with trailing spaces | block posted |
| empty block | warning, one-liner |
| block never closed | job fails with an error naming the problem |
| the example in `docs/releasing.md` | block posted |
| Slack replies `{"ok":false,"error":"invalid_auth"}` | job fails,
naming `invalid_auth` |

`gh release view 1.13.0 --json body,url` was checked against the real
repository. actionlint reports nothing for the `announce` job.

Not tested: a real post to Slack. That first happens at the next
release, where the job summary shows what was sent.

Fixes: VECTOR-1094

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants