Skip to content

feat(distance): Add AVX512-FP16 native distance kernels for Float16 data - #365

Draft
yuejiaointel wants to merge 1 commit into
intel:mainfrom
yuejiaointel:feature/avx512-fp16-native-kernel
Draft

feat(distance): Add AVX512-FP16 native distance kernels for Float16 data#365
yuejiaointel wants to merge 1 commit into
intel:mainfrom
yuejiaointel:feature/avx512-fp16-native-kernel

Conversation

@yuejiaointel

Copy link
Copy Markdown
Contributor

Summary

Adds hardware-native fp16 distance computation for CPUs with AVX512-FP16 support (Granite Rapids, Sapphire Rapids). Without this fix, the AVX512-FP16 dispatch tier on capable hardware silently fell through to a scalar generic, causing ~30% QPS regression vs gcc11 baseline.

Changes

  • distance_core.h: add AVX512_FP16 to AVX_AVAILABILITY enum
  • avx_detection.h: CPUID check for AVX512-FP16 (bit 23, was incorrectly bit 29)
  • inner_product.h / euclidean.h / cosine.h: AVX512_FP16 dispatch tier with fallback inheritance to AVX512 for unspecialized types
  • avx512_fp16.cpp: IPNativeHalfOp32 (Float16×Float16, vfmaddph, 32-lane) and IPMixedFloatToHalfOp32 (float×Float16, converts query on-the-fly to fp16)
  • cmake/multi-arch.cmake: wire avx512_fp16.cpp into cascadelake build
  • avx512.cpp: extern-template declarations for AVX512_FP16 tier

Related

Follows #361 (prefetch fence fix). Together these two PRs restore full performance on gcc-12 compiled builds with AVX512-FP16 hardware.

Adds hardware-native fp16 distance computation for CPUs with AVX512-FP16
support (Granite Rapids, Sapphire Rapids). Without this fix, the
AVX512-FP16 dispatch tier on capable hardware silently fell through to a
scalar generic, causing ~30% QPS regression vs gcc11 baseline.

Changes:
- distance_core.h: add AVX512_FP16 to AVX_AVAILABILITY enum
- avx_detection.h: CPUID check for fp16 (bit 23, not 29)
- inner_product.h/euclidean.h/cosine.h: AVX512_FP16 dispatch tier with
  fallback inheritance to AVX512 for unspecialized types
- avx512_fp16.cpp: IPNativeHalfOp32 (Float16×Float16, vfmaddph, 32-lane)
  and IPMixedFloatToHalfOp32 (float×Float16, converts query on-the-fly)
- cmake/multi-arch.cmake: wire avx512_fp16.cpp into cascadelake build
- avx512.cpp: extern-template declarations for AVX512_FP16 tier
@yuejiaointel
yuejiaointel marked this pull request as draft August 18, 2026 16:48
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.

1 participant