Skip to content

cpu: AVX2 Q8_0 dot product flips signs for caller-supplied -128 #54

Description

@am17an

Upstream: ggml-org#29351

The x86 AVX2 Q8_0 dot product returns the wrong sign when the first operand is negative and the second is -128.

Confirmed on Strix, Ryzen AI MAX+ 395, Linux x86_64, upstream 84e76d8a23162eca70490da131945ebec1f09bf4.

Use the public-API repro.c from the upstream issue:

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DGGML_NATIVE=OFF -DGGML_AVX2=ON -DGGML_AVX512=OFF -DGGML_AVX_VNNI=OFF
cmake --build build --target ggml-cpu -j8
cc repro.c -Iggml/include -Lbuild/bin -lggml-cpu -lggml-base -o repro
LD_LIBRARY_PATH=build/bin ./repro

Observed: -1 * -128 yields -128 instead of 128; -128 * -128 yields -16384 instead of 16384. Three other cases pass. A separate build with AVX/AVX2/AVX512/AVX_VNNI/FMA/F16C/SSE42 disabled passes all five.

Cause: _mm256_sign_epi8(y, x) cannot represent negated -128. Introducing commit not bisected.

Scope: caller-supplied full-range int8 buffers. Standard llama.cpp activation quantization does not emit -128; ordinary model inference was not shown to fail.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions