AI/TLDR

Cactus

A four-layer inference stack — quantizer, kernels, graph and engine — for running text, vision and speech models on phones, wearables and robots

Local RuntimesFreemium
Language
C++
License
Source-available (free for individuals, non-profits and organisations under $2M funding and revenue; commercial licence required above)
Coverage
1 story
$brew install cactus-compute/cactus/cactus

Overview

Cactus is a hybrid edge-cloud AI engine aimed at mobile devices and wearables. Rather than wrapping an existing runtime, it is built as four stacked layers that the project maintains itself: Cactus Quants, a rotation-and-codebook quantization scheme that takes weight tensors from 4-bit down to 1-bit; Cactus Kernels, hand-written ARM NEON SIMD kernels for matmul, attention, convolution, quantization, DSP and image processing; Cactus Graph, a zero-copy computation graph you can drive directly for tensor work; and Cactus Engine, which exposes OpenAI-compatible APIs for text, speech and vision on top of the rest.

The engine's C API covers chat completion, streaming, tool calling, transcription, embeddings, RAG and a vector index. Each generation returns telemetry alongside the text — time to first token, prefill and decode tokens per second, peak RAM, and a model confidence score. That confidence score drives the "hybrid" part: with cloud handoff enabled, a request the local model is not confident about can be routed to a hosted model instead, and the response marks whether the handoff happened.

Cactus is source-available rather than OSI open source. Its licence grants free use to individuals, students, educational institutions, registered non-profits, and organisations with both under $2M in total funding and under $2M in gross annual revenue; anyone above those thresholds needs a commercial licence from Cactus Compute, Inc. Bindings ship for Swift, Kotlin, Flutter, React Native, Python and Rust.

What it does

  • Rotation-and-codebook quantization (CQ) from 4-bit down to 1-bit, including the mixed-precision CQ3.26 and CQ2.54 formats, with published accuracy tables per bit width
  • ARM NEON SIMD kernels written for the stack, plus CPU and Metal backends selected automatically
  • OpenAI-compatible engine API covering chat, streaming, tool calling, transcription, embeddings, vision and a built-in vector index for RAG
  • Automatic cloud handoff: requests below a configurable confidence threshold are routed to a hosted model, and the response reports whether that happened
  • `cactus convert` turns a Hugging Face model into CQ weights — Liquid, Gemma, Whisper, Parakeet and Qwen families are the tested ones — and `cactus download` pulls pre-converted bundles
  • Bindings for Swift, Kotlin, Flutter, React Native, Python and Rust, so the same engine backs a native iOS app and an Android one

Getting started

The quickest look is the Homebrew CLI on a Mac; building from the repository gives you the full command set and the language bindings.

Try it from Homebrew

Two commands get a model running locally on macOS.

bashbash
brew install cactus-compute/cactus/cactus
cactus run

Build from the repository

On Ubuntu or Debian, install the build prerequisites first, then clone and source the setup script to put the `cactus` command on your path.

bashbash
sudo apt-get install python3.12 python3.12-venv python3-pip cmake \
  build-essential libcurl4-openssl-dev

git clone https://github.com/cactus-compute/cactus && cd cactus
source ./setup

Run, convert and serve models

`cactus run` downloads or converts a model if it is not already present. `cactus convert` takes any Hugging Face model to CQ weights, and `cactus serve` puts an OpenAI-compatible HTTP server in front of it.

bashbash
# chat with a model, choosing the quantization width
cactus run google/gemma-4-e2b-it --bits 4 --backend metal

# vision and audio inputs use the same command
cactus run <model> --image photo.jpg
cactus transcribe --file meeting.wav --language en

# convert your own checkpoint
cactus convert <hf-name> --bits 3

# OpenAI-compatible server on 127.0.0.1:8080
cactus serve <model> --port 8080 --confidence-threshold 0.7

Call the engine from C

The engine takes a weights folder and JSON chat messages, and writes the completion into a buffer you own. The same handle serves streaming, tool calling and transcription.

texttext
#include "cactus_engine.h"

cactus_model_t model = cactus_init(
    "path/to/weight/folder",
    "path to txt or dir of txts for auto-rag",
    false
);

const char* messages = R"([
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Summarise this in one line."}
])";

char response[4096];
int result = cactus_complete(
    model, messages, response, sizeof(response),
    R"({"max_tokens": 50})",
    nullptr, nullptr, nullptr, nullptr, 0
);

Measure it on your own device

The CLI ships a benchmark that reports prefill and decode throughput, image encode time, transcription latency and peak RAM, and can target a connected phone.

bashbash
cactus benchmark
cactus benchmark --ios
cactus benchmark --android

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Ship an assistant inside a mobile app that answers offline and only reaches for a hosted model when the local one is unsure
  • Fit a text, vision or speech model into a wearable or robot's memory budget by trading accuracy against bit width with measured numbers per task
  • Give an iOS and an Android app the same inference behaviour through the Swift, Kotlin, Flutter or React Native bindings
  • Run on-device tool calling with a small dedicated model rather than round-tripping every function call to a server

How Cactus compares

Cactus alongside other open-source local runtimes tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
Ollama★ 181kA developer-friendly tool that downloads and runs local LLMs from the terminal with a built-in OpenAI-compatible API.
llama.cpp★ 128kA C/C++ inference engine that runs LLMs in the GGUF format on CPUs, Apple Silicon, and GPUs with low memory use.
GPT4All★ 77.4kGPT4All is a free desktop app and Python client that runs large language models locally on your own computer, with no API calls or GPU required.
LocalAI★ 49.1kA self-hosted server that exposes an OpenAI-compatible API for running text, vision, voice, and image models on local hardware.
Jan★ 44.5kAn open-source desktop app that runs LLMs fully offline as a ChatGPT-style assistant on your own computer.
llmfit★ 36.6kA Rust terminal tool that inspects your CPU, RAM, GPUs and VRAM and scores which open-weight models and quantizations will actually run well on that machine, with a TUI, CLI, REST API and local-runtime integrations.
AirLLM★ 34.4kA Python inference library that keeps only one transformer layer on the GPU at a time, so a 70B model runs on a single 4GB card and a 671B MoE model on about 12GB, without quantization.
CactusA four-layer inference stack — quantizer, kernels, graph and engine — for running text, vision and speech models on phones, wearables and robots