Skip to content

Commit ab7d193

Browse files
Add GitHub data (#637)
1 parent 866c70e commit ab7d193

File tree

626 files changed

+175142
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

626 files changed

+175142
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
### 🗣️ [#100](https://github.com/ikawrakow/ik_llama.cpp/discussions/100) - New argument / env variable for GGML_SCHED_MAX_COPIES?
2+
3+
| **Author** | `Nexesenex` |
4+
| :--- | :--- |
5+
| **Created** | 2024-10-21 |
6+
| **Updated** | 2024-10-21 |
7+
8+
---
9+
10+
#### Description
11+
12+
@ikawrakow, could you set up a CLI argument (or at least an env variable, it's much simpler I guess but I'm failing to do it right) to determine GGML_SCHED_MAX_COPIES without recompiling? It impacts VRAM occupation and performances, and it'd be great to set that up conveniently for benching and customized use.
13+
14+
---
15+
16+
#### 🗣️ Discussion
17+
18+
👤 **ikawrakow** replied the **2024-10-21** at **08:29:25**:<br>
19+
20+
I haven't looked into this at all. What is it good for?
21+
22+
---
23+
24+
👤 **Nexesenex** replied the **2024-10-21** at **09:36:22**:<br>
25+
26+
It's supposed to go faster inference on multi-GPU I guess. Mainline sets it at 4, I set it at 1, because I didn't notice much improvement back in the days, but I noticed more vram consumption and gpu load.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
### 🗣️ [#104](https://github.com/ikawrakow/ik_llama.cpp/discussions/104) - Convenience improvements for llama-quantize
2+
3+
| **Author** | `Nexesenex` |
4+
| :--- | :--- |
5+
| **Created** | 2024-10-23 |
6+
| **Updated** | 2024-10-23 |
7+
8+
---
9+
10+
#### Description
11+
12+
Hey IK.
13+
14+
Here are some ideas of potential features for llama-quantize, that I'm not capable to code myself :
15+
16+
- Create a directory when it doesn't exist for the output file.
17+
18+
- Interrupt the quantization (or even **quantize each tensor in a directory**, so the quantization can be resumed on crash, or even a single series of tensor can be requantized (like attn_q weight for example, or even a function of use_more_bits if one of the part of the ternary statement deciding the quantization of a given tensor is not met when you change the quant of a part of the ternary, but not the other). The monolithic approach makes a pretty monster-file, but at the same time, wastes a lot of space, time and compute.
19+
20+
- integrate the formulas like use_more_bits (we have one, I intend to PR more of those) to the tensors that we manually specify with arguments in CLI to customize a FTYPE.
21+
22+
- A pre-check of the available space on disk before the quantization, ideally coupled with a dry-run giving the final size of the desired quant.

github-data/discussions/140-Questions about weight[j].md

Lines changed: 276 additions & 0 deletions
Large diffs are not rendered by default.

github-data/discussions/15-Will LQER improve k- and i-quants_.md

Lines changed: 293 additions & 0 deletions
Large diffs are not rendered by default.

github-data/discussions/164-Latest CPU performance comparison with llama.cpp.md

Lines changed: 766 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
### 🗣️ [#165](https://github.com/ikawrakow/ik_llama.cpp/discussions/165) - Norm RMS Epsilon
2+
3+
| **Author** | `Nexesenex` |
4+
| :--- | :--- |
5+
| **Created** | 2024-12-25 |
6+
| **Updated** | 2024-12-27 |
7+
8+
---
9+
10+
#### Description
11+
12+
While it crosses my mind..
13+
14+
@Ikawrakow : a while ago, you made some measurements with variations of Norm RMS Epsilon which showed some little benefits to offset it for <2bpw quants. It was on L2 I believe, and I wonder if it applies to other arches, and if yes, if there's some sort of "formula" which would come with it to improve the low bitrate quants themselves.
15+
16+
Just beotian thoughts.
17+
18+
And merry XMAS btw, if you celebrate it!
19+
20+
---
21+
22+
#### 🗣️ Discussion
23+
24+
👤 **ikawrakow** replied the **2024-12-27** at **17:44:24**:<br>
25+
26+
I'm travelling, so just quickly from the phone.
27+
28+
Yes, there is a small benefit from increasing rms_eps also for LlaMA-3, but only for very low-bit quants (IQ2_XXS). No, I haven't done any kind of systematic investigation.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
### 🗣️ [#166](https://github.com/ikawrakow/ik_llama.cpp/discussions/166) - Learning more LLM quantization
2+
3+
| **Author** | `robinnarsinghranabhat` |
4+
| :--- | :--- |
5+
| **Created** | 2025-01-05 |
6+
| **Updated** | 2025-03-13 |
7+
8+
---
9+
10+
#### Description
11+
12+
For beginners like me to ML, I wanted to learn what research papers guided the quantization implement in llama.
13+
14+
It might sound silly but we have separate tricks for quantization during training and during evaluation right ?
15+
16+
---
17+
18+
#### 🗣️ Discussion
19+
20+
👤 **ikawrakow** replied the **2025-01-05** at **10:37:28**:<br>
21+
22+
> For beginners like me to ML, I wanted to learn what research papers guided the quantization implement in llama.
23+
24+
I developed all quantization types in `llama.cpp` apart from the legacy quants `Q4_0, Q4_1, Q5_0, Q5_1, Q8_0` (but these are very simple round-to-nearest block-wise quants). I did not read any research papers, just went ahead and experimented. Rarely reading papers has always been my approach to research. I have found that reading what others have done influences my thinking direction and hence may prevent finding a better approach. I only go and read papers if I was not able to find a meaningful solution to a problem on my own.
25+
26+
> It might sound silly but we have separate tricks for quantization during training and during evaluation right ?
27+
28+
`llama.cpp` does not do any training, so it is always post-training quantization (PTQ). But in general there is quantization-aware training (QAT), where the model is not actually quantized during training but model weights are forced to stay within a specified range with the hope that this will give better PTQ results. The only actually quantized model training approach I'm aware of is Bitnet from Microsoft Research, where a ternary model is trained (weights are -1, 0, 1, plus a per tensor float scaling factor). More recently researchers have been utilizing fine-tuning for PTQ, where some corpus of training data is used to guide PTQ (look for, e.g., Quip#, AQLM, QTIP). This is quite different from the simple quantization approaches used in `llama.cpp` and also here in this repository, requires a full-fledged training framework such as PyTorch, powerful GPU(s), and many hours/days of GPU time.
29+
30+
---
31+
32+
👤 **robinnarsinghranabhat** replied the **2025-01-10** at **21:38:11**:<br>
33+
34+
Thank you for this humble response !
35+
36+
Now I understand it's doing inference on quantized weights.
37+
38+
But I get lost trying to understand llama cpp codebase. how should I navigate this codebase ?
39+
I am comfortable with python, machine learning concepts and understand pointers in C.
40+
But never written complex programs in C/C++.
41+
42+
Do I need to understand fundamentals concept on operating systems, comp.arch, memory-management e.t.c. ?
43+
44+
I want to be a programmar like you.
45+
46+
Sorry .. lots of questions all over the place :(
47+
48+
> 👤 **arnfaldur** replied the **2025-03-13** at **02:10:31**:<br>
49+
> Trying to understand this codebase isn't attacking the wall where it's lowest. You're probably best off finding some beginner/intermediate C++ courses online. I imagine that there are plenty available for free. You don't strictly need to understand all these fundamentals to understand what this project is doing, but you sound like you're in the *don't know what you don't know* phase and a general Computer Science course would likely get you the farthest at this point.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
### 🗣️ [#18](https://github.com/ikawrakow/ik_llama.cpp/discussions/18) - CPU beating GPU in token generation speed
2+
3+
| **Author** | `ikawrakow` |
4+
| :--- | :--- |
5+
| **Created** | 2024-08-13 |
6+
| **Updated** | 2025-04-03 |
7+
8+
---
9+
10+
#### Description
11+
12+
The [TriLM](https://huggingface.co/collections/SpectraSuite/trilms-unpacked-668d5f62afe0f4036925b1d2) ternary models are available in various sizes, so I was curious to look into prompt processing (PP) and token generation (TG) speed when the model is small enough to fit in the CPU cache. I have a Ryzen-7950X CPU with 64 MiB of L3 cache, and the 99M parameter TriLM model is 46 MiB when quantized with `IQ2_TN`. So, without further ado, lets look at a comparison between the Ryzen-7950X and an RTX-4080 in this case:
13+
14+
| backend | threads | test | t/s |
15+
| ---------- | ------: | ------------: | ---------------: |
16+
| Ryzen-7950X | 16 | pp1500 | 8268.11 ± 48.34 |
17+
| Ryzen-7950X | 4 | tg500 | 1016.65 ± 22.17 |
18+
| Ryzen-7950X | 8 | tg500 | 1224.83 ± 32.28 |
19+
| Ryzen-7950X | 16 | tg500 | 1240.54 ± 25.74 |
20+
| RTX-4080 | - | pp1500 | 110388 ± 250 |
21+
| RTX-4080 | - | tg500 | 1136.64 ± 4.99 |
22+
23+
The GPU is still much faster than the CPU for prompt processing (although the difference, which is typically a factor of ~30 between this specific GPU and CPU, has shrunk to just a factor of 13), but now the CPU beats the GPU in TG speed!
24+
25+
I also have an M2-Max laptop (the version with a 30-core GPU). Here is what we get:
26+
27+
| backend | threads | test | t/s |
28+
| ---------- | ------: | ------------: | ---------------: |
29+
| M2-Max CPU | 8 | pp1500 | 5209.27 ± 21.48 |
30+
| M2-Max CPU | 2 | tg500 | 692.87 ± 1.74 |
31+
| M2-Max CPU | 4 | tg500 | 841.48 ± 5.96 |
32+
| M2-Max CPU | 8 | tg500 | 894.73 ± 10.03 |
33+
| M2-Max GPU | 4 | pp1500 | 25824 ± 562 |
34+
| M2-Max GPU | 4 | tg500 | 464.86 ± 3.85 |
35+
36+
Also here the GPU is faster for PP (but just 5X faster), but the CPU wipes the floor with the GPU for TG, beating it close to 2X using all 8 threads, and 1.5X with just 2 threads!
37+
38+
---
39+
40+
#### 🗣️ Discussion
41+
42+
👤 **ikawrakow** replied the **2024-09-02** at **13:20:54**:<br>
43+
44+
Now that we have efficient Flash Attention (FA) implementation on the CPU via PR #32, we can compare again performance between the CPU and GPU for this tiny 99M parameter model. We get
45+
46+
| model | size | params | backend | ngl | threads | fa | test | t/s |
47+
| ------------------------------ | ---------: | ---------: | ---------- | --: | ------: | -: | ------------: | ---------------: |
48+
| IQ2_BN - 2.06 bpw TriLM | 45.89 MiB | 99.76 M | CUDA | 100 | 1 | 1 | pp1500 | 156827.38 ± 727 |
49+
| IQ2_BN - 2.06 bpw TriLM | 45.89 MiB | 99.76 M | CUDA | 100 | 1 | 1 | tg500 | 1496.37 ± 36.79 |
50+
| IQ2_BN - 2.06 bpw TriLM | 45.89 MiB | 99.76 M | CPU | 0 | 16 | 1 | pp1500 | 12133.80 ± 51.45 |
51+
| IQ2_BN - 2.06 bpw TriLM | 45.89 MiB | 99.76 M | CPU | 0 | 16 | 1 | tg500 | 1509.52 ± 9.65 |
52+
53+
TG speed is now about the same, which is still quite remarkable.
54+
55+
FA has improved CPU prompt processing speed by almost 50%, TG by 22%.
56+
57+
> 👤 **saood06** replied the **2025-04-02** at **10:36:44**:<br>
58+
> Is there a chance SpargeAttn could be implemented here. Code [here](https://github.com/thu-ml/SpargeAttn), Paper [here](https://arxiv.org/abs/2502.18137).
59+
>
60+
> If it could would it benefit speed on CPU?
61+
>
62+
> 👤 **ikawrakow** replied the **2025-04-02** at **13:44:09**:<br>
63+
> Other than the paper, is there any evidence that this works as advertised? If I did nothing else but implementing breakthroughs announced on arXiv, the day still wouldn't have enough hours.
64+
>
65+
> 👤 **saood06** replied the **2025-04-03** at **00:24:39**:<br>
66+
> >Other than the paper, is there any evidence that this works as advertised?
67+
>
68+
> Not really (there are multiple ComfyUI custom nodes that port support but not much on people using it), the paper looked interesting to me and the idea makes sense to me, but the implementation they have looks premature. The same group put out SageAttention/SageAttention2 which has been widely adopted (mostly for image/video models) and the performance matched the paper but SpargeAttn has gotten interest but not much adoption because of the state of the implmentation.
69+
>
70+
> >If I did nothing else but implementing breakthroughs announced on arXiv, the day still wouldn't have enough hours.
71+
>
72+
> Sorry.
73+
74+
---
75+
76+
👤 **ikawrakow** replied the **2024-09-08** at **07:16:59**:<br>
77+
78+
With PR #42 we get this
79+
80+
| model | size | params | backend | threads | fa | test | t/s |
81+
| ------------------------------ | ---------: | ---------: | ---------- | ------: | -: | ------------: | ---------------: |
82+
| IQ2_BN - 2.06 bpw TriLM | 45.89 MiB | 99.76 M | CPU | 16 | 1 | pp1500 | 12906.95 ± 61.04 |
83+
| IQ2_BN - 2.06 bpw TriLM | 45.89 MiB | 99.76 M | CPU | 16 | 1 | tg512 | 1563.62 ± 12.55 |
84+
85+
I.e., 56% improvement for PP and 26% improvement for TG since the original post from Aug 13!
86+
87+
I see [PR-8151](https://github.com/ggerganov/llama.cpp/pull/8151), which provides dedicated quantization for the TriLM ternary models in mainline `llama.cpp`, has been merged. Here is what we get for `TQ2_0` that corresponds to our `IQ2_TN`
88+
89+
| model | size | params | backend | threads | fa | test | t/s |
90+
| ------------------------------ | ---------: | ---------: | ---------- | ------: | -: | ------------: | -------------------: |
91+
| TQ2_0 - 2.06 bpw ternary | 45.89 MiB | 99.76 M | CPU | 16 | 1 | pp1500 | 5187.34 ± 11.69 |
92+
| TQ2_0 - 2.06 bpw ternary | 45.89 MiB | 99.76 M | CPU | 16 | 0 | pp1500 | 5281.54 ± 53.33 |
93+
| TQ2_0 - 2.06 bpw ternary | 45.89 MiB | 99.76 M | CPU | 16 | 1 | tg500 | 1156.25 ± 18.14 |
94+
| TQ2_0 - 2.06 bpw ternary | 45.89 MiB | 99.76 M | CPU | 16 | 0 | tg500 | 1041.27 ± 21.30 |
95+
96+
Our version is 2.44X faster for PP and 35% faster for TG.

0 commit comments

Comments
 (0)