perf: add explicit SIMD types and distance kernels for f64#6540
Merged
BubbleCal merged 2 commits intolance-format:mainfrom Apr 16, 2026
Merged
perf: add explicit SIMD types and distance kernels for f64#6540BubbleCal merged 2 commits intolance-format:mainfrom
BubbleCal merged 2 commits intolance-format:mainfrom
Conversation
Adds f64x4 (256-bit) and f64x8 (512-bit / 2x256-bit) SIMD types with full support for x86_64 (AVX2/AVX-512), aarch64 (NEON), and loongarch64 (LASX). Replaces auto-vectorization-dependent f64 distance functions with explicit SIMD implementations using two-level unrolling (f64x8 main loop + f64x4 remainder + scalar tail). Functions updated: - norm_l2 for f64 (was TODO in benchmarks) - dot product for f64 - L2 distance for f64 - cosine distance for f64 (was empty impl, falling back to scalar) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
BubbleCal
approved these changes
Apr 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
f64x4andf64x8SIMD types tolance-linalgwith support for x86_64 (AVX2/AVX-512), aarch64 (NEON), and loongarch64 (LASX)Benchmark Results (Apple M-series, aarch64 NEON)
1M vectors × 1024 dimensions:
The biggest win is cosine distance, which previously had an empty
impl Cosine for f64 {}falling back to the scalar path. The explicit SIMD implementation is 31% faster.For norm_l2, dot, and L2, LLVM's auto-vectorization with the LANES=8 hint was already producing good code on this platform. The explicit SIMD ensures consistent performance across compilers and platforms rather than relying on fragile auto-vectorization hints.
Test plan
-D warnings)cargo fmtclean🤖 Generated with Claude Code