mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #391] [CLOSED] iq_avx2: build the IQ2 sign table without a variable shift (BMI2 \shlx\ traps on pre-Haswell CPUs) #2617
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#2617
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/391
Author: @demetree
Created: 10/1/2026
Status: ❌ Closed
Base:
main← Head:iq-avx2-bmi2-fix📝 Commits (1)
3fcaf03iq_avx2: build the IQ2 sign table without a variable shift📊 Changes
1 file changed (+15 additions, -3 deletions)
View changed files
📝
src/kernels/cpu/iq_avx2.cpp(+15 -3)📄 Description
The bug
src/kernels/cpu/iq_avx2.cppbuilt a static lookup table with a variable shift:MSVC compiling this file with
/arch:AVX2emits BMI2shlxfor that shift — it assumes anythingwith AVX2 also has BMI2, which is true from Haswell (2013) on and false of every CPU before it.
Because
even_signsis a namespace-scopestatic, its constructor runs beforemain(). So this isnot a fault at first use, it is a fault at process start:
One
shlxin the entire linked binary — that single instruction was enough to make the engineunstartable on any pre-Haswell CPU built with MSVC. It is reached from
expert_layout_load()→native_fmt()→iq_avx2.cpp, so it is on the path for every native (IQ) pack.The fix
Store the byte instead of shifting it into place:
Identical 64-bit value: the OR of
0xFF << 8k/0x01 << 8kcontributes only byte k, so a directbyte store is the same result on the little-endian targets this file is compiled for. It leaves no
variable shift for the compiler to widen.
Verification
Built with MSVC 19.44 / CUDA 12.6,
CMAKE_CUDA_ARCHITECTURES=61-virtual,STRATA_EXPERIMENTAL_SM60=ON, for a GTX 1080 Ti (sm_61, Pascal).Before the fix the same binary listed
shlx x1and exited0xC000001D. After it, no BMI2 remains andthe engine starts.
This is independent of any AVX1 work — it is a plain startup crash, and it reproduces on pristine
0.1.31 with no other patch applied.
Why it matters even though 0.1.31 refuses these CPUs
0.1.31 added the startup refusal for CPUs without AVX2 (
d4279d5), and that refusal is after thisstatic initializer — so on MSVC the engine dies with an illegal instruction before it ever reaches the
message that would explain why. Anyone hitting this sees a crash rather than the intended diagnostic.
It also means the AVX2 baseline is real in a way the message does not convey: the file needs AVX2 for
its 256-bit kernel body, but the table build was silently requiring BMI2, which is a different
feature and arrived with the same generation only by coincidence.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.