Skip to content

About

Fast, exact LLM decoding on Apple Silicon (MLX) behind an OpenAI-compatible endpoint

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

 
 

Repository files navigation

Help Support TensorFold · @tensorfold_dev on X

TensorFold logo

TensorFold

This fork tracks native TensorFold and retains the Studio runbook. The optional Studio gateway supervises one model at a time. Its deployed runtime remains separately pinned and qualified; synchronizing this source tree does not upgrade that binary.

Suggested model: Inkling 2 Mini MLX 5-bit

For a 64 GB Apple Silicon setup, start with Inkling 2 Mini MLX 5-bit. It supports text and images through this fork's optional MLX adapter, with a 131,072-token input-plus-output window and up to two interleaved text requests when RAM admission allows. Images run sequentially. This is a practical starting recommendation, not a matched quality ranking over Swift, Liquid or Arete. Native Zig support for Inkling is not provided by this adapter.

On M5 Max with 64 GiB RAM, ordinary serving measured 39–43 generated tok/s solo, 19–21 tok/s per user with two active, and roughly 1,400–1,730 prompt tok/s solo at 4K–32K. Speculative experiments reached 49.7 tok/s at 4K but regressed at 32K, so drafting stays disabled. These are one-attempt speed probes.

Inkling generation speed and draft rejection

Benchmark details and raw results · API adapter setup, images and limits

The deployed 8-bit profile has a separate streaming optimization receipt: it preserves three passes and the same weights while avoiding unused GPU probability readbacks and tuning M5 command submission. Its measurements apply to the 8-bit checkpoint, not the 5-bit figures above.

The 8-bit profile also has an exact decode-mask optimization receipt, with alternating baseline comparisons on the pinned M5 Max runtime.

Try it locally

Use an Apple Silicon Mac and a separate Python environment. Set MODEL_DIR to an absolute directory for replaceable weights; on a Mac using Time Machine, exclude that directory and its download cache before downloading.

python3 -m venv .venv-inkling
.venv-inkling/bin/python -m pip install 'mlx==0.32.4' 'transformers==5.23.0' pillow \
  'git+https://github.com/ml-explore/mlx-lm.git@0c4c99192230f1943dd468d297f0b8a64ae7b7c2'
export MODEL_DIR="/absolute/path/to/models/inkling-2-mini-5bit"
.venv-inkling/bin/hf download araysuter/Inkling-2-Mini-MLX-5bit \
  --revision 4e7ff0e11667a88bae9a7a9323e93d498899aa8b --local-dir "$MODEL_DIR"
MLX_ENABLE_TF32=0 .venv-inkling/bin/python -m mlx_lm.generate \
  --model "$MODEL_DIR" --prompt "Write a short Python function to deduplicate a list." \
  --max-tokens 256 --temp 0

The pinned MLX-LM revision includes the Inkling port; a stock version without that port will not load this architecture. To expose an authenticated local OpenAI-compatible API, follow the short server setup.

Models through one Studio API

The current Studio API advertises inkling-2-mini, lfm2.5-24b-a2b, swift-1.5 and arete-27b. The checked-in starter configuration contains Swift-1.5 and Arete-27B MLX 5-bit; add Inkling using its adapter guide or Liquid using the Liquid profile guide. Swift and Arete use native TensorFold, the Qwen3.8-27B DFlash2 drafter, and a 131,072-token input-plus-output window with one active request at a time. Only the selected model and its drafter are loaded in RAM; the other model's weights stay on SSD. Swift and Arete both have native image profiles.

The shared snapshot limit is configurable; the current Studio profile uses eight slots total across supported models and API keys. Inkling keeps fresh KV per request and does not retain completed histories or consume SSD slots. After 30 minutes idle, it saves the conversation and unloads the engine. Temporary conversation state is cleared when the gateway shuts down. A cold request includes model-loading and conversation-restoration time. RAM admission checks retain the configured host reserve and return HTTP 503 when other work leaves insufficient headroom.

Swift remains an option for the historical locally tested reasoning workload. Choose Arete when you want the NousResearch model with its original BF16 vision tower and our 5-bit language quantization. There is no matched local quality score for Arete.

API model ID Published checkpoint Local quality evidence
swift-1.5 Swift-1.5 affine 4-bit Cleaned GPQA: 175/189 (92.6%)
arete-27b Arete-27B MLX 5-bit No local GPQA run; vision/runtime checks

Swift's score is from our historical local evaluation. It excludes nine questions from the 198-question GPQA Diamond set and uses adaptive output budgets: 32,768 tokens initially, with unfinished cutoffs retried at 65,536 and then 98,304. Remaining cutoffs count as incorrect. It is not a fresh fixed-budget run or an Arete comparison.

Use the session-enabled native runtime and Qwen3.8-27B DFlash2 with both models. Prepare Swift's native checkpoint and vision tower as described in the gateway setup guide; the published Arete quant already contains its tower. A stock release binary does not provide the supervisor's session save/load contract.

install -d -m 700 "$HOME/.config/tensorfold"
install -m 600 tools/studio-gateway/config.example.json \
  "$HOME/.config/tensorfold/studio-gateway.json"
# Edit the private copy for your executable, checkpoint, drafter, and key paths.
python3 tools/studio-gateway/gateway.py \
  --config "$HOME/.config/tensorfold/studio-gateway.json" --check-config
python3 tools/studio-gateway/gateway.py \
  --config "$HOME/.config/tensorfold/studio-gateway.json"

Clients keep one /v1 base URL and API key, choosing a configured model ID in the request's model field. Keep downloaded weights and conversion staging in Time Machine-excluded directories; private configuration, keys and snapshots stay outside Git. See sharing this fork.

The Ornith benchmarks and Ripple MLX conversion/DFlash2 tools remain available for historical reproduction. Their models are optional and are not included in the default two-model configuration.

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. Native serving needs no Python or MLX installation; the optional Inkling adapter described above requires its separate MLX environment.

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.2.10
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

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.

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.

About

Fast, exact LLM decoding on Apple Silicon (MLX) behind an OpenAI-compatible endpoint

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages