diff options
author | Kawrakow <iwankawrakow@gmail.com> | 2024-10-24 12:20:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-24 12:20:30 +0200 |
commit | 9114078959b404899fd67e1af45f0dcbee51b47f (patch) | |
tree | 754c2a10b54df315439e86e3106779f593a49504 /ggml/src/ggml-cuda/quantize.cu | |
parent | b61cf7d0d7e7c5d971087d2f919818fbf684809e (diff) |
Fix quantized k-cache without FA (#105)
* Added Johannes' changes, still getting NaNs with quantized k-cache.
Also getting NaN's on Johannes's mainline branch.
* This fixes it
---------
Co-authored-by: Iwan Kawrakow <iwan.kawrakow@gmail.com>
Diffstat (limited to 'ggml/src/ggml-cuda/quantize.cu')
-rw-r--r-- | ggml/src/ggml-cuda/quantize.cu | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/ggml/src/ggml-cuda/quantize.cu b/ggml/src/ggml-cuda/quantize.cu index 45408ce8..65c7e5f1 100644 --- a/ggml/src/ggml-cuda/quantize.cu +++ b/ggml/src/ggml-cuda/quantize.cu @@ -84,7 +84,8 @@ static __global__ void quantize_mmq_q8_1( } } - const float d_inv = 127.0f / amax; + const float d = amax/127.f; + const float d_inv = d > 0 ? 1/d : 0.f; char4 q; q.x = roundf(xi.x*d_inv); q.y = roundf(xi.y*d_inv); @@ -106,8 +107,6 @@ static __global__ void quantize_mmq_q8_1( return; } - const float d = 1.0f / d_inv; - y[ib].d2s6[iqs/64] = d; return; @@ -117,8 +116,6 @@ static __global__ void quantize_mmq_q8_1( return; } - const float d = 1.0f / d_inv; - if (ds_layout == MMQ_Q8_1_DS_LAYOUT_DS4) { y[ib].ds4[iqs/32] = make_half2(d, sum); } else { |