11---
2+ title : Litespark-Inference
3+ draft : true
4+
5+ description : Install Litespark-Inference on Arm or x86 Linux and Apple silicon macOS to run BitNet ternary LLMs on the CPU.
6+
7+ minutes_to_complete : 10
8+
9+ author :
10+ - Nii Osae Osae Dade
11+ - Tony Morri
12+ - Sayandip Pal
13+ official_docs : https://github.com/Mindbeam-AI/Litespark-Inference
14+
15+
216additional_search_terms :
317- BitNet
418- ternary
@@ -7,60 +21,65 @@ additional_search_terms:
721- CPU
822- Arm
923- Graviton
10- - Apple silicon
24+ - Apple Silicon
1125- Python
1226
13- layout : installtoolsall
14- minutes_to_complete : 10
15- author :
16- - Nii Osae Osae Dade
17- - Tony Morri
18- - Sayandip Pal
1927multi_install : false
2028multitool_install_part : false
21- official_docs : https://github.com/Mindbeam-AI/Litespark-Inference
29+
2230test_images :
2331- ubuntu:latest
2432test_link : null
2533test_maintenance : true
26- title : Litespark-Inference
27- description : Install Litespark-Inference on Arm or x86 Linux and Apple silicon macOS to run BitNet ternary LLMs on the CPU.
34+
2835tool_install : true
2936weight : 1
37+ layout : installtoolsall
3038---
3139
3240[ Litespark-Inference] ( https://github.com/Mindbeam-AI/Litespark-Inference )
3341is an open-source CPU inference runtime for
3442[ BitNet b1.58] ( https://arxiv.org/abs/2402.17764 ) ternary-weight LLMs. A
3543single ` pip install ` reads your CPU's feature flags and compiles the
36- right C++ kernel for it - NEON + SDOT on Arm, AVX-512/VNNI or AVX2+FMA
37- on x86. You do not pick the kernel; it picks itself.
44+ right C++ kernel for it using NEON and SDOT on Arm or AVX-512/VNNI and AVX2+FMA
45+ on x86. This saves you from needing to pick the right C++ kernel for best performance.
3846
3947## What do I need before installing Litespark-Inference?
4048
41- - ** Python 3.10 or newer. ** Check with ` python3 --version ` .
42- - ** A C++ toolchain** ( ` clang ` or ` g++ ` ). Already present on most
43- developer machines; install steps per platform are below.
44- - ** About 5 GB of free disk. ** The BitNet-2B model downloads from
45- Hugging Face on first run.
49+ - Python 3.10 or newer, you can run ` python3 --version ` to check your version
50+ - A C++ toolchain such as ` clang ` or ` g++ `
51+ - About 5 GB of free disk
52+
53+ The BitNet-2B model is downloaded from Hugging Face on your first run.
4654
4755It is good practice to install into a clean virtual environment so the
4856install does not conflict with anything else on your machine:
4957
50- ``` console
58+ If you don't have Python virtual environment support installed run:
59+
60+ ``` bash
61+ sudo apt update
62+ sudo apt install python3-venv -y
63+ ```
64+
65+ Create a Python virtual environment:
66+
67+ ``` bash
5168python3 -m venv .venv
5269source .venv/bin/activate
5370python -m pip install --upgrade pip wheel setuptools
5471```
5572
56- Then follow the section for your platform.
73+ Next, follow the section for your platform, Linux or macOS .
5774
58- ## How do I install Litespark-Inference on Arm or x86 Linux?
75+ ## How do I install Litespark-Inference on Arm Linux?
5976
6077The released package builds the correct kernel for your CPU
61- automatically - AVX-512 with an AVX2+FMA fallback on x86, and NEON +
78+ automatically. It uses NEON and
6279SDOT on Arm (Graviton 2/3/4, Ampere, Neoverse N1/N2/V1/V2, Raspberry
63- Pi 5). Install the C++ toolchain, then the package:
80+ Pi 5).
81+
82+ For Ubuntu/Debian distributions, install the C++ toolchain, then the Litespark-Inference Python package:
6483
6584``` bash
6685sudo apt-get update
@@ -72,6 +91,7 @@ For Red Hat, Fedora, or RHEL, install the toolchain with `dnf` instead:
7291
7392``` console
7493sudo dnf install -y gcc-c++ clang ninja-build git python3-pip
94+ pip install litespark-inference
7595```
7696
7797Confirm the package imports and reports the kernel selected for your CPU:
@@ -80,35 +100,42 @@ Confirm the package imports and reports the kernel selected for your CPU:
80100python3 -c " import litespark_inference; print(litespark_inference.__version__)"
81101```
82102
103+ The version is printed:
104+
105+ ``` output
106+ 1.0.3
107+ ```
108+
83109To inspect which kernel was built, run:
84110
85- ``` console
111+ ``` bash
86112python -m litespark_inference.torchless info
87113```
88114
89115The output ends with one of the following, depending on your CPU:
90116
91117``` output
92- kernel : avx512 (torchless, extern "C" AVX-512/VNNI + OMP)
93- kernel : avx2 (torchless, extern "C" AVX2+FMA fallback + OMP)
94- kernel : neon (torchless, extern "C" NEON SDOT)
118+ litespark_inference.torchless
119+ platform : Linux aarch64
120+ python : 3.12.3
121+ kernel : /home/ubuntu/.venv/lib/python3.12/site-packages/litespark_inference/torchless/_matmul_lut_neon.cpython-312-aarch64-linux-gnu.so
122+ OpenMP : True (max_threads=8)
123+ Accelerate: False
95124```
96125
97126## How do I install Litespark-Inference on Apple silicon macOS?
98127
99128Apple's CPUs have NEON SDOT and Litespark-Inference uses it directly.
100- The only extra step versus Linux is installing ` libomp ` - Apple's
129+
130+ The only extra step versus Linux is installing ` libomp ` , Apple's
101131toolchain does not ship a built-in OpenMP runtime, and Litespark uses
102- OpenMP for multi-threading inside the kernel:
132+ OpenMP for multi-threading inside the kernel.
133+
134+ Install Xcode command-line tools, the full Xcode is not required:
103135
104136``` console
105- # Xcode command-line tools (one-time setup; no full Xcode required)
106137xcode-select --install
107-
108- # libomp via Homebrew
109138brew install libomp
110-
111- # Install the released package from PyPI
112139pip install litespark-inference
113140```
114141
@@ -118,18 +145,22 @@ Verify the install:
118145python -m litespark_inference.torchless info
119146```
120147
121- Expected output includes:
148+ The expected output includes:
122149
123150``` output
124- kernel : neon (torchless, extern "C" NEON SDOT)
125- OpenMP : True (max_threads=...)
151+ litespark_inference.torchless
152+ platform : Darwin arm64
153+ python : 3.14.5
154+ kernel : .venv/lib/python3.14/site-packages/litespark_inference/torchless/_matmul_lut_neon.cpython-314-darwin.so
155+ OpenMP : True (max_threads=12)
156+ Accelerate: True
126157```
127158
128- If ` OpenMP : False ` , the build did not find Homebrew's ` libomp ` . The
159+ If you see ` OpenMP : False ` , the build did not find Homebrew's ` libomp ` . The
129160most common cause is that Homebrew is installed under ` /opt/homebrew `
130- (the Apple silicon default) but ` pip install ` ran in an environment that
131- hides it. Re-running ` pip install litespark-inference ` from a normal
132- shell usually fixes it.
161+ (the Apple Silicon default) but ` pip install ` ran in an environment that
162+ hides it. Re-run ` pip install litespark-inference ` from a normal
163+ shell to fix it.
133164
134165## How do I install from source?
135166
@@ -144,14 +175,31 @@ pip install -e .
144175
145176## Sanity-check
146177
147- On all platforms, the same one-liner generates text. The first run
148- downloads ` microsoft/bitnet-b1.58-2B-4T-bf16 ` from Hugging Face (around
149- 4.5 GB into ` ~/.cache/huggingface/hub ` ); later runs start instantly:
178+ On all platforms, the same command can be used.
179+
180+ The first run downloads the model weights (around 4.5 GB into
181+ ` ~/.cache/huggingface/hub ` ). Subsequent runs do not need to download
182+ again.
150183
151184``` console
152185litespark-inference generate "Hello, world!" --max-tokens 16
153186```
154187
155- You are now ready to run BitNet-2B. Continue with the
156- [ Accelerate LLM inference on Arm CPUs with Litespark-Inference] ( /learning-paths/laptops-and-desktops/litespark-inference/ )
157- Learning Path.
188+ The output is similar to:
189+
190+ ``` output
191+ Prompt (36 tokens): 'System: You are Litespark, a helpful AI assistant running locally. Provide accurate, concise, and practical answers.<|eot_id|>User: Hello, world!<|eot_id|>Assistant: '
192+ Prefill...
193+ 36 tokens in 0.40s (90.09 tok/s)
194+ Generate:
195+ Hello! How can I assist you today?
196+
197+ Generated 9 tokens in 0.29s (31.58 tok/s)
198+
199+ --- output ---
200+ Hello! How can I assist you today?
201+ ```
202+
203+ You are now ready to run BitNet-2B.
204+
205+ Continue with [ Accelerate LLM inference on Arm CPUs with Litespark-Inference] ( /learning-paths/laptops-and-desktops/litespark-inference/ ) to learn more.
0 commit comments