Skip to main content

Module cpu

Module cpu 

Source
Expand description

Can this CPU run the llama.cpp compiled into this build?

llama.cpp’s build turns on AVX, AVX2, BMI2, FMA and F16C by default. A static build made that way dies with an illegal instruction on x86 CPUs without them (most made before 2013) the first time ggml runs. check compares what the build contains (worked out by build.rs) with what this CPU has, and LlamaEngine::load calls it before any llama.cpp code runs, so such a CPU gets Error::UnsupportedCpu instead of a crash.

With the cpu-dispatch feature ggml is built for every CPU level and picks the best one at run time, so nothing is required and check always passes. ARM builds use the target’s baseline (armv8-a on Linux, the Apple M1 level on macOS), which every CPU of that target has.

Functions§

check
Ok when this CPU can run the compiled-in llama.cpp, else Error::UnsupportedCpu. Cheap (the detection is cached), so apps can call it to decide whether to offer local models.
missing
The required instructions this CPU lacks (empty when local inference can run).
required
x86 instructions this build’s llama.cpp contains (is_x86_feature_detected! names). Empty without the llama feature, with cpu-dispatch, and on non-x86 targets.