Repository navigation
Complete the U16x32 facade surface on every backend - #385
Merged
Merged
Conversation
U16x32 had a different method set on each backend, so code written against ndarray::simd could not use zero(), the u16->f32 widening, the compare masks, min/max or saturating arithmetic portably. Every backend (AVX-512, AVX2, AVX, scalar, nightly) now carries the same surface: zero, simd_min/max, saturating_add/sub, cmpeq_mask/cmpgt_mask, reduce_min/max, to_f32x16_lo/hi, the bit operators, Not, SubAssign and Default, and the widening, shift, multiply and pack methods on nightly. reduce_sum returns u16 everywhere. The new parity test also caught two AVX-512 bugs: shl/shr returned 0 for any count other than 1, 2, 4 or 8 (including 0), and pack_saturate_u8 saturated as signed and interleaved its inputs per 128-bit lane. Both now match the scalar reference. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMMjKnig6MXTd41Lf2v
…ckboard Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMMjKnig6MXTd41Lf2v
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
AdaWorldAPI
pushed a commit
to AdaWorldAPI/turbovec
that referenced
this pull request
Oct 29, 2026
Re-applies this fork's work on top of upstream 1.1.2, as one commit. The
backup branches backup/main-pre-upstream-sync-2026-10-29{,-b} keep the
original history.
search_multi_query_avx2 now uses only the ndarray::simd facade, 64 bytes
wide: one U8x64 load covers two adjacent byte groups (codes and LUT),
shuffle_bytes does the lookups, U16x32::from_u8x64_lo/hi widen into the
u16 accumulators (replacing the SUB trick), U16x32::to_f32x16_lo/hi +
F32x16::mul_add flush each FLUSH_EVERY batch, and F32x16::simd_gt prunes
against the heap minimum. Scores are bit-identical to the AVX-512 kernel.
Also:
- FORCE_AVX2_PATH forces the AVX2 kernel on AVX-512 hosts (tests and the
bench-internals feature); avx2_ndarray_simd_parity compares it with the
default kernel bit for bit, including a two-batch dim and a partial
block.
- examples/kernel_speed.rs times the native, AVX2 and scalar paths.
- ndarray fork dependency (x86_64 only, no BLAS), currently on the
claude/u16x32-facade-gaps branch until AdaWorldAPI/ndarray#385 merges.
- Toolchain 1.99.0, which the ndarray fork requires: rust-toolchain.toml,
rust-version in both crates, and the CI clippy pin, with the two lint
classes 1.99 adds to existing code allow-listed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XAqKMMjKnig6MXTd41Lf2v
7 tasks done
AdaWorldAPI
marked this pull request as ready for review
October 29, 2026 12:09
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
|
Add Carrot credits or activate Agent usage billing to use Autofix |
AdaWorldAPI
pushed a commit
to AdaWorldAPI/turbovec
that referenced
this pull request
Oct 29, 2026
… is merged Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMMjKnig6MXTd41Lf2v
AdaWorldAPI
pushed a commit
that referenced
this pull request
Oct 29, 2026
…1848 Adds section R2. Rows moved: H1 partly closed by #385 (first U16x32 parity found two AVX-512 bugs); H3 reframed (count_ones lowers to the same vpshufb nibble table on AVX2, so a rewrite would only hide it); AVX2 mask_blend set as R2 burn-down item #1 by measurement. New dots N10-N15: the two 9-bit contracts agree across repos; recall and cost were measured on different layouts; the AVX2 masked dot hides compiler-emitted shuffles the source guard cannot see; W4's ndarray half shipped in #386; the u8->i8 view and R3 are one ruling; NEON and wasm lib tests are not in CI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMPh2Seh2WLccCksAdY
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.
ndarray::simd::U16x32had a different method set on each backend, and there was no way to get fromU16x32toF32x16. Code written against the facade couldn't usezero(), min/max, saturating arithmetic, the compare masks or the u16→f32 widening portably. This gives every backend the same surface and fixes two AVX-512 bugs the new parity test found.Consumer: turbovec's AVX2 FastScan kernel, rewritten against
ndarray::simdat 64-byte width (U8x64loads →U16x32accumulators →F32x16flush). Its flush needsto_f32x16_lo/to_f32x16_hi.Added (AVX-512, AVX2, AVX-without-AVX2, scalar, nightly):
zero,simd_min/simd_max,saturating_add/saturating_subcmpeq_mask/cmpgt_maskreturning au32bitmask (laneiin biti)reduce_min/reduce_maxto_f32x16_lo/to_f32x16_hi(everyu16is exact inf32)BitAnd/BitOr/BitXor(+*Assign),Not,SubAssign,Default, which the other backends already hadfrom_u8x64_lo/from_u8x64_hi,shl/shr,mullo,pack_saturate_u8, which the other backends already hadHow each backend realizes them:
>ismax(a, b) == a && a != b, so no signed compare is involved. Reductions fold to 128 bits and finish withminpos_epu16.simd_avx.rssupplies the same methods from four 128-bit SSE quarters.Changed:
U16x32::reduce_sumreturnsu16(wrapping) on AVX-512 as well. It returnedu32there andu16on every other backend. No caller in this repo.Fixed (both pre-existing on AVX-512):
shl/shrreturned 0 for every count other than 1, 2, 4 and 8, includingshl(0). They now use the variable-countsll_epi16/srl_epi16, which also gives 0 for counts ≥ 16, matching the other backends.pack_saturate_u8usedpackus_epi16, which saturates as signed (a lane ≥ 0x8000 became 0) and interleaves its two inputs per 128-bit lane. It now usescvtusepi16_epi8per input, so bytes 0..32 come fromselfand 32..64 fromother, as on the other backends. No caller in this repo.Parity test:
simd::u16x32_facade_paritycovers every method against a plain-array reference. The corpus mixes a fixed-seed generator with the edge values 0, 1, 255, 256, 0x7FFF, 0x8000 and 0xFFFF, and checks more than 5000 pairs for the element-wise ops.target-cpu=native, AVX-512 host)--config .cargo/config-v3.toml--config .cargo/config-avx.toml,qemu-x86_64-static -cpu SandyBridge--config .cargo/config-v2.toml,qemu-x86_64-static -cpu Nehalemcargo +nightly test --features nightly-simdOther gates:
U16x32doc examples pass.cargo fmt --checkis clean, andfacet-stride-guard.sh --diff origin/masterexits 0.cargo clippy --lib -- -D warningsis clean on the default, v3 and v2 builds.mastertoo, and none of its errors is in the new code.cmpgt_maskcompute>=turns the AVX2 parity run red.Not done: no bench against scalar yet (acceptance criterion 4). The consumer PR in turbovec measures the kernel end to end.
Generated by Claude Code