mirror of
				https://github.com/ggml-org/llama.cpp.git
				synced 2025-10-31 08:51:55 +00:00 
			
		
		
		
	 7a32fcb3b2
			
		
	
	7a32fcb3b2
	
	
	
		
			
			* ggml : add Q8_0 quantization format (rename the old one to Q8_1) * tests : fix test-quantize-fns * ggml : finalize Q8_0 implementation * ggml : use q4_0_q8_0 and q4_2_q8_0 * ggml : fix Q8_0 dot product bug (ARM) * ggml : Q8_0 unroll x2 * ggml : fix bug - using wrong block type * ggml : extend quantize_fns_t with "vec_dot_type" * ggml : fix Q8_0 to use 255 values out of 256 * ggml : fix assert using wrong QK4_2 instead of QK4_3
		
			
				
	
	
		
			43 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| #include <cublas_v2.h>
 | |
| #include <cuda_runtime.h>
 | |
| 
 | |
| #ifdef  __cplusplus
 | |
| extern "C" {
 | |
| #endif
 | |
| 
 | |
| #define CUDA_CHECK(err)                                                                 \
 | |
|     do {                                                                                \
 | |
|         cudaError_t err_ = (err);                                                       \
 | |
|         if (err_ != cudaSuccess) {                                                      \
 | |
|             fprintf(stderr, "CUDA error %d at %s:%d: %s\n", err_, __FILE__, __LINE__,   \
 | |
|                 cudaGetErrorString(err_));                                              \
 | |
|             exit(1);                                                                    \
 | |
|         }                                                                               \
 | |
|     } while (0)
 | |
| 
 | |
| #define CUBLAS_CHECK(err)                                                               \
 | |
|     do {                                                                                \
 | |
|         cublasStatus_t err_ = (err);                                                    \
 | |
|         if (err_ != CUBLAS_STATUS_SUCCESS) {                                            \
 | |
|             fprintf(stderr, "cuBLAS error %d at %s:%d\n", err_, __FILE__, __LINE__);    \
 | |
|             exit(1);                                                                    \
 | |
|         }                                                                               \
 | |
|     } while (0)
 | |
| 
 | |
| extern cublasHandle_t g_cublasH;
 | |
| extern cudaStream_t   g_cudaStream;
 | |
| 
 | |
| void   ggml_init_cublas(void);
 | |
| void * ggml_cuda_pool_malloc(size_t size, size_t * actual_size);
 | |
| void   ggml_cuda_pool_free(void * ptr, size_t size);
 | |
| 
 | |
| void dequantize_row_q4_0_cuda(const void * vx, float * y, int k, cudaStream_t stream);
 | |
| void dequantize_row_q4_1_cuda(const void * vx, float * y, int k, cudaStream_t stream);
 | |
| void dequantize_row_q4_2_cuda(const void * vx, float * y, int k, cudaStream_t stream);
 | |
| void dequantize_row_q4_3_cuda(const void * vx, float * y, int k, cudaStream_t stream);
 | |
| void dequantize_row_q8_0_cuda(const void * vx, float * y, int k, cudaStream_t stream);
 | |
| 
 | |
| #ifdef  __cplusplus
 | |
| }
 | |
| #endif
 |