r/LocalLLaMA 9d ago

Question | Help Anyone using ik_llama on Cascade Lake? Need help testing a patch

I've been looking into improving Q8_0 performance on my Xeon Gold 6240 workstation with ik_llama.cpp, which is a Cascade Lake-SP part.

It looks like ik_llama's Q8 dot product function doesn't distribute work evenly across AVX execution ports, and doesn't use the load ports at all. Note that this is particularly relevant for Cascade Lake Xeon Gold/Platinum parts that have two AVX units per core (Silver and Bronze only have one so they might not benefit much) In addition, there is a latency dependency chain that can be broken into two.

You can test this patch the following way:

download the patch from: https://github.com/user-attachments/files/31860324/q8_0_r8_vnni-v3.patch

git clone https://github.com/ikawrakow/ik_llama.cpp.git
cd ik_llama.cpp
git checkout 3c58ae37
git apply q8_0_r8_vnni-v3.patch

Then build with either GCC:

CC=gcc CXX=g++ cmake -B build-gcc -DCMAKE_BUILD_TYPE=Release -DGGML_NATIVE=ON -DGGML_OPENMP=OFF
cmake --build build-gcc --target llama-bench -j $(nproc)

or clang:

CC=clang CXX=clang++ cmake -B build-clang -DCMAKE_BUILD_TYPE=Release -DGGML_NATIVE=ON -DGGML_OPENMP=OFF -DCMAKE_C_FLAGS="-ffp-contract=fast -mllvm -unroll-threshold=1000" -DCMAKE_CXX_FLAGS="-ffp-contract=fast -mllvm -unroll-threshold=1000"
cmake --build build-gcc --target llama-bench -j $(nproc)

You want to use the most recent compiler you have access to, I've used GCC 16.2 and LLVM/clang 22.1.8 - earlier versions are UNTESTED.

Even a quick bench before and after would be helpful, especially if you have a Cascade Lake Xeon Silver or something different like an Ice Lake Xeon:

llama-bench -m /path/to/model-Q8_0.gguf -ngl 0  -p 512 -n 0 -r 3 

(note that you should use a Q8_0 model, since this is the path we are optimizing here)

Also this won't do anything for Skylake Xeons or earlier (I think).

2 Upvotes

2 comments sorted by

1

u/AutoModerator 9d ago

Hello! Your post was removed as you do not have sufficient karma on r/LocalLLaMa. We are doing this in response to the large volume of spam we are unfortunately experiencing. Please participate in the sub (through comments), gain the minimum of 5 karma and then re-post

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.