GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — IQ2_XXS: much faster CPU prompt processing by ikawrakow · Pull Request #515 · ikawrakow/ik_llama.cpp

Conversation

@ikawrakow

@ikawrakow ikawrakow commented Jun 11, 2025

Copy link
Copy Markdown
Owner

While experimenting with the trellis quants in PRs #505 and #511, I realized that CPU matrix multiplications (GEMM) for quants that are slow to unpack and make ready for int8_t dot products (as the trellis quants are) are much faster if one unpacks a given number of rows to, e.g., Q8_0_R8, and then uses the Q8_0_R8 x Q8_2_X4 GEMM to perform the multiplication with all columns of the right matrix.

This PR applies the approach of #505/#511 to IQ2_XXS (AVX2/Zen4 only). We get nearly 3X improvement in PP performance compared to IQ2_XXS on the main branch, and 2X compared to IQ2_XXS_R4!

The same approach can be used out-of-the-box for IQ3_XXS (left for a follow up PR).

IQ2_XS, IQ2_S and IQ3_S use blocks of 16, so one would need a new row-interleaved 8-bit type with blocks of 16 for those.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Iwan Kawrakow added 6 commits June 10, 2025 10:47
Iwan Kawrakow
Much faster iq2_xxs GEMM
169ef39
PP-512 = 290 t/s vs ~110 t/s (iq2_xxs) or 148 t/s (iq2_xxs_r4) on main.
Iwan Kawrakow
iq2_xxs: q8_2_x4 GEMM
d584d1e
Iwan Kawrakow
iq2_xxs: use template for q8_2_x4 GEMM
f247368
Iwan Kawrakow
Fix AVX2
fad8b0e
Iwan Kawrakow
Cleanup
bed683f
Iwan Kawrakow
NEON is not working yet, so still use Q8_K GEMM
415a7cf
@ikawrakow

ikawrakow commented Jun 11, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Owner Author

Here some sweep-bench tables on a Ryzen-7950X CPU for LlaMA-3.1-8B

IQ2_XXS, main branch

PP TG N_KV T_PP s S_PP t/s T_TG s S_TG t/s
512 128 0 4.793 106.82 5.452 23.48
512 128 512 4.984 102.73 6.375 20.08
512 128 1024 5.357 95.58 6.191 20.68
512 128 1536 5.062 101.15 6.290 20.35
512 128 2048 5.168 99.07 6.559 19.51

IQ2_XXS_R4

PP TG N_KV T_PP s S_PP t/s T_TG s S_TG t/s
512 128 0 3.467 147.69 5.508 23.24
512 128 512 3.764 136.03 5.964 21.46
512 128 1024 3.573 143.31 6.292 20.34
512 128 1536 3.660 139.88 6.341 20.19
512 128 2048 3.729 137.29 6.620 19.33

IQ2_XXS, PR

PP TG N_KV T_PP s S_PP t/s T_TG s S_TG t/s
512 128 0 1.778 288.03 5.484 23.34
512 128 512 1.860 275.28 5.685 22.52
512 128 1024 1.948 262.82 5.848 21.89
512 128 1536 2.040 250.93 6.158 20.78
512 128 2048 2.131 240.32 6.322 20.25
ubergarm reacted with rocket emoji
All reactions
  • 🚀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ikawrakow
ikawrakow merged commit e56061f into main Jun 11, 2025
This was referenced Jun 11, 2025
Much faster iq3_xxs GEMM via repacking to q8_0_r8 (AVX2) #516
Merged
IQ1_S: much faster CPU prompt processing #517
Merged
IQ3_S: much faster CPU prompt processing #518
Merged
Faster CPU prompt processing for Q4_K and Q5_K #525
Merged
Much faster CPU prompt processing (part 1) #531
Merged
rog77 pushed a commit to rog77/ik_llama.cpp that referenced this pull request Jul 21, 2026
@ikawrakow Iwan Kawrakow
IQ2_XXS: much faster CPU prompt processing (ikawrakow#515)
bdf1b34
* Much faster iq2_xxs GEMM

PP-512 = 290 t/s vs ~110 t/s (iq2_xxs) or 148 t/s (iq2_xxs_r4) on main.

* iq2_xxs: q8_2_x4 GEMM

* iq2_xxs: use template for q8_2_x4 GEMM

* Fix AVX2

* Cleanup

* NEON is not working yet, so still use Q8_K GEMM

---------

Co-authored-by: Iwan Kawrakow <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@ikawrakow
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.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.