llama.cpp/ggml-cuda
Kawrakow 55c1b2a3bb
IQ1_M: 1.75 bpw quantization (#6302)
* iq1_m: basics

* iq1_m: basics-2

* iq1_m: CUDA dequantize works

Very 1st shot I get PPL = 9.76 for LLaMA-v2-7B.

* iq1_m: separate shifts for each group of 8 in a block

We get
PPL(LLaMA-v2-7B ) = 9.2810
PPL(LLaMA-v2-13B) = 6.8105

Not bad, but slightly higher than
  sqrt(PPL(IQ1_S) * PPL(IQ2_XXS))
which is the expected outcome given that IQ1_M is
halfway between IQ1_S and IQ2_XXS in terms of bpw.
From this, we would expect
 PPL = 9.14 for LLaMA-v2-7B
 PPL = 6.63 for LLaMA-v2-13B

* iq1_m: go to 3-bit scales

There is slight increase in PPL, but the 0.0625 bpw reduction
in size is totally worth it.

We now have
PPL(LLaMA-v2-7B ) = 9.4469 at 1.96 bpw
PPL(LLaMA-v2-13B) = 6.8717 at 1.93 bpw
PPL(LLaMA-v2-70B) = 4.8568 at 1.85 bpw

* iq1_m: scalar dot product

* iq1_m: AVX2 dot product

* iq1_m: very slightly faster AVX2 dot product

* iq1_m: ARM_NEON dot product

Works, but very slow (10.5 t/s)

* iq1_m: Metal - dequantize works, dot product does not

* iq1_m: Metal now works

About the same performance as iq1_s.

* iq1_m: minor

* iq1_m: checking pure iq1_m quantization

It is pretty bad: PPL(LLaMA-v2-7B) = 34 if we quantize output.weight
with Q4_K.

* iiq1_m: slightly faster ARM_NEON dot product

10.5 t/s -> 11.65 t/s

* iq1_m: faster ARM_NEON dot product

11.65 t/s -> 14.9 t/s

* iq1_m: another minor ARM_NEON dot product improvement

14.9 -> 15.0 t/s

* iq1_m: small PPL improvement via super-block scale adjustment

After quantizing block scales redo the super-block scale fit.

PPL(LLaMA-v2-7B ) = 9.3346
PPL(LLaMA-v2-13B) = 6.8419
PPL(LLaMA-v2-70B) = 4.8294
PPL(Mistral-7B  ) = 8.1624

* iq1_m: adapt to CUDA refactoring

* iq1_m: remove unused variable

We have progressed to warnings being errors.

* iq1_m: add to backend-ops tests

* iq1_m: fix Windows ARM

* iq1_m: use common definition of iq1m_scale_t

* cuda: assert -> NO_DEVICE_CODE

* iq1_M: PR comments

---------

Co-authored-by: Iwan Kawrakow <iwan.kawrakow@gmail.com>
2024-03-26 15:21:27 +01:00
..
acc.cu cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
acc.cuh cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
alibi.cu cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
alibi.cuh cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
arange.cu cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
arange.cuh cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
argsort.cu cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
argsort.cuh cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
binbcast.cu cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
binbcast.cuh cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
clamp.cu cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
clamp.cuh cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
common.cuh cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
concat.cu cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
concat.cuh cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
convert.cu IQ1_M: 1.75 bpw quantization (#6302) 2024-03-26 15:21:27 +01:00
convert.cuh cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
cpy.cu cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
cpy.cuh cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
dequantize.cuh cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
diagmask.cu cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
diagmask.cuh cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
dmmv.cu cuda : fix LLAMA_CUDA_F16 build (#6298) 2024-03-25 16:43:22 +02:00
dmmv.cuh cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
getrows.cu cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
getrows.cuh cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
im2col.cu cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
im2col.cuh cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
mmq.cu cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
mmq.cuh cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
mmvq.cu IQ1_M: 1.75 bpw quantization (#6302) 2024-03-26 15:21:27 +01:00
mmvq.cuh cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
norm.cu cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
norm.cuh cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
pad.cu cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
pad.cuh cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
pool2d.cu cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
pool2d.cuh cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
quantize.cu cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
quantize.cuh cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
rope.cu cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
rope.cuh cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
scale.cu cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
scale.cuh cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
softmax.cu cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
softmax.cuh cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
sumrows.cu cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
sumrows.cuh cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
tsembd.cu cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
tsembd.cuh cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
unary.cu cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
unary.cuh cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
upscale.cu cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
upscale.cuh cuda : refactor into multiple files (#6269) 2024-03-25 13:50:23 +01:00
vecdotq.cuh IQ1_M: 1.75 bpw quantization (#6302) 2024-03-26 15:21:27 +01:00