11---
22title : Litespark-Inference
3- draft : true
43
5- description : Install Litespark-Inference on Arm or x86 Linux and Apple silicon macOS to run BitNet ternary LLMs on the CPU.
4+ description : Install Litespark-Inference on Arm Linux and Apple silicon macOS to run BitNet ternary LLMs on the CPU.
65
76minutes_to_complete : 10
87
@@ -39,23 +38,29 @@ layout: installtoolsall
3938
4039[ Litespark-Inference] ( https://github.com/Mindbeam-AI/Litespark-Inference )
4140is an open-source CPU inference runtime for
42- [ BitNet b1.58] ( https://arxiv.org/abs/2402.17764 ) ternary-weight LLMs. A
43- single ` pip install ` reads your CPU's feature flags and compiles the
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.
41+ [ BitNet b1.58] ( https://arxiv.org/abs/2402.17764 ) ternary-weight Large Language Models (LLMs).
4642
47- ## What do I need before installing Litespark-Inference?
43+ A single ` pip install ` reads your CPU's feature flags and compiles the
44+ right C++ kernel for it using Neon and SDOT on Arm. This saves you from needing to manually pick the right C++ kernel for best performance.
4845
49- - Python 3.10 or newer, you can run ` python3 --version ` to check your version
46+ You can install Litespark-Inference on Linux and macOS.
47+
48+ ## Before you begin
49+
50+ Before installing Litespark-Inference, make sure your local machine has the following:
51+
52+ - Python 3.10 or later
5053- A C++ toolchain such as ` clang ` or ` g++ `
5154- About 5 GB of free disk
5255
53- The BitNet-2B model is downloaded from Hugging Face on your first run.
56+ To check the Python version on your machine, run ` python3 --version ` .
57+
58+ The first run downloads the BitNet-2B model from Hugging Face.
5459
55- It is good practice to install into a clean virtual environment so the
56- install does not conflict with anything else on your machine:
60+ Install Litespark-Inference into a clean virtual environment so the
61+ install doesn't conflict with anything else on your machine.
5762
58- If you don't have Python virtual environment support installed run:
63+ If you don't have Python virtual environment support installed, run:
5964
6065``` bash
6166sudo apt update
@@ -70,43 +75,46 @@ source .venv/bin/activate
7075python -m pip install --upgrade pip wheel setuptools
7176```
7277
73- Next, follow the section for your platform, Linux or macOS.
74-
75- ## How do I install Litespark-Inference on Arm Linux?
78+ ## Install Litespark-Inference on Arm Linux
7679
7780The released package builds the correct kernel for your CPU
78- automatically. It uses NEON and
79- SDOT on Arm (Graviton 2/3/4, Ampere, Neoverse N1/N2/V1/V2, Raspberry
80- Pi 5).
81+ automatically. It uses Neon and SDOT on Arm.
82+
83+ Supported CPUs include:
8184
82- For Ubuntu/Debian distributions, install the C++ toolchain, then the Litespark-Inference Python package:
85+ - AWS Graviton 2, 3, or 4
86+ - Ampere family processors
87+ - Neoverse N1, N2, V1, or V2
88+ - Raspberry Pi 5
89+
90+ For Ubuntu or Debian distributions, install the C++ toolchain, then the Litespark-Inference Python package:
8391
8492``` bash
8593sudo apt-get update
8694sudo apt-get install -y build-essential clang ninja-build git python3-pip
8795pip install litespark-inference
8896```
8997
90- For Red Hat, Fedora, or RHEL, install the toolchain with ` dnf ` instead:
98+ For Red Hat, Fedora, or RHEL, install the toolchain and package with ` dnf ` instead:
9199
92100``` console
93101sudo dnf install -y gcc-c++ clang ninja-build git python3-pip
94102pip install litespark-inference
95103```
96104
97- Confirm the package imports and reports the kernel selected for your CPU :
105+ Confirm the package imports and list the installed version of Litespark-Inference :
98106
99107``` bash
100108python3 -c " import litespark_inference; print(litespark_inference.__version__)"
101109```
102110
103- The version is printed :
111+ The output is similar to :
104112
105113``` output
1061141.0.3
107115```
108116
109- To inspect which kernel was built, run :
117+ Inspect which kernel was built for your CPU :
110118
111119``` bash
112120python -m litespark_inference.torchless info
@@ -123,29 +131,28 @@ litespark_inference.torchless
123131 Accelerate: False
124132```
125133
126- ## How do I install Litespark-Inference on Apple silicon macOS?
134+ ## Install Litespark-Inference on Apple silicon macOS
127135
128- Apple's CPUs have NEON SDOT and Litespark-Inference uses it directly.
136+ Apple's CPUs have Neon SDOT, and Litespark-Inference uses it directly.
129137
130- The only extra step versus Linux is installing ` libomp ` , Apple's
131- toolchain does not ship a built-in OpenMP runtime, and Litespark uses
132- OpenMP for multi-threading inside the kernel.
138+ Litespark uses OpenMP for multi-threading inside the kernel. However, Apple's
139+ toolchain doesn't ship a built-in OpenMP runtime. To address this, you'll need to install ` libomp ` .
133140
134- Install Xcode command-line tools, the full Xcode is not required :
141+ Install Xcode command-line tools, ` libomp ` , and the Litespark-Inference Python package :
135142
136143``` console
137144xcode-select --install
138145brew install libomp
139146pip install litespark-inference
140147```
141148
142- Verify the install :
149+ Verify that the installation was successful :
143150
144151``` console
145152python -m litespark_inference.torchless info
146153```
147154
148- The expected output includes :
155+ The output is similar to :
149156
150157``` output
151158litespark_inference.torchless
@@ -156,15 +163,19 @@ litespark_inference.torchless
156163 Accelerate: True
157164```
158165
159- If you see ` OpenMP : False ` , the build did not find Homebrew's ` libomp ` . The
160- most common cause is that Homebrew is installed under ` /opt/homebrew `
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.
166+ ### Troubleshoot missing OpenMP support
167+
168+ If you see ` OpenMP : False ` , the build didn't find Homebrew's ` libomp ` . The
169+ most common cause is that Homebrew is installed under ` /opt/homebrew ` , which is the
170+ Apple silicon default, but ` pip install ` ran in an environment that
171+ hides the directory.
164172
165- ## How do I install from source?
173+ To fix this, re-run ` pip install litespark-inference ` from a normal
174+ shell.
166175
167- To modify the runtime or kernels, install from source instead of from
176+ ## (Optional) Install Litespark-Inference from source
177+
178+ To modify the runtime or kernels, install Litespark-Inference from source rather than from
168179PyPI:
169180
170181``` console
@@ -173,17 +184,20 @@ cd Litespark-Inference
173184pip install -e .
174185```
175186
176- ## Sanity-check
177-
178- On all platforms, the same command can be used.
187+ ## Verify the Litespark-Inference installation
179188
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.
189+ To verify that Litespark-Inference works as expected, run the following command:
183190
184191``` console
185192litespark-inference generate "Hello, world!" --max-tokens 16
186193```
194+ The same command works on both Linux and macOS.
195+
196+ {{% notice Note %}}
197+ The first run downloads the model weights, around 4.5 GB, into
198+ ` ~/.cache/huggingface/hub ` . Subsequent runs don't need to download
199+ again.
200+ {{% /notice %}}
187201
188202The output is similar to:
189203
@@ -200,6 +214,8 @@ Generated 9 tokens in 0.29s (31.58 tok/s)
200214Hello! How can I assist you today?
201215```
202216
203- You are now ready to run BitNet-2B.
217+ ## Next steps
218+
219+ You're now ready to run BitNet-2B.
204220
205- Continue with [ Accelerate LLM inference on Arm CPUs with Litespark-Inference] ( /learning-paths/laptops-and-desktops/litespark-inference/ ) to learn more .
221+ To learn more, see the [ Accelerate LLM inference on Arm CPUs with Litespark-Inference] ( /learning-paths/laptops-and-desktops/litespark-inference/ ) Learning Path .
0 commit comments