Skip to content

Latest commit

 

History

History
232 lines (199 loc) · 25 KB

run-guide.md

File metadata and controls

232 lines (199 loc) · 25 KB

Run guide

How to install, start and tune a TensorFold server after the quick start. Which checkpoints run on which machines is in supported models.

Platform setup

The quick start serves Qwen3.5-2B, the small 4-bit checkpoint checked on Metal and a GB10. Its commands download its pinned revision, then serve it as local-model. Model weights have their own licenses. Reviewing or benchmarking TensorFold? Evaluating TensorFold covers pinning, signature checks, a container and the tests that need no GPU.

  • Mac with Apple Silicon: install with Homebrew (brew install ashhart/tensorfold/tensorfold). The runbook covers macOS installation in more detail.
  • Linux with an NVIDIA GPU: use the release archive for your CPU: linux-aarch64 on a GB10, linux-x86_64 on an x86_64 host. It needs glibc 2.28 or newer and NVIDIA driver R580 or newer (CUDA 13.0), providing libcuda.so.1. Keep the archive's directories together. Its kernels are built with CUDA 13, so TensorFold refuses an older driver at startup; nvidia-smi shows the installed one. See the CUDA runbook for runtime libraries and supported GPUs. The archive's binary is tensorfold-native; the quick start defines a tensorfold shell function that calls it.
  • Windows with an NVIDIA GPU: follow the native Windows build guide.

Select, download and prove a model

After installation, tensorfold start uses the same machine probe and registry as tensorfold models, picks the largest fully pinned checkpoint that fits and tensorfold pull can install, shows its download size, and asks before downloading. --yes gives that consent explicitly. Without --yes, a non-interactive run stops before any download; an interactive run accepts only y or yes. A cached model needs no prompt or download. Rows whose Gemma 4 drafts need M5 tensor units are served without the drafter on pre-M5 Metal; M5 and CUDA retain it.

The command starts a loopback server and sends one deterministic request. --check stops that server after a nonempty reply and exits 0; this ephemeral check replaces any caller API key with a private temporary key. Without --check, set TENSORFOLD_API_KEY in the environment first: persistent start requires at least one nonempty, valid entry, passes a comma-separated list to the child unchanged, and uses its first nonempty trimmed entry for the managed checks. Every entry must be UTF-8, at most 256 bytes, and contain no whitespace or control characters. The server accepts each registered entry. Send external requests with Authorization: Bearer KEY, replacing KEY with one accepted entry. Keys are never printed or placed in the child arguments. A failed first reply is fatal and the started server is stopped. --startup-timeout SECONDS sets how long start waits for the server to load, above 0 and at most 3600; unset, it waits 600 seconds plus 6 for every GB of weights past 20 GB, at most 3600. No existing serve default or flag changes.

Send a request

Leave the server running. In another terminal, on either platform, send the persistent credential below. For a comma-separated TENSORFOLD_API_KEY, substitute one accepted entry for the whole value in the Authorization header. An unauthenticated manual serve does not need a key:

curl -fsS http://127.0.0.1:8080/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer ${TENSORFOLD_API_KEY}" \
  -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. Use tensorfold --help, tensorfold capabilities --json and tensorfold serve REPO --help to inspect your binary. tensorfold device says whether this machine is supported, which formats it serves and how much memory weights may take (device check). You can also serve a complete local checkpoint directory or an existing Hugging Face cache.

TensorFold Web

tensorfold web [ARGS...] opens TensorFold Web, a small local web app for picking, running and chatting with models. If it needs installing, an interactive release binary offers to install its matching version with uv after you say yes. See the web launcher for manual installation and unattended use.

Parallel requests

--parallel N caps active requests at N; extra requests wait for a free slot. Omitting the flag uses --parallel auto, which asks for up to eight streams as memory and the engine allow. An explicit number is refused if the engine cannot fit that many streams. Read the engine's startup capacity line, such as 8 streams at once on CUDA, for the count it accepted. With API authentication off, /health reports live.connections as active plus waiting requests and live.waiting as the queued count. For example, 8 connections with 4 waiting means 4 active requests. Completing or cancelling an active request frees its slot; cancelling a waiting request removes it from the queue.

Exact decoding

Every accepted draft must equal the token the same native engine would produce with "draft": false. A resumed request must equal fresh execution, and each concurrent stream must equal its solo run. The comparison fixes the checkpoint, backend, settings and runtime. Different quantizations and different backends can produce different outputs. Flash Next on Metal uses shared target rounds with an explicit --parallel N above one, when that many sessions fit. A lone greedy request there uses GPU-side rounds and hands over when a second request arrives. --parallel auto (the default) and --parallel 1, learning and two-Mac serving use the single-reply driver. FZ_BATCH_MTP_SERIAL=1 restores serial MTP drafting on the shared host. The earlier MTP chain receipt records its own pinned commits. Nemotron, GLM, the 2B model and Qwen3.8-27B use shared lane rounds. On Metal, each of up to 128 streams in the 27B's shared rounds drafts its own DFlash2 tree.

Context compaction

Compaction is off by default, and with it off every reply is unchanged. With --compact-at, a conversation that would overflow is compacted instead of refused. The server keeps the system prompt and the most recent turns word for word, and never separates a tool call from its result. The older turns become a memory note: goal, constraints, progress, decisions, next steps, exact names and numbers, and the files the tool calls read or changed. Each later compaction updates the previous note instead of starting over. A client that sends back the compacted conversation keeps its note. The reply carries the note and the compaction counts under tensorfold.compaction, and every reply reports context_window and context_used. The same request gives the same compaction and the same reply. With --compact-memory, the stored note carries over between requests.

Cortheon mode

Off by default. --cortheon gives every chat request Cortheon's reasoning program and web research run by the server, so any OpenAI-compatible client gets it with no setup. The model works through Cortheon's stages for its task type and can call cortheon_search and cortheon_fetch, which the server runs without the client seeing them. A question about current facts, or a request to build with an outside library, is researched before the model starts. A coding task that changed files is asked to run its tests before it finishes. Web text is filtered for instructions aimed at the model, and reads reach public addresses only. With the flag, search queries written from the conversation go to DuckDuckGo, or to Brave with BRAVE_SEARCH_API_KEY, and pages are fetched from this machine; without it, the server makes no searches and reads no pages. See Cortheon mode.

Serve flags

The read-only /memory diagnostics report process footprint and lifetime peak, available backend allocation counters, and the applied retained-prefix plan without changing memory policy.

The binary's capabilities --json response lists its supported flags and platform-specific values. serve MODEL --help prints usage without loading a model.

Flag Meaning
--host HOST, --port PORT Listen address and port, default 127.0.0.1:8080.
--unix-socket PATH Listen on a new owner-only Unix socket at PATH instead of TCP, refused with --host or --port; macOS and Linux. An existing PATH, or a directory other users can write to (unless sticky, like /tmp), is refused, and connections from other users are closed. API keys, --metrics-open and the Host check apply as on TCP (a client sends a loopback Host or one in --allowed-host): the socket's permissions are a second layer, not a substitute for keys.
--profile stable Explicitly preserve current defaults; profiles describes the initial switch registry and startup report.
--config FILE.toml Read serve flags from a TOML file: a key is a flag without its --, and model names the model. The command line wins over the file, and a relative path in the file starts at the file's folder. See serve config files.
--name NAME Model ID advertised to clients.
--alias NAME Another accepted model ID; repeat for multiple aliases.
--api-key KEY Require a bearer key; repeat for multiple keys.
--api-key-file FILE Read keys from a restricted-permission file; a key can be limited to some routes.
--metrics-open Allow /metrics, /v1/metrics and /v1/load without a key when API authentication is enabled.
--dashboard Enable the local /dashboard page and /stats endpoint.
--log-json Write the access, ended and refused lines as one JSON object each, with event set to access, ended or refused. access is written when the response starts, with the HTTP status and the request id once assigned. ended is written only when the client left or the reply failed, with prompt and tokens. refused is written for an error reply, before its access line. Long fields are cut so each line still parses. Off keeps the text lines.
--execution-witness Serve GET /v1/execution/witness to read-scoped keys: a snapshot of the running binary, the checkpoint's text files, the serve defaults and settings, or why it is unknown. Needs an API key or --unix-socket; see execution witness.
--max-inflight N, --max-inflight-per-key N Refuse model requests past N in progress at once, overall or per key, with 429; 0, the default, is off. See admission.
--max-connections N, --max-connections-per-address N, --trusted-proxy ADDRESS Open connections at most (default 128); from three quarters full, one address's share (default a quarter, 0 off); addresses never counted for that share, as loopback is not, such as a reverse proxy or Docker's bridge gateway. See admission.
--requests-per-second N, --request-burst N Refuse a key's model requests past N a second, after a burst; 0, the default, is off.
--context N Bound prompt plus reply tokens; the model's window and memory checks still apply. Qwen3.8-27B defaults to 32,768 and takes up to 262,144.
--rope-yarn F YaRN context extension with this factor over the checkpoint's trained window, for Qwen3.5 and 3.6 on a CUDA build; other builds refuse the flag.
--loops N Passes over a looped model's recurrent block, from 1; without it the checkpoint's own count runs. Other builds refuse the flag.
--speed-up FILE Rank and link settings for two-Mac Flash Next or GLM serving.
--max-tokens N Default reply limit, 4096; requests can override it.
--temperature T Sampling temperature; zero requests greedy decoding.
--prompt-seed Use native prompt-derived keys instead of the fresh OS fallback; request and configured default seeds still win.
--top-p P, --top-k K, --min-p P Sampling defaults.
--instruct-sampling SET Sampling defaults for sampled chat requests with thinking off: card (the Qwen 3.5, 3.6 and 3.8 cards' temperature 0.7, top_p 0.8, top_k 20, presence_penalty 1.5), name=value pairs over it, or none; the serve flags still win. Greedy requests, raw completions and the server's own requests never take them.
--thinking, --no-thinking Choose whether the chat template opens a reasoning block.
--reasoning-effort LEVEL Default template effort: minimal, low, medium, high, xhigh or max.
--thinking-budget N Limit reasoning tokens where the engine supports closing the reasoning block.
--thinking-reserve N With thinking on, let reasoning use up to N tokens beyond a request's max_tokens, which then limits the answer (lane engines).
--loop-guard Close reasoning that repeats itself verbatim (a short cycle, or a long passage) where the engine supports it.
--tool-think-close With thinking on, a required or named tool call closes its think block at max_tokens - max(256, max_tokens / 4) (or a smaller request thinking_budget), so the call fits instead of ending as length. Off by default (API).
--loop-guard-stop As --loop-guard, but end the reply where the guard fires: the reasoning so far, no answer or tool calls, finish_reason content_filter and a reasoning_loop error (API).
--no-drafts Produce the plain reference through the same engine.
--drafter DRAFTER An external drafter, as a directory or a repo id in the Hugging Face cache, for models that take one (Gemma 4 31B's recipe names its drafter); none serves without one. Without the flag, Qwen3.8-27B pairs DFlash2 when the cache holds it (never downloaded, not on HIP): one line names it, and serve runs without it if it does not open.
--drafter-bits 0|4 Drafter weight precision where the model offers a choice: 4 bits (the default), or 0 to keep bf16. Qwen3.8-27B on CUDA takes 4 only.
--record DIR Write each stream's committed tokens, positions and tapped rows under DIR, for drafter training. CUDA Nemotron only; a single stream runs through the lane rounds, and recording stops below 25 GiB free disk.
--keep-warm SECONDS Keep the Metal GPU active while idle for this long after a request, default 900; zero disables it.
--cfg-gamma GAMMA Drama speech on Metal and CUDA: semantic guidance strength, finite 1–5; 0/default disables it. Only reference-conditioned requests are guided. Enabled replies report X-Cfg-Gamma; codec heads stay conditional.
--cfg-allow-request-gamma Drama speech on Metal and CUDA: allow a finite 1–5 X-Cfg-Gamma request header; invalid values return 400 before engine submission. Without this opt-in, the server's gamma is fixed.
--cfg-force-guided With an enabled Drama guidance policy, exercise the unconditional state even at gamma 1. The semantic mix at 1 remains exact conditional-logit identity.
--cfg-batched With enabled Drama guidance, run both independent backbone states without a host wait between them: one command buffer on Metal, two streams joined by events on CUDA, rather than separate submissions. Weights are shared; extra state is included in admission. Not vectorized batching.
--silence-floor-dbfs DBFS Drama speech only: explicit frame-power floor for the silence guard, with no default floor. Calibrate below quiet intended speech using public or built-in speech.
--silence-seconds SECONDS Drama speech only: stop after this continuous duration below the explicit floor, retaining audio and reporting silence. Unset by default: off; calibrate above intentional pauses.
--silence-onset-s SECONDS Drama speech only: with the silence guard on, stop once this many seconds run below its floor while the synthesis has voiced less than --silence-onset-voiced-s, retaining audio and reporting silence. Off unless given; must be below --silence-seconds.
--silence-onset-voiced-s SECONDS Drama speech only: the voiced seconds below which --silence-onset-s applies; required with it, with no default. Calibrate on public or built-in speech.
--silence-mid-s SECONDS Drama speech only: with the silence guard on, finish as silence when end of speech falls in a run this long below the floor, after the explicit voiced minimum. Whole replies carry the decimal X-Silence-Mid-Trips count, including zero. Must be below --silence-seconds and paired with --silence-mid-min-voiced-s. Unset by default: off.
--silence-mid-min-voiced-s SECONDS Required with --silence-mid-s: positive finite cumulative voiced duration before the mid rule applies, including equality. No default; calibrate with the other silence thresholds.
--silence-redraws N Drama speech only: draw a whole reply the silence guard ended again, up to N times, as seed salt + k or explicit request seed + k; N of 1 or more needs the guard. Unset by default: off, as is 0; streams are never redrawn. See speech redraws.
--silence-redraw-budget-s SECONDS Start a redraw only while elapsed time plus the last take's duration fits; a request's X-Deadline-S can lower it. No default budget.
--silence-redraw-controls LIST Redraws speak the input filtered to the listed controls, as --allowed-controls filters; an empty list removes every control.
--short-reply-ratio R Also redraw a whole reply that finished stop with less audio than R (above 0, below 1) of its text's expected length; needs --silence-redraws and --short-reply-chars-per-s. No default.
--short-reply-chars-per-s CPS Input characters per second of audio in complete replies of the served voice, setting the expected length; needs --short-reply-ratio. No default; calibrate on your own voice.
--register-redraw-st ST Drama speech only: draw a whole reply once more when a phrase after the first opens ST semitones above the other phrases' median opening; needs the two flags below. Unset by default: off, with no default for any of the three. See speech redraws.
--register-redraw-high PERCENT The share of that phrase's voiced frames that must lie above --register-high-hz.
--register-high-hz HZ The pitch line, 75 to 600 Hz, that marks a high register; calibrate it on your own voice.
--parallel N|auto Cap active requests at N and queue the rest. Default auto asks for up to 8 as memory and the engine allow; an explicit count that cannot fit is refused. Read the accepted count at startup.
--prompt-cache-gib GIB Retained-prefix budget; by default half the room left after streams on Metal and unified-memory CUDA (16 GiB floor where room permits), 8 GiB host snapshots on discrete CUDA, 16 GiB for Flash Next's batch host. An explicit value overrides it; 0 disables it.
--prompt-cache-over-cap Permit an explicit prefix budget past what 70% of RAM leaves once the server loads.
--learn Keep shared prompt prefixes on disk for new conversations to resume; the models are below the table.
--learn-dir DIR Where --learn keeps them, ~/.cache/tensorfold/learned by default; implies --learn.
--learn-gib GIB Disk for learned prefixes on each Mac, 32 by default; the least recently used go first. Implies --learn.
--learn-min-free-gib GIB Free disk --learn leaves on each Mac, 4 by default; below it learning pauses and serving goes on.
--learn-conversations Keep every prompt state on disk too, each conversation's and the shared prefixes, in one store in place of --learn's, so a next turn after a restart, a crash or an eviction reads it back. Implies --learn; see Conversations on disk.
--learn-daily-gib GIB What --learn-conversations may write to disk a day, every model together, 32 by default; past it states stay in RAM only.
--recall Draft from a record of the token ids earlier requests read and wrote, so repeated text is verified in a few rounds; replies are unchanged. Off by default; see Recall for what stays on disk.
--recall-dir DIR The record's directory, one a tokenizer under ~/.cache/tensorfold/recall by default; implies --recall.
--recall-gib GIB Disk for the record, 1/16 GiB by default; the oldest ids go first. Implies --recall.
--recall-read-only Draft from the record without adding to it, as gates and benchmarks run; implies --recall.
--snapshot-dir none Keep prefix state in memory; none is the supported value.
--max-snapshots 0 Disable disk snapshots at startup; 0 is the supported value.
--compact-at auto|FRACTION Turn on context compaction. auto compacts when the prompt and reply would pass the window minus a reserve.
--compact-keep TOKENS Recent tokens kept word for word when compacting; the default is 20,000 or a quarter of the window, whichever is smaller.
--compact-memory DIR Also keep each conversation's memory note as a Markdown file in DIR.
--cortheon Cortheon's reasoning program and server-run web research for chat requests; see Cortheon mode.
--no-update-check Accepted compatibility switch; update the installed binary through its package manager.
--backend auto Use the backend compiled for the platform; mlx selects native Metal on macOS and cuda selects CUDA on Linux.

--prompt-cache-gib applies to Nemotron, Flash Next, GLM, Qwen3.8-27B and LFM2.5-24B-A2B, and --prompt-cache-over-cap to the same models but GLM. --learn keeps shared prompt prefixes, such as a system prompt and its tools, on disk, so new conversations resume them after a restart or an upgrade that computes the same bits. It covers GLM-5.3-Flash, Nemotron, and Flash Next on one Mac; Qwen3.8-27B, Qwen3.5-2B, LFM2.5-24B-A2B, GLM-5.3 (EXLR8) and a CUDA server refuse it at startup. Qwen3.8-27B on Metal also resumes a follow-up turn from the state its last reply left in the server's first slot, when the prompt cache holds nothing as far: the turn reads only its new tokens, even on a Mac whose cache cannot keep a long conversation. Where the cache cannot keep a whole context, the server also keeps that slot's DeltaNet states at each prompt's history end, so a turn whose template drops the last reply's reasoning resumes there. Replies are the same tokens as a fresh prompt pass; TF_QWEN27_SLOT_RESUME=0 turns both off.

Sampling defaults come from the checkpoint's generation_config.json, then serve flags and request fields override them. --context 0 is family-specific; use a positive limit for GLM and inspect the capacity reported at startup. The supported environment variables are listed in capabilities --json, including API keys, request logging and Hugging Face cache paths. TF_Q27_PROFILE=N makes a native Metal Qwen3.8-27B server log a per-class GPU-time breakdown every N decode rounds (1 means 64) and add gpu_seconds to its replies; it is diagnostic only, and a profiled round runs slower.

Reading the request journal

With TENSORFOLD_REQUEST_JOURNAL=PATH set on serve, tensorfold log list, tensorfold log show ID and tensorfold log follow read what each request asked, what it got back, its token counts and its timings, while the server runs; see the API's request journal section.

Other ways to run

Mac app

The TensorFold desktop workspace bundles the local engine, model downloads, hardware recommendations, live generation metrics, coding workers and document editing. Download the Apple-silicon beta 9 DMG, or build from app/. The desktop app launches the bundled tensorfold-native executable directly. Mobile clients in app/mobile/ remain preview software.

TensorFold Starlight (enterprise)

TensorFold Starlight gives an organisation one governed OpenAI- and Anthropic-compatible endpoint for a fleet of TensorFold engines on Macs, Linux GPU servers and Windows machines. It signs people in through the organisation's identity provider (OIDC or SAML, with SCIM provisioning), decides who may use which model and where it runs, places and supervises models on nodes, and accounts for every token. It runs fully offline, or brokers approved frontier providers under the same identity, policy and budgets; the install guide covers Docker, Kubernetes and Linux services. Starlight lives in its own repository, ashhart/tf-starlight: it pins the TensorFold release it is tested with and checks every flag its nodes pass to tensorfold serve against that release in CI. Starlight is new: the gates that still need real GPU clusters or identity-provider tenants are listed in its qualification notes.