Skip to content

fix(linalg): preserve half-kernel fallback on AVX-512 hosts - #8877

Open
lance-gatefixer[bot] wants to merge 1 commit into
mainfrom
gatekeeper/fix-8876-1
Open

fix(linalg): preserve half-kernel fallback on AVX-512 hosts#8877
lance-gatefixer[bot] wants to merge 1 commit into
mainfrom
gatekeeper/fix-8876-1

Conversation

@lance-gatefixer

Copy link
Copy Markdown
Contributor

Root cause

SIMD_SUPPORT reports one exclusive tier. An Avx512FP16 host therefore never reaches match arms limited to Avx2 | Avx512, and falls through to scalar f16/bf16 implementations whenever the optional Sapphire Rapids C object could not be compiled—even though the fallback x86 object is present.

Fix

  • Centralize half-precision backend selection and route AVX-512 tiers to the fallback object only when its actual ISA requirements are available (F16C+FMA for f16, AVX2+FMA for bf16).
  • Preserve the existing 1e-6 f16 L2 accuracy contract with lane-partitioned AVX2 reductions.
  • Check cosine input lengths before every newly reachable FFI call and cover the selector with a host-independent dispatch matrix.

Validation

  • cargo test --profile ci -p lance-linalg --lib --features fp16kernels (470 passed, 1 ignored)
  • Forced both optional AVX-512 C builds to fail, then ran cargo test --profile ci -p lance-linalg --lib f16 --features fp16kernels (34 passed, 1 ignored)
  • cargo clippy --all --tests --benches -- -D warnings
  • cargo clippy -p lance-linalg --all-targets --features fp16kernels -- -D warnings
  • cargo fmt --all -- --check

Fixes #8876

@github-actions github-actions Bot added A-index Vector index, linalg, tokenizer bug Something isn't working labels Aug 30, 2026

@lance-gatekeeper lance-gatekeeper Bot 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.

Gate recommendation: approve.

The exclusive-tier fallback is fixed at the right boundary: native kernels remain preferred, each half type requires its emitted fallback ISA, and scalar remains the safe default. The testable selector covers the build/tier matrix, while the newly reachable path preserves the existing f16 accuracy and equal-length FFI contracts.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-index Vector index, linalg, tokenizer bug Something isn't working K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: AVX-512FP16 hosts fall to scalar f16 and bf16 kernels when the AVX-512 C kernel was not built

0 participants