GGUFC compiles one GGUF model file into plain C99 that runs that one model on one CPU. There's no inference engine and no malloc, and the exact RAM is known before the program runs. The same output builds into a C library, a command-line chat, or an arm64 kernel image that boots in place of Linux.
Every shape is a constant and every buffer has a fixed place in one static block. The RAM is sizeof one struct, printed by the compiler.
About 40 KB of generated code plus the weights. It builds freestanding, with no libc and no libm: GGUFC ships the few functions it needs.
QEMU's -kernel or a stock U-Boot booti loads the image like Linux. It sets up its own MMU, starts the cores and answers on the serial console.
F32 builds match a pinned llama.cpp to 1e-3 on every position. Quantized builds pass a statistical gate calibrated on llama.cpp's own configurations.
Every demo runs a kernel image in QEMU on a development Mac, with no Linux, no libc and no audio stack in the VM. The sound in the videos is what QEMU recorded from the image's virtio-sound device. These are demos, not speed measurements.
The ready-made images and weights below come from release v0.2.0. The generated C sources are in examples/prebuilt. To build them you need only a C compiler and make: no Rust and no GGUF.
| File | What it is | Size | SHA-256 |
|---|
Check a download with shasum -a 256 -c SHA256SUMS. A weights.bin works for every target of its model, and each model.h holds its CRC-32. You can also rebuild every file byte for byte with ggufc convert from the GGUF. All releases
| Directory | Model | Target | Build | Tested |
|---|---|---|---|---|
smollm2-135m-q4_k_m-portable-c | SmolLM2-135M | any CPU, plain C99 | make | macOS arm64 |
smollm2-135m-q4_k_m-arm64 | SmolLM2-135M | arm64 with dotprod (Apple silicon, Cortex-A76+) | make | macOS arm64 |
qwen2.5-0.5b-q4_k_m-arm64 | Qwen2.5-0.5B | same | make | macOS arm64 |
smollm2-135m-q4_k_m-qemu | SmolLM2-135M | QEMU virt kernel image, 4 cores | make image | QEMU + HVF |
qwen2.5-0.5b-q4_k_m-qemu | Qwen2.5-0.5B | same | make image | QEMU + HVF |
smollm2-135m-q4_k_m-raspi4 | SmolLM2-135M | Raspberry Pi 4 kernel image | make image | QEMU raspi4b only |
smollm2-135m-q4_k_m-rk3588 | SmolLM2-135M | RK3588 kernel image for U-Boot | make image | builds; no hardware yet |
qwen2.5-0.5b-q4_k_m-rk3588 | Qwen2.5-0.5B | same | make image | builds; no hardware yet |
All of them use Q4_K_M and a 2048-token context. Both models are Apache-2.0. CI regenerates these sources on every push and fails if they differ from what's committed.
Pick where you want the model to run.
Run a ready-made build with a C compiler and make. On x86 or older arm64, use smollm2-135m-q4_k_m-portable-c instead.
git clone https://github.com/antonellof/ggufc && cd ggufc
cd examples/prebuilt/smollm2-135m-q4_k_m-arm64
curl -L -o weights.bin https://github.com/antonellof/ggufc/releases/download/v0.2.0/smollm2-135m-q4_k_m-weights.bin
make
./build/model -p "What is the capital of France?" # one answer
./build/model # chat in the terminal
The program is a demo around a C library: model.c and model.h are all you need to embed the model in your own program (see the API).
Build the model as an arm64 kernel and boot it in QEMU. You need clang, ld.lld and llvm-objcopy to link the image.
cd examples/prebuilt/qwen2.5-0.5b-q4_k_m-qemu
curl -L -o weights.bin https://github.com/antonellof/ggufc/releases/download/v0.2.0/qwen2.5-0.5b-q4_k_m-weights.bin
make image
qemu-system-aarch64 -M virt -accel hvf -cpu host -smp 4 -m 1G -nographic -no-reboot \
-kernel build/image/model.img -append "shutdown=1 prompt=What is the capital of France?"
Use -accel kvm on arm64 Linux. Anywhere else, use -accel tcg -cpu cortex-a76, which is slow. Leave out prompt= to chat on the console: /reset starts a new conversation and /off powers off.
The image also boots through stock U-Boot (boot.scr, then booti), exactly as on a board. tests/image/uboot.sh runs this end to end.
raspi4b at 1 and 4 cores, bit identical to the hosted build. It has not yet run on a real Pi.smollm2-135m-q4_k_m-raspi4-model.img and rename it to model.img. Or build it: make image in examples/prebuilt/smollm2-135m-q4_k_m-raspi4.start4.elf, fixup4.dat and bcm2711-rpi-4-b.dtb.config.txt:
arm_64bit=1
enable_uart=1
kernel=model.img
kernel_address=0x200000cmdline.txt, such as max_tokens=128 prompt=What is the capital of France?. Leave it empty to chat on the console instead.ggufc sdcard -o pi4.img start4.elf fixup4.dat bcm2711-rpi-4-b.dtb config.txt cmdline.txt model.img
dd if=pi4.img of=/dev/rdiskN bs=4m # or Raspberry Pi Imager, "Use custom"
To skip installing Rust for ggufc sdcard, copy the six files onto a FAT32 card instead.Full guide: examples/raspberry-pi.
smollm2-135m-q4_k_m-rk3588-model.img and smollm2-135m-q4_k_m-rk3588-boot.scr, and rename them to model.img and boot.scr. Or build the Qwen2.5 one with make image in examples/prebuilt/qwen2.5-0.5b-q4_k_m-rk3588.ggufc sdcard -o rk.img boot.scr model.img and copy it with dd. Leave U-Boot where the board keeps it, which is SPI flash on most RK3588 boards.=> setenv ggufc_args "max_tokens=128 prompt=What is the capital of France?"
=> saveenvThe image computes on the four Cortex-A76 cores and parks the A55 that U-Boot started it on. Full guide: examples/rk3588.
Compiling your own GGUF needs a stable Rust toolchain and a C compiler. Supported architectures are llama and qwen2 in F32, Q8_0 and Q4_K_M; Qwen3-ASR and Soprano cover speech. An unknown architecture, tensor or quantization is a hard error: the compiler never guesses.
cargo build --release
export PATH=$PWD/target/release:$PATH
ggufc inspect model.gguf # metadata, tensors, tokenizer
ggufc convert model.gguf --target targets/host-neon.toml --ctx 2048 -o out/model
ggufc build out/model && out/model/build/model -p "Why is the sky blue?"
# the same model as a kernel image, 4 cores
ggufc convert model.gguf --target targets/qemu-virt.toml --ctx 2048 --cores 4 -o out/img
ggufc image out/img # out/img/build/image/model.img
The converter prints the exact RAM, the weight size and every kernel it picked:
smollm2-135m-instruct-q4_k_m.gguf -> out/img (qemu-virt, ctx 2048, 30 layers, 4 cores)
RAM 94894144 bytes (90.50 MiB), sizeof(m_ctx): KV cache 90.00 MiB + activations 0.50 MiB
weights 105820672 bytes (100.92 MiB) in .rodata, crc32 2d9dc1c8
The targets are host-generic, host-neon, aarch64-neon-dotprod, qemu-virt, raspi4 and rk3588, each a short TOML file in targets/. --dump-ir <pass> prints the IR after any pass.
Run the generated model with no arguments for a terminal chat. Answers stream as they're generated, Esc stops one, and a status line after each answer shows tokens, speed and context use. Commands: /reset, /stats, /help, /quit.
Link speech models into the same program:
ggufc convert qwen2.5-0.5b-instruct-q4_k_m.gguf \
--voice soprano-1.1-80m-f32.gguf --mmproj mmproj-soprano-1.1-80m-f32.gguf \
--hear Qwen3-ASR-0.6B-Q8_0.gguf --hear-mmproj mmproj-Qwen3-ASR-0.6B-Q8_0.gguf \
--target targets/host-neon.toml --ctx 1024 -o out/agent
make -C out/agent
out/agent/build/model -s "Hello there." hello.wav # text to speech
out/agent/build/model -a question.wav # speech to text
out/agent/build/model # chat: /listen, /hear file, /say text, /voice
Compiled for the qemu-virt-3g profile, the same three models boot as one kernel image. It records and speaks through a virtio-sound device (/listen, voice=1), using 2.16 GB of RAM, all of it static.
These numbers come from the development machine (Apple M5 Max), not a target board. Each one has a raw result file in bench/results. Speed per token is about the same as llama.cpp: decode is bound by memory bandwidth, so no speedup is claimed.
Process start to first token, hosted, against llama.cpp b12952. SmolLM2-135M Q4_K_M, 4 threads.
Peak RAM, same run.
Program code, not counting the weights.
QEMU launch to first answer byte: the kernel image against Linux 6.12 (minimal config) + llama.cpp in the same VM.
F32 builds match llama.cpp to 1e-3 on every position of 32 prompts: SmolLM2 at 6.9e-5, Qwen2.5 at 2.5e-4 and Llama 3.2 1B at 1.1e-4 (NEON). llama.cpp doesn't agree with itself across its own valid kernel configurations, so quantized builds are held to a different standard: they must not disagree with llama.cpp's default more than its other configuration does (McNemar and Mann-Whitney tests, KL < 0.01). All twelve Q8_0 and Q4_K_M builds pass. Kernel images give the same tokens and logits as the hosted build, bit for bit.
The API is fixed. Every buffer lives in one static struct and every dimension is a compile-time constant.
#include "model.h"
static m_ctx ctx; /* every buffer of the model: sizeof = M_RAM_BYTES */
int32_t ids[M_CTX]; float logits[M_VOCAB]; int n = 0;
n += m_chat_prefix(M_ROLE_USER, ids + n, M_CTX - n);
n += m_tokenize("Why is the sky blue?", ids + n, M_CTX - n);
n += m_chat_prefix(M_ROLE_END, ids + n, M_CTX - n);
n += m_chat_prefix(M_ROLE_ASSISTANT, ids + n, M_CTX - n);
m_init(&ctx);
m_eval(&ctx, ids, n, logits); /* prefill, then one call per decode step */
int32_t next = m_sample(logits, &cfg, &rng);
m_detokenize(next, text, sizeof text);
The generated code has no malloc, no recursion, no variable-length arrays and no file I/O outside the demo. It compiles clean with -std=c99 -Wall -Wextra -Wpedantic -Werror on gcc and clang. The output is deterministic: the same GGUF, target and compiler version give byte-identical files.
| Where | Status |
|---|---|
| Hosted library and chat (macOS, Linux; arm64, x86) | Works |
| Kernel image in QEMU, booted directly or by stock U-Boot | Works, bit identical to hosted at 1 and 4 cores |
| Speech in and out on the kernel image (virtio-sound) | Works in QEMU |
| Raspberry Pi 4 | Works in QEMU raspi4b; not yet on a real Pi |
| RK3588 / RK3588S boards | Boot path works in QEMU; hardware run next |
| Microcontroller instant-on (Cortex-M33 + RK3588) | Planned |
| MicroVM cells (Firecracker, Unikraft) | Planned |
Tested models: SmolLM2-135M-Instruct, Qwen2.5-0.5B-Instruct, Llama-3.2-1B-Instruct, Qwen3-ASR-0.6B and Soprano-1.1-80M. Nothing here is production ready yet.