devankit commited on
Commit
8e41467
Β·
verified Β·
1 Parent(s): 94f901a

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +94 -0
README.md ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: HuggingFaceTB/SmolLM3-3B
3
+ language:
4
+ - en
5
+ library_name: gguf
6
+ tags:
7
+ - quantization
8
+ - llama.cpp
9
+ - gguf
10
+ - smollm
11
+ - nim-kernels
12
+ - 4-bit
13
+ - 8-bit
14
+ - consumer-hardware
15
+ ---
16
+
17
+ # SmolLM3-3B β€” 4-bit GGUF with Custom Nim Kernels
18
+
19
+ Quantized versions of [SmolLM3-3B](https://huggingface.co/HuggingFaceTB/SmolLM3-3B)
20
+ running on consumer hardware under 6 GB VRAM, with custom matrix kernels written in Nim
21
+ for hot-path matrix-multiply operations.
22
+
23
+ Full write-up: [Run LLMs on a 6 GB Laptop GPU & CPU β€” Medium](https://medium.com/@devbyankit/run-llms-on-a-6-gb-laptop-gpu-cpu-smollm-3-quantization-nim-kernels-6c9cbb233930)
24
+
25
+ ---
26
+
27
+ ## What's in this repo
28
+
29
+ | File | Format | Size approx. | Use case |
30
+ |------|--------|--------------|----------|
31
+ | smolLM3-q4_k_m.gguf | Q4_K_M | ~1.9 GB | Best speed, GPU + CPU |
32
+ | smolLM3-q8_0.gguf | Q8_0 | ~3.3 GB | Near FP16 quality, fits 6 GB |
33
+
34
+ Memory footprint is reduced ~75% from the FP16 baseline.
35
+
36
+ ---
37
+
38
+ ## Performance (512-token prompt, averaged over 3 runs)
39
+
40
+ | Configuration | Prompt Processing | Text Generation | VRAM / RAM |
41
+ |--------------|-------------------|-----------------|------------|
42
+ | 4-bit GPU | 11.25 tok/s | **14.60 tok/s** | ~5.5 GB VRAM |
43
+ | 8-bit GPU | 2.57 tok/s | 12.65 tok/s | ~5.8 GB VRAM |
44
+ | 4-bit CPU | 2.38 tok/s | 15.37 tok/s | ~3–4 GB RAM |
45
+ | 8-bit CPU | 7.79 tok/s | 11.83 tok/s | ~3–4 GB RAM |
46
+
47
+ Hardware used: NVIDIA GPU with 6 GB VRAM, Windows, CUDA 12.4.
48
+
49
+ ---
50
+
51
+ ## How to run
52
+
53
+ ```bash
54
+ # 4-bit GPU
55
+ llama-cli.exe -m smolLM3-q4_k_m.gguf -ngl 36 -n 256 --temp 0.7 \
56
+ --repeat-penalty 1.1 --color -sys "you are a helpful assistant"
57
+
58
+ # 8-bit CPU
59
+ llama-cli.exe -m smolLM3-q8_0.gguf -ngl 0 -n 256 --temp 0.7
60
+ ```
61
+
62
+ Requires [llama.cpp](https://github.com/ggerganov/llama.cpp) 0.3.14+ built with CUDA
63
+ support for GPU runs.
64
+
65
+ ---
66
+
67
+ ## Custom Nim Kernels
68
+
69
+ The repo ships two companion DLLs β€” `libsmolkernels_q4.dll` and `libsmolkernels_q8.dll`
70
+ β€” written in Nim, compiled with `-O3` and ORC memory management. They implement a
71
+ custom dequantization + matrix-multiply path (`mulQ4Mat` / `mulQ8Mat`) that is
72
+ dynamically loaded by a patched `main.cpp` at runtime based on the detected model type.
73
+ llama-cli.exe detects "q4_k_m" in filename β†’ loads libsmolkernels_q4.dll β†’ mulQ4Mat()
74
+ llama-cli.exe detects "q8_0" in filename β†’ loads libsmolkernels_q8.dll β†’ mulQ8Mat()
75
+ Full build instructions, kernel source code, and the main.cpp patch are in the
76
+ Medium article linked above.
77
+
78
+ ---
79
+
80
+ ## System requirements
81
+
82
+ - NVIDIA GPU 4 GB+ VRAM (for GPU runs), or 8 GB+ RAM (for CPU runs)
83
+ - CUDA Toolkit 12.0+
84
+ - llama.cpp 0.3.x+
85
+ - Windows (DLL-based kernel loader); Linux port straightforward with .so
86
+
87
+ ---
88
+
89
+ ## Related project
90
+
91
+ This work is the research foundation for
92
+ [QBench CLI](https://github.com/AnkitTsj/qbench) β€” a C++ command-line tool that
93
+ automates LLM quantization workflows, model selection, and hardware compatibility
94
+ checks using the same quantization and kernel techniques developed here.