Skip to content

Add Neon Squared L2 kernels for USlice2 and USlice4 - #1398

Open
pfoxARM wants to merge 8 commits into
microsoft:mainfrom
pfoxARM:pfoxARM/neon_squared-u2_squared-u4
Open

pfoxARM wants to merge 8 commits into
microsoft:mainfrom
pfoxARM:pfoxARM/neon_squared-u2_squared-u4

Conversation

@pfoxARM

@pfoxARM pfoxARM commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

What does this implement/fix? Briefly explain your changes.

  • Adds U4 Squared L2 U2U2 kernel and U4U4 Squared L2 kernel
  • Adds SIMDAbsDiff trait in diskann-wide with emulated paths and testing

Any other comments?

Tested for performance on C100 and C200 using graph-index-build-sq

@pfoxARM
pfoxARM requested review from a team and a lite review from Copilot September 14, 2026 19:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A critical codegen arity error prevents compilation, with documentation nits also unresolved.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds AArch64 Neon squared-L2 kernels for packed 2-bit and 4-bit vectors, plus SIMD absolute-difference support and benchmark coverage.

Changes:

  • Adds SIMDAbsDiff implementations, tests, and exports.
  • Adds Neon U2/U4 squared-L2 kernels and dispatch updates.
  • Registers the 2-bit scalar-quantization benchmark.
File summaries
File Summary Findings
diskann-wide/src/traits.rs Defines SIMDAbsDiff.
diskann-wide/src/test_utils/ops.rs Adds absolute-difference test support.
diskann-wide/src/reference.rs Adds scalar reference implementations.
diskann-wide/src/lib.rs Re-exports the trait.
diskann-wide/src/emulated.rs Implements and tests emulated absolute differences.
diskann-wide/src/doubled.rs Propagates the operation across doubled vectors.
diskann-wide/src/arch/aarch64/u8x16_.rs Adds Neon U8 absolute-difference support and tests.
diskann-wide/src/arch/aarch64/macros.rs Adds the Neon intrinsic wrapper macro.
diskann-quantization/src/spherical/__codegen/aarch64.rs Adds Neon spherical L2 instantiations. Critical (3 votes): Incorrect CompensatedSquaredL2::new arity causes codegen compilation failure in four entries. Nit (3 votes): Rename SquardL2 to SquaredL2.
diskann-quantization/src/bits/distances.rs Adds Neon U2/U4 squared-L2 kernels and dispatch.
diskann-benchmark/src/index/inmem/scalar.rs Registers the 2-bit benchmark. Nit (2 votes): Update the policy comment to include the 2-bit variant.
Review details

Suppressed comments (3)

diskann-quantization/src/spherical/__codegen/aarch64.rs:117

  • This L2 codegen entry point passes shift to CompensatedSquaredL2::new, but that constructor takes only dim (vectors.rs:543), so enabling the codegen feature cannot compile. Remove the unused shift parameter and call new(dim) here.
    shift: &[f32],
    dim: usize,
) -> Result<DistanceComputer, AllocatorError> {
    let reify = Reify::<_, _, AsQuery<2>, AsData<2>>::new(
        vectors::CompensatedSquaredL2::new(shift, dim),

diskann-quantization/src/spherical/__codegen/aarch64.rs:134

  • This L2 codegen entry point passes shift to CompensatedSquaredL2::new, but that constructor takes only dim (vectors.rs:543), so enabling the codegen feature cannot compile. Remove the unused shift parameter and call new(dim) here.
    shift: &[f32],
    dim: usize,
) -> Result<DistanceComputer, AllocatorError> {
    let reify = Reify::<_, _, AsData<4>, AsData<4>>::new(
        vectors::CompensatedSquaredL2::new(shift, dim),

diskann-quantization/src/spherical/__codegen/aarch64.rs:153

  • This L2 codegen entry point passes shift to CompensatedSquaredL2::new, but that constructor takes only dim (vectors.rs:543), so enabling the codegen feature cannot compile. Remove the unused shift parameter and call new(dim) here.
    shift: &[f32],
    dim: usize,
) -> Result<DistanceComputer, AllocatorError> {
    let reify = Reify::<_, _, AsQuery<4>, AsData<4>>::new(
        vectors::CompensatedSquaredL2::new(shift, dim),
  • Files reviewed: 11/11 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +94 to +98
shift: &[f32],
dim: usize,
) -> Result<DistanceComputer, AllocatorError> {
let reify = Reify::<_, _, AsData<2>, AsData<2>>::new(
vectors::CompensatedSquaredL2::new(shift, dim),
Comment on lines +39 to +41
"graph-index-sq-2-bit-f32",
imp::ScalarQuantized::<2, f32>::new().search(Topk),
)?;
DistanceComputer::new(reify, GlobalAllocator)
}

/// Instantiate the Neon SquardL2 implementation for
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.

3 participants