[GH-ISSUE #535] VNNI code path is compiled even on a CPU without it #215

Closed
opened 2026-10-29 21:22:44 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @biochem-fan on GitHub (Oct 27, 2026).
Original GitHub issue: https://github.com/mw00/project-maya/issues/535

When compiling the latest version (v1.1.29), I got this failure:

/tmp/cckQjjrp.s:3710: Error: unsupported instruction `vpdpbusd'

I am using Rocky Linux 9 with GCC 11.5.0. Certainly my compiler toolchain does not support VNNI (see https://github.com/opencv/opencv/issues/29840).

But my CPU is AMD EPYC 7713 (Zen3, Milan) and does not support VNNI anyway. Thus, the VNNI code path should not be selected. I guess there is a bug in the compiler flag selection. Indeed, the auto-generated build/build.ninja contains -mavx512f -mavx512bw -mavx512vl -mavx512dq -mavx512vnni -mavx512vbmi -mf16c -mfma.

How can I disable it and force the AVX2 code path? Any help would be greatly appreciated.

Originally created by @biochem-fan on GitHub (Oct 27, 2026). Original GitHub issue: https://github.com/mw00/project-maya/issues/535 When compiling the latest version (v1.1.29), I got this failure: ``` /tmp/cckQjjrp.s:3710: Error: unsupported instruction `vpdpbusd' ``` I am using Rocky Linux 9 with GCC 11.5.0. Certainly my compiler toolchain does not support VNNI (see https://github.com/opencv/opencv/issues/29840). But my CPU is AMD EPYC 7713 (Zen3, Milan) and does not support VNNI anyway. Thus, the VNNI code path should not be selected. I guess there is a bug in the compiler flag selection. Indeed, the auto-generated `build/build.ninja` contains `-mavx512f -mavx512bw -mavx512vl -mavx512dq -mavx512vnni -mavx512vbmi -mf16c -mfma`. How can I disable it and force the AVX2 code path? Any help would be greatly appreciated.
Author
Owner

@biochem-fan commented on GitHub (Oct 27, 2026):

As a temporary workaround, I installed the latest GCC from conda.

conda install -c conda-forge gcc_linux-64 gxx_linux-64

Compilation proceeded further than before but failed in the last step:

x86_64-conda-linux-gnu-ld: failed to set dynamic section sizes: bad value

This usually means a missing -fPIC flag but I am not sure why others do not have this problem.

<!-- gh-comment-id:6435524195 --> @biochem-fan commented on GitHub (Oct 27, 2026): As a temporary workaround, I installed the latest GCC from conda. ``` conda install -c conda-forge gcc_linux-64 gxx_linux-64 ``` Compilation proceeded further than before but failed in the last step: ``` x86_64-conda-linux-gnu-ld: failed to set dynamic section sizes: bad value ``` This usually means a missing `-fPIC` flag but I am not sure why others do not have this problem.
Author
Owner

@mw00 commented on GitHub (Oct 27, 2026):

Thanks for the report. The flags are on purpose: that one file is always built with AVX-512, and the engine picks its kernel at run time, so on your EPYC 7713 the AVX2 path runs. The real problem was the toolchain: Rocky 9's GCC 11 + binutils 2.35 can't assemble that instruction. From v1.1.34 the build checks this at configure time. If the assembler can't do it, the file is built with AVX-512 BW instructions that give the same sums. No action needed on your side - a plain ./setup.sh with the system GCC should build.

The conda error (failed to set dynamic section sizes: bad value) comes from mixing conda's linker with the system's libraries. With v1.1.34 you won't need the conda GCC.

Closing - please reopen if it comes back.

Released in v1.1.34: https://github.com/mw00/project-maya/releases/tag/v1.1.34

<!-- gh-comment-id:6456003722 --> @mw00 commented on GitHub (Oct 27, 2026): Thanks for the report. The flags are on purpose: that one file is always built with AVX-512, and the engine picks its kernel at run time, so on your EPYC 7713 the AVX2 path runs. The real problem was the toolchain: Rocky 9's GCC 11 + binutils 2.35 can't assemble that instruction. From v1.1.34 the build checks this at configure time. If the assembler can't do it, the file is built with AVX-512 BW instructions that give the same sums. No action needed on your side - a plain `./setup.sh` with the system GCC should build. The conda error (`failed to set dynamic section sizes: bad value`) comes from mixing conda's linker with the system's libraries. With v1.1.34 you won't need the conda GCC. Closing - please reopen if it comes back. Released in **v1.1.34**: https://github.com/mw00/project-maya/releases/tag/v1.1.34
Author
Owner

@biochem-fan commented on GitHub (Oct 28, 2026):

@mw00 Thank you very much for your support.
I checked out the latest version into a new directory and tried to build afresh outside conda, using the system compilers.
Unfortunately, the "Error: unsupported instruction `vpdpbusd'" message persisted.

(I cannot reopen this issue; GitHub says I do not have the permission)

<!-- gh-comment-id:6458727847 --> @biochem-fan commented on GitHub (Oct 28, 2026): @mw00 Thank you very much for your support. I checked out the latest version into a new directory and tried to build afresh outside conda, using the system compilers. Unfortunately, the "Error: unsupported instruction `vpdpbusd'" message persisted. (I cannot reopen this issue; GitHub says I do not have the permission)
Author
Owner

@biochem-fan commented on GitHub (Oct 28, 2026):

I don't know why but your compiler check

check_cxx_source_compiles([=[
#include <immintrin.h>
__m256i f(__m256i a, __m256i b, __m256i c) { return _mm256_dpbusd_epi32(a, b, c); }
__m512i g(__m512i a, __m512i b, __m512i c) { return _mm512_dpbusd_epi32(a, b, c); }
int main() { return 0; }
]=] MAYA_CPU_VNNI_ASM)

surprisingly passes on our system.

So I explicitly set MAYA_CPU_VNNI_EMULATE=ON.

The problem persisted, though.

Your fix applies to src/kernels/cpu/expert.cpp but src/ds4/ds4_gguf_cpu.cpp is also problematic.

<!-- gh-comment-id:6465034319 --> @biochem-fan commented on GitHub (Oct 28, 2026): I don't know why but your compiler check ```cmake check_cxx_source_compiles([=[ #include <immintrin.h> __m256i f(__m256i a, __m256i b, __m256i c) { return _mm256_dpbusd_epi32(a, b, c); } __m512i g(__m512i a, __m512i b, __m512i c) { return _mm512_dpbusd_epi32(a, b, c); } int main() { return 0; } ]=] MAYA_CPU_VNNI_ASM) ``` surprisingly passes on our system. So I explicitly set `MAYA_CPU_VNNI_EMULATE=ON`. The problem persisted, though. Your fix applies to `src/kernels/cpu/expert.cpp` but `src/ds4/ds4_gguf_cpu.cpp` is also problematic.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mw00/project-maya#215
No description provided.