Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/ggml/blob/master/src/ggml-cuda/quantize.cuh # ggml [Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685) Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `ggml / src / ggml-cuda / quantize.cuh` 70 lines ยท 3466 bytes Raw Blame History 1 #pragma once 2 3 #include "common.cuh" 4 #include "mmq.cuh" 5 6 #include 7 8 #define CUDA_QUANTIZE_BLOCK_SIZE 256 9 #define CUDA_QUANTIZE_BLOCK_SIZE_MMQ 128 10 11 static_assert(MATRIX_ROW_PADDING % CUDA_QUANTIZE_BLOCK_SIZE == 0, "Risk of out-of-bounds access."); 12 static_assert(MATRIX_ROW_PADDING % (4*CUDA_QUANTIZE_BLOCK_SIZE_MMQ) == 0, "Risk of out-of-bounds access."); 13 14 typedef void (*quantize_cuda_t)( 15 const float * x, const int32_t * ids, void * vy, 16 ggml_type type_src0, int64_t ne00, int64_t s01, int64_t s02, int64_t s03, 17 int64_t ne0, int64_t ne1, int64_t ne2, int64_t ne3, cudaStream_t stream); 18 19 void quantize_row_q8_1_cuda( 20 const float * x, const int32_t * ids, void * vy, 21 ggml_type type_src0, int64_t ne00, int64_t s01, int64_t s02, int64_t s03, 22 int64_t ne0, int64_t ne1, int64_t ne2, int64_t ne3, cudaStream_t stream); 23 24 void quantize_mmq_q8_1_cuda( 25 const float * x, const int32_t * ids, void * vy, 26 ggml_type type_src0, int64_t ne00, int64_t s01, int64_t s02, int64_t s03, 27 int64_t ne0, int64_t ne1, int64_t ne2, int64_t ne3, cudaStream_t stream); 28 29 void quantize_mmq_fp4_cuda(const float * x, 30 const int32_t * ids, 31 void * vy, 32 float * scale, 33 ggml_type type_src0, 34 bool use_aligned_float8, 35 int64_t ne00, 36 int64_t s01, 37 int64_t s02, 38 int64_t s03, 39 int64_t ne0, 40 int64_t ne1, 41 int64_t ne2, 42 int64_t ne3, 43 cudaStream_t stream); 44 45 // quantize each token once and scatter the block to its compact rows (via the inverse map) 46 void quantize_scatter_mmq_fp4_cuda(const float * x, 47 const int32_t * ids_src1_inv, 48 void * vy, 49 float * scale, 50 ggml_type type_src0, 51 bool use_aligned_float8, 52 int64_t ne00, 53 int64_t stride_token, 54 int64_t ne0, 55 int64_t n_tokens, 56 int64_t nrows_dst, 57 int n_expert_used, 58 cudaStream_t stream); 59 60 void quantize_scatter_mmq_q8_1_cuda(const float * x, 61 const int32_t * ids_src1_inv, 62 void * vy, 63 ggml_type type_src0, 64 int64_t ne00, 65 int64_t stride_token, 66 int64_t ne0, 67 int64_t n_tokens, 68 int64_t nrows_dst, 69 int n_expert_used, 70 cudaStream_t stream);