ggml-cpu : add LoongArch64 LASX Q4_0 repack path#25991
Open
ztsubaki wants to merge 1 commit into
Open
Conversation
choose q4_0_8x8_q8_0 repack when building with LASX support, and add optimized LASX repack gemm, gemv for it.
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.
Overview
LongArch has a LASX SIMD ISA similar to AVX2, which can be accelerated by repack. Previously, ggml-cpu only used LASX in the quantized dot product kernel on LoongArch. This PR adds a LASX kernel for the Q4_0_8x8_Q8_0 repack path for Q4_0 quantized models, with performance far exceeding the original dot product implementation and slightly higher than the OpenBLAS backend.
Additional information
quantize_mat_q8_0_4x8 is edited from x86 AVX2 implementation
Benchmark using Qwen 3.5 0.8B Q4_0 from unsloth on Loongson 3A6000 (4 core LA664)
Before(bec4772):
Current submit:
OpenBLAS backend:
Compared to before, pp512 has a 1.66x speedup, tg128 has a 1.07x speedup, and compared to OpenBLAS, pp512 is almost the same, while tg128 has a 1.11x speedup.
The perplexity was verified using the top 10% of the wiki-test2 test set on the same model and the same CPU.
CPU backend(using new LASX repack path):
OpenBLAS backend:
Requirements
Use AI to read and review the code, but did not use AI to generate the code.