[MOD-17916] Reduce native-FP16 SIMD lanes in FP32 - #1021
Open
dor-forer wants to merge 1 commit into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## MOD-17845-simd-dispatch-hygiene #1021 +/- ##
================================================================
Coverage 97.19% 97.19%
================================================================
Files 141 141
Lines 8435 8441 +6
================================================================
+ Hits 8198 8204 +6
Misses 237 237 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dor-forer
force-pushed
the
fp16-avx512fp16-accumulator
branch
from
August 20, 2026 14:47
4788e5d to
bd65260
Compare
dor-forer
changed the base branch from
main
to
MOD-17845-simd-dispatch-hygiene
August 20, 2026 14:47
dor-forer
force-pushed
the
fp16-avx512fp16-accumulator
branch
from
August 23, 2026 07:44
bd65260 to
04aa990
Compare
dor-forer
force-pushed
the
fp16-avx512fp16-accumulator
branch
from
August 23, 2026 07:48
04aa990 to
37c7c04
Compare
dor-forer
force-pushed
the
fp16-avx512fp16-accumulator
branch
from
August 23, 2026 13:32
37c7c04 to
fd9ebd9
Compare
dor-forer
force-pushed
the
fp16-avx512fp16-accumulator
branch
from
August 23, 2026 13:52
fd9ebd9 to
930bc73
Compare
2 tasks
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.
Describe the changes in the pull request
The AVX512FP16, NEON and SVE float16 distance kernels keep their throughput-critical multiply/accumulate loops in native FP16. Before returning, each half-precision accumulator is widened separately and the horizontal reduction is completed in FP32. Inner product also performs
1.0f - dotin FP32.This is deliberately a performance-oriented compromise. It removes FP16 overflow caused solely by combining otherwise-finite SIMD lanes, without paying to widen both operands before every multiply.
AVX512FP16 scenario fixed
For dimension 32 with values of 100:
The regression covers dimensions 32, 35, 40, 64 and 128. At dimension 128 the largest per-lane partial is 40,000, while the final result is 1,280,000.
Intentional limitation
This does not make native-half kernels identical to the scalar FP32 contract:
A dimension-only blocker cannot remove those cases because safety also depends on component magnitude. The advanced randomized tests now compare against the scalar FP32 reference while retaining the existing 1% error budget, making the approximation explicit.
Performance
The hot loops retain their native instructions:
vfmaddphper 32 elements; twovcvtph2psxconversions appear only after the loop.fmla v*.8hremains in the loop;fcvtl/fcvtl2are in the final reduction.svmla_f16remains in the loop; widening and FP32 reduction happen once at the end.This avoids the full-FP32 version’s four operand conversions and two FP32 FMAs per 32 x86 elements.
A same-runner A/B against the previous native-AVX512FP16 implementation shows that the FP32 final reduction is not free. Across 104 matched IP/L2 dimension and residual cases, the old/hybrid latency ratio was 0.9700× on average and 0.9678× at the median—equivalent to about 3.1% and 3.3% higher hybrid latency, respectively. Dimensions 32–100 were commonly 5–11% slower; IP was about 2–3% slower at dimensions 256 and 1024, while some L2 cases were worse. This is the performance comparison relevant to deciding whether the additional final-reduction protection is worth keeping.
Old-vs-hybrid benchmark: https://github.com/RedisAI/VectorSimilarity/actions/runs/32647246414
The FP16-only benchmark matrix ran on an Intel Xeon Platinum 8488C with AVX512FP16. Across all 104 matched IP/L2 dimensions and residual specializations, this hybrid was 2.15× faster on average and 2.29× faster at the median than the existing AVX512F FP16-input kernel, which widens operands and accumulates in FP32.
The exceptions are also visible in the full matrix: both dimension-115 cases were about 8–10% slower, and a few 513–516 residual cases were near parity. The 10th-to-90th-percentile speedup was 1.21×–2.57×.
The same targeted workflow executed NEON, SVE and SVE2 on a Graviton4/Neoverse-V2 runner. The benchmark steps completed successfully; the workflow was intentionally cancelled only during the unrelated results-export step after logs were captured and both EC2 runners were stopped.
Benchmark: https://github.com/RedisAI/VectorSimilarity/actions/runs/32644106830
Which issue this PR fixes
Related issue
Files modified
src/VecSim/spaces/L2/L2_AVX512FP16_VL_FP16.hsrc/VecSim/spaces/IP/IP_AVX512FP16_VL_FP16.hsrc/VecSim/spaces/L2/L2_NEON_FP16.hsrc/VecSim/spaces/IP/IP_NEON_FP16.hsrc/VecSim/spaces/L2/L2_SVE_FP16.hsrc/VecSim/spaces/IP/IP_SVE_FP16.htests/unit/test_spaces.cppVerification
test_spaces: 1585/1585 passed.vfmaddph/vsubphhot loops; no FP16 horizontal add; widening occurs after the loop.armv8.2-a+sve+fp16,-Wall -Wextra -Werror: clean, with noFMLAL.+fp16fml: zeroFMLALinstructions.ARM run: https://github.com/RedisAI/VectorSimilarity/actions/runs/32642761606
Mark if applicable