Skip to content

Add tiled MinMax MaxSim kernels - #1375

Draft
juchen-ms (partychen) wants to merge 6 commits into
microsoft:mhildebr/multivectorfrom
partychen:arm64-neon-maxsim
Draft

Add tiled MinMax MaxSim kernels#1375
juchen-ms (partychen) wants to merge 6 commits into
microsoft:mhildebr/multivectorfrom
partychen:arm64-neon-maxsim

Conversation

@partychen

@partychenjuchen-ms (partychen) commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a prepared MaxSim matrix kernel for MinMax8 queries against packed MinMax4 documents.

  • packs each query once; query packing is excluded from per-document timing
  • reads packed MinMax4 nibbles directly without a temporary unpacked document matrix
  • preserves Driver -> PanelKernel -> MicroKernel
  • fuses integer accumulation, MinMax compensation, and MaxSim reduction
  • dispatches Scalar, x86-64 V3/V4, and ARM64 Neon through MaxSimIsa

Kernels

ISAMR x NRA packingB expansion and dot product
Scalar8 x 6Row-majorPortable scalar loop
x86-64 V316 x 8Grouped-4AVX2 expansion + maddubs + madd
x86-64 V416 x 8Grouped-8BMI2 pdep_u64 + 512-bit VNNI
ARM64 Neon8 x 8Grouped-4Scalar expansion + UDOT

V4 processes eight dimensions per step. Each pdep_u64 expands four packed MinMax4 bytes, VNNI accumulates two four-byte groups per query row, and adjacent accumulator lanes are combined before compensation.

The micro-kernel enters the selected target-feature context through run_inline. This is required for LLVM to emit direct vpdpbusd instructions instead of calling intrinsic shims from the contraction loop.

API

let kernel = build_minmax_max_sim(MaxSimIsa::Auto, query_minmax8,BoxErase)?;letmut scores = vec![0.0; kernel.nrows()];
kernel.compute_max_sim(doc_minmax4,&mut scores)?;

Performance

Workload: 1,000 documents, 16 query vectors x 16 document vectors x 250 dimensions. Query packing is performed once and excluded. All implementations produced identical results.

PlatformExisting AutoScalarV3V4Neon
Intel Xeon Platinum 8370C11.25 us/doc7.66 us/doc1.43 us/doc0.53 us/doc-
Snapdragon X Elite X1E8010018.12 us/doc2.33 us/doc--1.20 us/doc
Optimized pathSpeedup vs Existing
x86-64 V37.87x
x86-64 V421.2x
ARM64 Neon15.1x

On x86-64, Grouped-8 V4 is approximately 32% faster than the best Grouped-4 V4 variant. V3 retains AVX2 nibble expansion because it is within about 2% of BMI2 on this Intel CPU while avoiding slow pdep implementations on older AMD CPUs supported by V3.

Validation

cargo test -p diskann-quantization --release --lib minmax::multi::factory::tests
cargo clippy -p diskann-quantization --all-targets -- -D warnings
cargo check -p diskann-quantization --target aarch64-pc-windows-msvc

Scalar, V3, V4, Neon, and Auto match the existing MinMax8 x MinMax4 implementation across tested dimensions, row counts, and panel tails. Generated assembly contains direct vpdpbusd on V4 and direct udot on ARM64 Neon.

Implement MinMax8 query by MinMax4 document matrix kernels with Scalar, AVX2, AVX-512, and Neon paths.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@partychen
juchen-ms (partychen) marked this pull request as draft September 4, 2026 16:57
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use architecture intrinsics directly in the matrix kernel and restore unrelated distance and diskann-wide changes.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Reuse diskann-wide operations where available and handle unsupported ISAs in tests.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pack queries with grouped slice copies, build document panels in one pass, and consume accumulators while borrowing metadata. Initialize scores within each query block and extend tail coverage.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for freeto 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.

1 participant

@partychen