Skip to content

Latest commit

 

History

107 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Release

https://refinefuture.ai

About

refft.cpp is a building tool to compile LLM/LMs' inference and training on the designated cloud-GPU or edge-NPU backends to a native executable including API, inference serving, training, model, ops, etc

  • Average 20%+ faster inference and training than Python/PyTorch-based inference/training(in the same quantization/precision and use cases)

  • 0 running dependencies other than Linux/Android/Mac system and GPU/NPU backends

55a6248c50bfda5f996bb47c68cced5c

🔥 Key Features

  • Native Compilation -- Compile the whole inference/training of a LLM/LM into the native executable object
  • OpenAI-Compatible API -- Seamless integration with existing tools
  • Custom Training via Plugins -- Data-loader, Optimizer, Model layers, Loss-function
  • Multi-Modal Support -- Text, vision, audio, etc
  • Native vRAM mgt -- Native mem mgt instead of GC to lower peak occ-mem and alloc-overhead
  • Mixed-precision quantization -- FP16, w4a16, w8a16, etc supported per tensor/channel/block
  • NPU dynamics -- enable NPU to support dynamic shape, MoE, control flow, flexible heterogeneous compute

🚀 Inference of LLM/LM

refft.cpp build tools compile a LLM/LM into a single native executable, one per backend: refft-hexagon today, with refft-cuda and refft-mlx coming. They all expose the same commands and the same OpenAI-compatible API, so the Quick Start below uses refft-hexagon as the example.

The previous generation of packages, built around the refft-cli / refft-server binaries, is no longer supported and is archived under Legacy.

Runtimes

Runtime Target Status
refft-hexagon Qualcomm Hexagon NPU (Snapdragon) on Android, arm64 Linux and Windows Available
refft-cuda NVIDIA GPU on x86_64 Linux Coming
refft-mlx Apple Silicon on macOS arm64 Coming

Packages

The installer picks the right package automatically. Direct downloads if you prefer:

Runtime Package Description
refft-hexagon_android-aarch64 Android arm64, Hexagon HTP runtime + DSP skel
refft-hexagon_ubuntu-arm64 arm64 Linux, Snapdragon dev kits
refft-hexagon_windows-arm64 Windows on Snapdragon

Releases are tagged vYYYY.MM.DD.NN: year, month, day, and the n-th release of that day. A Hexagon package ships one variant (v73, v81, etc) per SoC generation. Names follow refft-<runtime>_<os>-<arch>[-<variant>], so the upcoming refft-cuda_ubuntu-x86_64 and refft-mlx_macos-arm64 install and run the same way.

Quick Start

Three steps: install, run, chat.

1. Install

One command installs the newest release for your platform. No version to pick, no path to configure.

Linux, or Android from a host with adb (also works inside Termux):

curl -fsSL https://raw.githubusercontent.com/refinefuture-ai/refft.cpp/main/refft-hexagon/install.sh | sh

Windows (PowerShell):

irm https://raw.githubusercontent.com/refinefuture-ai/refft.cpp/main/refft-hexagon/install.ps1 | iex

It prints Installation complete and where the runtime landed:

Platform Default location
Linux ~/.local/share/refft-hexagon, or /opt/refft-hexagon as root
Android, pushed over adb /data/local/tmp/refft-hexagon
Windows %LOCALAPPDATA%\Programs\refft-hexagon

Options such as --prefix, --tag and --hexagon-version are documented in refft-hexagon/README.md.

2. Run

Everything is one binary — refft-hexagon — with three commands: cli, serve, bench.

The examples use refinefuture-ai/SmolVLM2-500M-Video-Instruct-REFFT, a Hexagon serving bundle. Download it first:

hf download refinefuture-ai/SmolVLM2-500M-Video-Instruct-REFFT --local-dir ~/SmolVLM2-500M-Video-Instruct-REFFT

--model points at the bundle directory, the one holding serving_manifest.json.

Linux / Termux, from the folder printed by the installer:

cd ~/.local/share/refft-hexagon
export LD_LIBRARY_PATH=$PWD/lib
export ADSP_LIBRARY_PATH=$PWD/lib
export REFFT_HEXAGON_MODULE_PATH=$PWD/lib/librefft_hexagon_v73.so   # match the .so in lib/

./bin/refft-hexagon help
./bin/refft-hexagon cli   --model ~/SmolVLM2-500M-Video-Instruct-REFFT/SmolVLM2-500M-Video-Instruct-w4.refft --backend hexagon --prompt "Who are you?" --max_new_tokens 128
./bin/refft-hexagon serve --model ~/SmolVLM2-500M-Video-Instruct-REFFT/SmolVLM2-500M-Video-Instruct-w4.refft --backend hexagon --port 8080

Android over adb:

adb push ~/SmolVLM2-500M-Video-Instruct-REFFT/SmolVLM2-500M-Video-Instruct-w4.refft /data/local/tmp/
adb shell
cd /data/local/tmp/refft-hexagon
export LD_LIBRARY_PATH=$PWD/lib
export ADSP_LIBRARY_PATH=$PWD/lib

./bin/refft-hexagon cli --model /data/local/tmp/SmolVLM2-500M-Video-Instruct-w4.refft --backend hexagon --prompt "Who are you?" --max_new_tokens 128

Windows (PowerShell):

cd $env:LOCALAPPDATA\Programs\refft-hexagon
$env:ADSP_LIBRARY_PATH = "$PWD\lib"

.\bin\refft-hexagon.exe cli   --model $HOME\SmolVLM2-500M-Video-Instruct-REFFT\SmolVLM2-500M-Video-Instruct-w4.refft --backend hexagon --prompt "Who are you?" --max_new_tokens 128
.\bin\refft-hexagon.exe serve --model $HOME\SmolVLM2-500M-Video-Instruct-REFFT\SmolVLM2-500M-Video-Instruct-w4.refft --backend hexagon --port 8080
Topic Options
Commands help, version, cli, serve, bench serve --prompt "Who are you?"
Generation --max_new_tokens <n> (default 1 for cli, 16 for serve), --chat, --stream true, --print_perf_metrics
Sampling pass --sampler chain first, then --do_sample, --temperature, --top_k, --top_p, --min_p, --repetition_penalty, --ignore_eos
Model serving bundle from refinefuture-ai/SmolVLM2-500M-Video-Instruct-REFFT; the binary's built-in builders are listed by cli --list_models

3. Chat with the server

Once refft-hexagon serve is up:

curl http://127.0.0.1:8080/health
curl http://127.0.0.1:8080/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "SmolVLM2-500M-Video-Instruct",
    "messages": [{"role": "user", "content": "Explain KV cache reuse briefly."}],
    "max_tokens": 128,
    "stream": false
  }'

The endpoint is OpenAI-compatible, so any OpenAI client works by pointing its base URL at http://127.0.0.1:8080/v1.


FAQs

Why refft.cpp implements all of modeling, serving and training in C++

It's manly for a better performance and easy-to-use compared to Python/PyTorch-based as well as for scalability on edge-NPU.

Why Triton is not used in refft.cpp

Because the Triton models can get up to 78% of the performance of the CUDA models on the H100 and up to 82% on the A100.

CUDA-Free Inference for LLMs

How to support multi-nodes GPU/NPU Technically refft.cpp supports multi-nodes inference and training, while multi-nodes haven't been tested due to lacking of HW resources. Please contact us if needed.
Strictly equivalence of computational precision matters the most in LLM/LM's ops and serving optimization https://epoch.ai/gradient-updates/why-benchmarking-is-hard
https://blog.vllm.ai/2025/10/28/Kimi-K2-Accuracy.html

Legacy (Archived)

The previous generation, the old QNN / CUDA / MLX packages built around the refft-cli / refft-server binaries, the training flow and the build tools showcase, is no longer part of the supported surface and has been archived:

CUDA and Apple Silicon are not going away: they return as the single-binary refft-cuda and refft-mlx runtimes. For anything current, use refft-hexagon as described in Quick Start.

Contact Us

Please contact us via haiteng@refinefuture.ai for commercial uses, technical consulting, sponsorship/partnership opportunities, etc.

Acknowledgment

refft.cpp was inspired by Andrej Karpathy' llm.c, and also referred to HuggingFace, PyTorch, vLLM, SGLang, FlashAttention, FlashInfer.

About

A new approach of running LLM/LMs' inference/training on GPU/NPU backends through C++ implementation and compile for High-Performance and Easy-to-Use

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages