Skip to content

[Feature Request]: arm64 NEON SIMD vector distance kernels (requires Go 1.27) #29495

Closed

Description

@cpegeric

Is there an existing issue for the same feature request?

  • I have checked the existing issues.

Is your feature request related to a problem?

Vector distance functions in pkg/vectorindex/metric have SIMD kernels only on amd64
(simd/archsimd, GOEXPERIMENT=simd). On arm64 (Graviton, Apple Silicon, Ampere) every
distance falls back to the pure-Go path, for both float (f32/f64) and narrow
(f16/bf16/int8/uint8) vectors.

Describe the feature you'd like

Add arm64 NEON SIMD distance kernels (L2sq, L2, L1, inner product, cosine, spherical)
for f32/f64 and the narrow types, selected by the same build contract as amd64
(ARCHSIMD=1, GOEXPERIMENT=simd), with the same finite-extreme result contract.

Describe implementation you've considered

Go 1.27's simd/archsimd adds arm64 (NEON) vector types. It also renames the amd64 slice
loaders (LoadFloat32x16Slice -> LoadFloat32x16, Store -> StoreArray) and exposes
VPSADBW / VPMADDWD, which the amd64 int8/uint8 kernels can use. So:

- go.mod moves to go 1.27.0; the SIMD files' build tags move from go1.26 to go1.27.
- Makefile enables ARCHSIMD by default on arm64 as well as x86_64.
- amd64 narrow int8/uint8 kernels use VPSADBW / VPMADDWD.

Documentation, Adoption, Use Case, Migration Strategy

Builds need Go 1.27. Every build image pinned below it with GOTOOLCHAIN=local fails with
"go.mod requires go >= 1.27.0 (running go 1.26.4; GOTOOLCHAIN=local)":

- optools/images/gpu/{Dockerfile,Dockerfile.dev}:
  golang:1.26.4-bookworm -> golang:1.27.0-bookworm (published).
- optools/images/{Dockerfile,Dockerfile.ci,Dockerfile.ci-builder,Dockerfile.dev}:
  matrixorigin/golang:1.26.4-ubuntu22.04* -> matrixorigin/golang:1.27.0-ubuntu22.04*
  (NOT published yet, tracked in #29494: 1.27.0-ubuntu22.04, 1.27.0-ubuntu22.04-matrixone-native-1).
- optools/bvt_ut/Dockerfile, optools/compose_bvt/Dockerfile.tester:
  matrixorigin/tester:go1.26.4-jdk8 -> matrixorigin/tester:go1.27.0-jdk8 (NOT published yet, tracked in #29494).
- BUILD.md / INSTALLATION.md / README.md: minimum Go 1.26.4 -> 1.27.0.

Additional information

Local toolchains with GOTOOLCHAIN=auto switch to go1.27.0 automatically under GOWORK=off
(the Makefile default). A parent go.work that pins an older go keeps a bare `go test` on
the older toolchain, where the go1.27 build tags drop every SIMD kernel.

Activity

  1. cpegeric commented on Oct 6, 2026

    @cpegeric
    ContributorAuthor

    please verify it

  2. slyunnn commented on Oct 10, 2026

    @slyunnn

    Regression and extended verification for #29495 (2026-10-10)

    Verification Environment

    • Validation source was aligned with the latest origin/main: 0ccc989731f9c2b40d31554a44ca505c656c0e62 — feat(sql): add durable cluster-scoped UUID_SHORT() (#29805). git fetch origin completed and HEAD matched origin/main.
    • Actual host: darwin/arm64 (Apple M2 Pro), Go 1.27.1, with GOEXPERIMENT=simd. The target package was built and executed directly from that checked-out ref.
    • This is an in-process vector-metric library feature, not a SQL/service-path defect. No mo-service binary, database topology, or client protocol participates in the code under test. Therefore the 2 CN / 1 TN / 1 Log service / Proxy topology and Proxy 6001, CN1 16001, and CN2 16002 endpoints were not applicable and were not used.
    • Related implementation: PR #29496, merged as 143a03b3060d6eff36f82b42d2e1f1b7566e897a, feat(vectorindex/metric): arm64 NEON SIMD distance kernels; build with Go 1.27. The arm64 NEON implementation originates from 3a49e624b2ac9a01978de648e752eb6a943ff130; the finite-extreme contract was strengthened by 26fad2c11bf65f9ddcc49aa5ae996dc9d2cb5fcf.

    What Was Covered

    • OK — go build ./pkg/vectorindex/metric completed on the verified origin/main ref with GOEXPERIMENT=simd. The Makefile defaults ARCHSIMD=1 and GOEXPERIMENT=simd for arm64.
    • OK — Full go test ./pkg/vectorindex/metric -count=1 -v passed with GOEXPERIMENT=simd in 0.755s. This included arm64 kernels across dimensions, NEON/scalar tail comparison, dimension mismatch, zero/clamp edges, cosine upper clamp, generic dispatchers, bf16/f16/int8/uint8 equivalence, narrow-value extremes, finite extremes, lane-cancellation recovery, and no-NaN assertions.
    • OK — Full go test ./pkg/vectorindex/metric -count=1 -v also passed with GOEXPERIMENT=nosimd in 1.286s, confirming the scalar fallback build and behavior.
    • OK — Direct NEON-vs-scalar l2sq benchmark passed with zero allocations: bf16 167.2 ns/op vs 482.3 ns/op (about 2.9x); f16 728.9 ns/op vs 1557 ns/op (about 2.1x); int8 123.4 ns/op vs 254.9 ns/op (about 2.1x); uint8 123.7 ns/op vs 266.5 ns/op (about 2.2x).
    • OK — The original request is a feature request rather than a product bug. The requested arm64 NEON paths are present, selectable with GOEXPERIMENT=simd, numerically checked against scalar implementations, and materially faster on the verified arm64 host.
    • Not covered — Proxy, CN1, CN2, Prepared Statement, MySQL protocol, multi-session, and multi-CN execution are not applicable to this pure in-process metric-kernel feature; no SQL was executed through any endpoint.
    • Not covered — Linux arm64-server, amd64 AVX, GPU/CUDA, and CI/TKE hardware were not available locally. These are platform-specific follow-up validations, not a failure of the verified darwin/arm64 NEON path.
    • Not covered — Engine worker/batch/block parallelism is not applicable: this feature operates on individual vectors and the package benchmark/test does not depend on rows, LIMIT, spills, indexes, network transfer, or database data volume. No large-data regression is required.

    Findings

    The arm64 NEON implementation is integrated in current main and behaves consistently with scalar reference paths across normal, boundary, mismatch, and finite-extreme cases. The direct benchmark confirms the intended performance benefit without allocations for all four narrow types. No regression or product defect was observed in the verified arm64 environment.

    MOTR / BVT Coverage

    No MOTR/BVT change was needed or created. Existing pkg/vectorindex/metric arm64 tests directly exercise the build-tag-selected NEON kernels and compare them to scalar references; an SQL MOTR case would not establish that the NEON code path was selected. Consequently, no test branch, commit, recording/replay, push, or daily-summary entry applies.

    Final Conclusion

    Fixed — PR #29496 is merged in verified origin/main, and the requested arm64 NEON SIMD metric feature passed actual build, functional, boundary, scalar-fallback, and performance validation on darwin/arm64.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions