Skip to content
hardenedlinuxPublic

About

SonicBoom is a compiler-first PyTorch alternative for language, vision, audio, and training. It builds on proven kernels and pushes performance further through compiler optimization, with native HTTP serving powered by GNU Artanis.

Topics

Resources

Stars

42 stars

Watchers

0 watching

Forks

Repository files navigation

SonicBoom

A native tensor runtime. No Python. One .so.

On a desktop RTX 3050, SonicBoom edits code at 657 tok/s with Gemma 4 E4B and 519 tok/s with Qwen2.5-7B — decode to decode, 1.39× and 1.38× llama.cpp's fastest speculative mode. Its output is identical, bit for bit, with speculation on or off; llama.cpp's differs from its own plain output on 2 of the 10 turns.

It also runs Qwen3.6-35B-A3B — 35B parameters, 3B active, 20.5 GB of weights — on the same 8 GB card, streaming its experts from pinned host memory.

SonicBoom is written from the ground up in C++ and CUDA, exposed through a stable C ABI, with GNU Guile as its first-class language. No Python interpreter, pip or wheel tree is involved in inference.

SonicBoom: fast, exact and lean. The stack runs from Guile, C or an OpenAI-compatible server through one libsonicboom.so to the runtime, the Boom IR compiler, SonicBoom's own kernels and the GPU. Each speculative step drafts tokens, verifies them in one pass with every row bit-identical to a plain decode step, and commits them unchanged; kernel choices are tuned at load and sealed.

Numbers

Code editing, speculative decoding ¹ on an RTX 3050 8 GB: the same GGUF on both engines, ten frozen turns, each a single chat-templated user message. The rate is decode-only, the median of the ten turns over three runs (llama-server's predicted_n / predicted_ms definition).

Gemma 4 E4B code editing on an RTX 3050: SonicBoom decodes 657 tok/s speculative and llama.cpp 471 tok/s, 1.39×. Output decay 0.0000% for SonicBoom, 11.93% for llama.cpp. Qwen2.5-7B code editing on an RTX 3050: SonicBoom decodes 519 tok/s speculative and llama.cpp 376 tok/s, 1.38×. Output decay 0.0000% for SonicBoom, 10.36% for llama.cpp.
Model SonicBoom llama.cpp SonicBoom / llama.cpp Identical to its plain output (SonicBoom / llama.cpp)
Gemma 4 E4B Q5_K_M 657.3 tok/s 471.3 tok/s 1.39× 10 of 10 / 8 of 10
Qwen2.5-7B-Instruct Q4_K_M 518.6 tok/s 376.2 tok/s 1.38× 10 of 10 / 8 of 10

Speculation lifts SonicBoom's own decode 14.2× on Gemma 4 E4B (46.3 → 657.3 tok/s) and 13.4× on Qwen2.5-7B (38.8 → 518.6); llama.cpp's ngram-mod mode lifts its own 10.4× (45.5 → 471.3) and 9.0× (41.6 → 376.2).

Output Decay is the share of reply text bytes that differ from the engine's own plain run: SonicBoom is at 0.0000% on both models, the same as its run-to-run floor; llama.cpp is at 11.93% on Gemma 4 E4B and 10.36% on Qwen2.5-7B.

Qwen2.5-7B-Instruct Q4_K_M, general inference, speculation off

Workload SonicBoom llama.cpp Ratio
Decode, context 512 40.6 tok/s 43.2 tok/s 0.94×
Decode, context 4K 38.3 tok/s 41.4 tok/s 0.92×
Prefill, 512-token prompt 1600 tok/s 1594 tok/s 1.00×
Prefill, 8K-token prompt 1008 tok/s 1425 tok/s 0.71×

Both runtimes run the same GGUF on the same machine: RTX 3050 8 GB (sm_86), Ryzen 5 5500, llama.cpp 43fe9c642 with -ngl 99 -fa on. Each figure in the general-inference table is the median of its harness's process runs. Prefill is wall-clock time for the whole prompt.

¹ The code-editing workload is ten turns, each asking for an edit of a 100–300-line source file; generation is greedy, as long as the file. Each turn is one user message, the instruction and the file, rendered through the model's own chat template exactly as SonicBoom's server renders it. llama.cpp runs llama-server -ngl 99 -fa on -np 1 --spec-type ngram-mod, its fastest of the eight speculative modes on this workload, and receives the same rendered message. Its identity count compares each speculative run with its non-speculative run, turn by turn; it differs on 2 of the 10 turns for both models.

Every row comes from the harness under Reproduce the table that owns it: the code-edit, decode and prefill rows from tools/bench.sh (docs/benchmarks.md); the cross-engine Output Decay figures from the Output Decay harness. Model files, checksums and the long-context tiers are in docs/benchmark.md. Models under 2B parameters are no longer benchmarked, because they have little practical use. Qwen3.6-35B-A3B, a 35B-parameter routed-expert model, runs on the same 8 GB card with its experts streamed from host memory: 18.9 tok/s on the 512-token chat set against llama.cpp's 22.0.

Reproducible

  • Same input, same output. This holds with the same version, the same GPU and the same warm-up table.
  • Speculation doesn't change the result. Turning speculative decoding on or off gives bit-identical token sequences. It is on by default.
  • Seeded sampling. The same seed and configuration give the same output.

The warm-up table is measured on your own GPU when a model loads. You can export it and import it elsewhere with sb-tune, which carries a run to another machine with the same GPU. Batched execution is not covered yet.

Details: docs/reproducibility.md.

What's new in v0.1.0

  • Routed-expert models on one card. Qwen3.6-35B-A3B runs on the 8 GB card: its experts stream from pinned host memory by direct DMA through a bounded device pool, with prefetch of predicted experts, least-used eviction and a device-memory ledger. Its gated-delta-net blocks run on new CPU and CUDA scan kernels with per-sequence state, checkpointed at prefill segment boundaries.
  • A speculative gate that prices itself. Auto prices each verify against the plain step it replaces and learns the cost curve from the requests it sees. Verify rows tile past 16 tokens, routed-expert verify rows run grouped and bit-identically, and a verify that cannot allocate falls back to the plain step.
  • Reproducible replies. The server keys a reply to a seed and reports the fingerprint — engine, build, GPU, driver, tune table and model — inside which the same request gives the same bytes. --replay-store with POST /sonicboom/replay/:id regenerates a stored reply, and tools/repro-conformance checks any OpenAI-compatible server the same way. Every reply also carries its own timing.
  • Serving. Sampling parameters travel over HTTP and the reply carries the seed it was drawn with; one model stays resident on the device and switches on request; image generation streams its steps and can be cancelled.
  • A documentation site. Generated from the sources, with full-text search over pages and symbols, extracted reference pages for every Guile module, a PyTorch-name lookup, and the models-tested record. ctest -L docs keeps the docstrings, examples, name map and site consistent.
  • One harness per metric. tools/community-bench.sh runs the canonical comparison into one log; the code-edit rate is in-process, chat-templated and decode-only, reproducible with tools/bench.sh --spec; Output Decay has its own harness, tool and charts; tools/bench-toolcall.sh covers constrained JSON tool calls.
  • A smaller binary surface. Every exported C symbol carries the boom_ prefix, and implementation symbols are hidden from the dynamic table of libsonicboom.so.
  • CUDA 13.0 is the default toolkit, and the build targets the host GPU's architecture as SASS.

Quick start

Requirements: Linux x86-64, g++-13, CMake, Ninja, CUDA 13.0 (12.0 is the minimum supported toolkit), an NVIDIA GPU (tested on sm_86), GNU Guile 3.0 with guile-json 4.7.3, and SonicCross v0.0.2 at build time. Full details are in docs/build.md.

git clone --recursive https://github.com/hardenedlinux/SonicBoom
cd SonicBoom
tools/mlir/build-mlir.sh                 # one-time: pinned LLVM/MLIR
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DSONICBOOM_USE_CUDA=ON
cmake --build build

mkdir -p models
curl -L -o models/qwen2.5-7b-instruct-1m-q4_k_m.gguf \
  https://huggingface.co/ngxson/Qwen2.5-7B-Instruct-1M-Q4_K_M-GGUF/resolve/main/qwen2.5-7b-instruct-1m-q4_k_m.gguf
LD_LIBRARY_PATH=build/core guile -L bindings/guile/scheme
(use-modules (sonicboom inference))

(define model   (load-model "models/qwen2.5-7b-instruct-1m-q4_k_m.gguf"))
(define session (make-session model 4096))
(display (generate model session "The three laws of thermodynamics are" 64))

The same calls are available from C (boom_llm_* in capi.h).

Serve an OpenAI-compatible API

The server is a GNU Artanis app; its dependencies are listed in docs/serve-openai.md.

LD_LIBRARY_PATH=build/core guile -L bindings/guile/scheme \
  bindings/guile/scheme/sonicboom/serve/app.scm \
  --model models/qwen2.5-7b-instruct-1m-q4_k_m.gguf --model-id qwen2.5-7b \
  --context-length 16384 --max-sessions 1 --port 8000
curl -s http://127.0.0.1:8000/v1/chat/completions \
  -H 'content-type: application/json' \
  -d '{"model": "qwen2.5-7b", "stream": true,
       "messages": [{"role": "user", "content": "Write the opening paragraph of a mystery novel."}]}'

Any OpenAI client, or a writing tool that speaks the OpenAI API, can use http://127.0.0.1:8000/v1 as its base URL; no API key is checked. A conversation reuses its shared prefix automatically, so asking for a revision of a long chapter only prefills the new instruction. --max-sessions 1 keeps one KV cache on an 8 GB card; raise it on larger GPUs to serve several conversations at once.

Reproduce the table

tools/community-bench.sh models/qwen2.5-7b-instruct-1m-q4_k_m.gguf \
  /path/to/llama.cpp/build/bin

This runs the four steps below in order, writes every line of their output to one log, sonicboom-bench-<datetime>.log, and prints the path at the end. (--serve adds a fifth step, the server's streamed code-edit rate; --od adds the Output Decay harness step that produces the cross-engine Output Decay and chat rows. The code-edit rate is the --spec step's, measured in-process on the same chat-templated turns llama-server receives. Which harness owns which metric is in docs/benchmarks.md.) Its first argument is the model file; pass the Gemma 4 E4B GGUF from docs/benchmark.md to reproduce the Gemma rows. Run the same steps by hand to see or adjust them:

export CUDA_VISIBLE_DEVICES=0
MODEL=models/qwen2.5-7b-instruct-1m-q4_k_m.gguf
LLAMA=/path/to/llama.cpp/build/bin
tools/sb-report.sh --model "$MODEL" --no-bench
git -C "$LLAMA" rev-parse --short HEAD
LLAMA_BIN="$LLAMA" tools/bench.sh "$MODEL" --runs 3 --spec
LLAMA_BIN="$LLAMA" tools/bench.sh "$MODEL" --runs 3 --long

Both llama-bench and llama-server come from LLAMA_BIN; add --no-llama to measure SonicBoom alone, in which case every llama.cpp cell reads skipped. The script prints its own command line, the llama.cpp version and commit, and the SM clock sampled inside each measurement window.

The --long run prints the decode and prefill rows for your GPU. The code-editing rows are the --spec step's: SonicBoom runs in-process through the Guile binding's real backend (the public C ABI, no HTTP), llama.cpp through llama-server --chat, both on the same ten frozen turns, each one user message rendered by the model's own chat template, and both decode-only from the end of prefill. The printed rate is the median of the ten turns; the pooled rate is beside it. That step also carries the SonicBoom arms' Output Decay — how much of the plain answer speculative decoding changes, measured over the replies' text bytes by tools/output-decay (0% is identical) — with the run-to-run floor, the same comparison between two runs at one setting, on the line below it. The chat rows and the cross-engine Output Decay are the --od step's, which runs every engine through one rendered prompt snapshot. The server's streamed code-edit rate is tools/bench-serve.sh MODEL --runs 3; it is listed separately, not as a ratio against llama.cpp. The protocols are described in docs/benchmarks.md and docs/benchmark.md. Post your run under the benchmark label in the issue tracker; earlier runs are in issues #1, #2, #3, #4 and #5.

Build the documentation

cmake --build build --target docs-site     # writes build/site/sonicboom/

Open build/site/sonicboom/index.html, or serve the directory with python3 -m http.server to use the search box. ctest -L docs checks the Guile docstrings, the API reference and the generated site.

The published documentation is at hardenedvault.com/sonicboom.

Thanks

Community runs keep these numbers honest beyond one card. Thanks to @svenha for the RTX 4060 Ti report in issue #1, and to @mmssix for the four-GPU sweep in issue #2 (RTX 3090 Ti, RTX 3090, RTX 4090 Laptop and RTX PRO 6000 Blackwell), which also surfaced the CUDA 12.9/13.x build and benchmark-harness fixes.

What's inside

  • Runtime. Each decode step is one CUDA Graph replay, with an on-device KV cache and exact prefix reuse: a continued prompt gives the same tokens as recomputing it from scratch.
  • Models. Dense and routed-expert families run through the same planner and backends. Qwen3.6-35B-A3B streams its experts from pinned host memory through a bounded device pool, and its recurrent blocks carry per-sequence state across prefill segments.
  • Kernels. SonicBoom's own attention kernels (boom_fattn for prefill, boom_fdec for decode and verification) and ggml-derived quantized matmuls. 8.8% of the engine's code is line-identical to llama.cpp (commit 43fe9c642), almost all of it these matmuls (measured by tools/provenance). The ggml code is MIT-attributed in NOTICE and is not linked as a dependency.
  • Compiler. An MLIR dialect, Boom IR, that lowers fused glue kernels straight to PTX. Every pass has an on/off switch.
  • Beyond LLMs. MOSS-Image text-to-image through the same C ABI, and a research route that traces Scheme models into graphs, with autograd and AdamW.

Architecture, scope and roadmap: docs/architecture.md, docs/scope.md, docs/roadmap.md.

How this is built

  • Human architectured
  • Agent: Claude Code
  • Worker: Deepseek-flash-v4.1

Commercial support

SonicBoom is developed by HardenedVault. We offer consulting on private or air-gapped LLM inference, performance tuning on your hardware, and hardened, auditable inference stacks. Contact consulting@hardenedvault.com.

License

GPL-3.0-or-later (see LICENSE). ggml/llama.cpp-derived code keeps its MIT notice (see NOTICE).

About

SonicBoom is a compiler-first PyTorch alternative for language, vision, audio, and training. It builds on proven kernels and pushes performance further through compiler optimization, with native HTTP serving powered by GNU Artanis.

Topics

Resources

Stars

42 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages