TensorFold README

The project's README from github.com/ashhart/TensorFold. As one markdown file: README.md.

Help Support TensorFold · @tensorfold_dev on X

TensorFold logo

TensorFold

TensorFold serves language models from a Zig binary on Apple Silicon and NVIDIA GPUs. The engine reads checkpoints, tokenizes requests and runs Metal or CUDA kernels directly. Serving needs no Python or MLX installation.

Building with a coding agent? Have it load the contributor skill and follow CONTRIBUTING.md.

Quick start

Start with Qwen3.5-2B, a small 4-bit checkpoint. The commands below download its pinned revision, then serve it as local-model. Model weights have their own licenses.

Mac with Apple Silicon

Install with Homebrew, then start the server:

brew install ashhart/tensorfold/tensorfold
tensorfold pull mlx-community/Qwen3.5-2B-MLX-4bit@93760be4f1f69842a46bc13dbdc0f19e291392a3
tensorfold serve mlx-community/Qwen3.5-2B-MLX-4bit --name local-model --context 8192 --no-thinking

Linux with an NVIDIA GPU

Needs glibc 2.28 or newer and NVIDIA driver R580 or newer (CUDA 13.0). The run guide lists the archive's requirements; Windows has its own guide.

V=1.3.7
case "$(uname -m)" in
  aarch64|arm64) PLATFORM=linux-aarch64 ;;
  x86_64) PLATFORM=linux-x86_64 ;;
  *) echo 'No release archive for this CPU' >&2; exit 1 ;;
esac
curl -fLO "https://github.com/ashhart/TensorFold/releases/download/v$V/tensorfold-$V-$PLATFORM.tar.gz"
curl -fLO "https://github.com/ashhart/TensorFold/releases/download/v$V/tensorfold-$V-$PLATFORM.tar.gz.sha256"
sha256sum -c "tensorfold-$V-$PLATFORM.tar.gz.sha256"
tar -xzf "tensorfold-$V-$PLATFORM.tar.gz"
export PATH="$PWD/tensorfold-$V-$PLATFORM/bin:$PATH"
tensorfold() { command tensorfold-native "$@"; }
tensorfold pull mlx-community/Qwen3.5-2B-MLX-4bit@93760be4f1f69842a46bc13dbdc0f19e291392a3
tensorfold serve mlx-community/Qwen3.5-2B-MLX-4bit --name local-model --context 8192 --no-thinking

On Windows, tensorfold start is not available yet. Use the Windows guide.

Or let TensorFold choose on macOS and Linux with tensorfold start --check. It prints the selected model and download size and asks before downloading. The check prints one reply and stops the server.

Send a request

Leave the server running. In another terminal, on either platform:

curl -fsS http://127.0.0.1:8080/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{"model":"local-model","messages":[{"role":"user","content":"Say hello in one sentence."}],"max_tokens":128,"temperature":0}'

The API also serves completions, Responses and Anthropic Messages. /v1/models lists the served name.

To talk to a model in the terminal in one command, tensorfold chat MODEL starts the server itself, streams each reply and stops the server when the chat ends; /help lists the chat's commands, and /bye or Ctrl-D ends it:

tensorfold chat mlx-community/Qwen3.5-2B-MLX-4bit

With the server above still running, tensorfold chat --url http://127.0.0.1:8080 chats with it instead, and echo "Say hello." | tensorfold chat --url http://127.0.0.1:8080 prints one reply for a script. See the chat command for its flags and the serve flags it passes on.

Docs

Contributors

Thank you to everyone who has sent TensorFold a pull request, a measurement or a bug report:

@0mao0, @321sssrt-bit, @AbrahamCete, @aditya1503, @AdrianBinDC, @ajensenwaud, @akol1, @alenperic, @Alexbob0, @alexderz, @anvilsong, @Arminova, @b-ostrov, @BadAd84, @barelyworkingcode, @Benjamin-Wegener, @benthecarman, @benwilson, @BHCC2025, @Bizuayeu, @BlivionIaG, @BobClawblaw, @borodach23, @Boscoeuk, @boxabirds, @brandonmmusic-max, @bunnyfu, @CanadaApollo6, @CerebralCoding, @cesarswong, @chadhurley25075-png, @chaog992, @Charlie-Louis, @Chedrian07, @chris247474, @christrade215, @crescit, @cshintov, @cwschroeder, @DakotaTexas, @danyo1399, @Deesha08, @Defilan, @DevRico003, @di37, @diwakergupta, @drowzeys, @easthambuilds, @ecohash-co, @edurdias, @eleqtrizit, @ericlsimplifi, @EugeneClaw, @fche, @feni6, @florianbrede-ayet, @gbgbgbg, @GDACONSULT, @gecobattya, @gilby, @Gogo6969, @gprot42, @GraithSecurity, @grantoverton, @grearjake-star, @greatyingzi, @GustavBlack, @harrisonfriia, @haxudev, @heitke, @hichaiuse, @ivanfioravanti, @jasontitus, @javierbits, @jayleaton, @jeffpeng3, @jeidbugs404, @Jenpo, @jerryfane, @jetnet, @jishnuvenugopal, @jkuepker, @joeynyc, @johnymoo, @JordiPosthumus, @joshuaswarren, @JRaxworthy, @jrb-ai, @jschmied, @juliankang4, @justincasey, @kelchm, @kieranscotney, @kingjamez, @kky42, @laudney, @lcgutierrez, @LECYWZA, @lijian1999, @liumorrisclaw, @LXD-8, @m-naoki-m, @mapamalu, @mcclanahanaman, @MESevenJourney, @mgoldwasser, @MiaAI-Lab, @mikolaj92, @millaguie, @Mirrdhyn, @Moutonc, @MovieMaker93, @mrpmorris, @mrv777, @MV10, @NeoAiLabs, @Nipale-ai, @nmcbride, @nood-co1, @nullburn, @olexale, @omar16100, @optimisme, @otarkhan, @outcastofmusic, @paragontasx, @peacockesq, @philip-pentatonic, @plotarmordev, @pmeenan, @ppardus, @pulseandthread, @quigles1977, @rafafortes, @raymondkpwong, @robertpitt, @rootsbymenda, @RoscoeTT, @RS91Dev, @russellmm, @salmanarshad321, @samwang0041-star, @sanjaibalajee, @satindergrewal, @scottleimroth, @sethforprivacy, @sfxnz, @shantanugoel, @simon-lin88, @simonmd, @spenchey, @squarrier, @ss-cong, @Stephane-Eden, @styles01, @SvangenStudios, @swbiggart, @SxMShaDoW, @sxuff, @taussoe, @tfolkman, @ThinkOffApp, @ThomasHalwax, @Thotheris, @tinyapps, @tolewis, @tomByrer, @tonydehnke, @tournierjc, @tovereast, @tpischke, @urtho, @valacroix, @vcruz305, @vinicius-symetrix, @wojo, @xjqx2z, @yguanrong, @Yuepixel, @YvesLaRose, @ZackSample, @zweck.

docs/credits.md names whose Python engine work each part of the native engine carries.

TensorFold (ashhart/TensorFold)

Searching Database…

What is this?TensorFold is an LLM inference engine that serves open-weight language models through an OpenAI-compatible API, running them on Apple Silicon via MLX or on NVIDIA GPUs via CUDA.
Is this a library I import, or a server I run?It is a command-line server: you run 'tensorfold serve' to host a model, then point any OpenAI-API-compatible client at its base URL and model ID.
How do I get it running?Install it with pip (it also pulls in MLX automatically on a Mac), then use 'tensorfold pull' to fetch a checkpoint or 'tensorfold serve' to download it and start the API server directly.
What do I need before trying it?Python 3.11 or newer; on macOS, MLX 0.32.2 or newer; on CUDA you need a supported NVIDIA GPU and, for some models, a separately pulled DFlash2 draft checkpoint.
Does it work with any model I throw at it?No, only a short list of named checkpoints (Nemotron, Qwen3.8-27B, Flash Next, GLM-5.3-Flash, Gemma 4) is supported, each restricted to specific quantization formats, and unsupported layouts are rejected before loading.
Who is this for, people without a GPU?No, it targets people with an Apple Silicon Mac or an NVIDIA CUDA GPU; CUDA further limits concurrent requests, with some model families (GLM, Nemotron) serving only one request at a time.
Which hardware does it actually support?Apple Silicon Macs through MLX and NVIDIA GPUs through CUDA, with the project description also mentioning Vulkan; the README's detailed walkthrough only covers MLX and CUDA.
Is the whole project free to use commercially?The engine itself is Apache-2.0, but one optional draft checkpoint for GLM (DFlash2) is distributed under non-commercial license terms.
What does 'exact decoding' mean here?TensorFold only accepts a speculative draft token when it equals what the same engine would produce serially, so drafted output matches non-drafted output for the same engine, weights, runtime and settings.
Why do some models need a separate 'draft' or MTP checkpoint?These are speculative-decoding helpers: a lightweight head or model predicts several tokens ahead, which the full model then verifies in one pass, speeding up generation without changing the final output.
How much RAM or VRAM do I actually need?On MLX, TensorFold defaults to using 70% of Mac RAM (up to 85% for GLM-5.3-Flash) and lets you override the budget with the TENSORFOLD_MEMORY_LIMIT_GB variable; exact peak-memory figures per model and RAM class are still marked TBD in the README.
Does it remember previous turns of a conversation efficiently?Yes, it caches prompt prefixes between turns so a follow-up message doesn't need to reprocess the entire earlier prompt, as long as the chat history and template haven't changed in a way that breaks the cached prefix.
Creator
ashhart
Size
78.1 MB
Stars
2.3K
Age
5mo
Commits · 90 Days