Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

Merge branch 'f-133-docs' into rel-0.1.34

Niko12213629d22c76bd
diff --cc docs/AMD_HIP.md
index 9dd335881,780b86789..12a1e105f
--- a/docs/AMD_HIP.md
+++ b/docs/AMD_HIP.md
@@@ -1,10 -1,12 +1,12 @@@
- # Experimental AMD HIP backend (gfx1100, gfx1101, gfx1200, gfx1201, gfx1030)
+ # AMD Radeon: the HIP backend (gfx1100, gfx1101, gfx1200, gfx1201, gfx1030)
- On Linux this is a source build (on Windows a ready-made engine, see [Windows](#windows)) for the RX 7900 XT / XTX (RDNA3, gfx1100) and the
+ Strata runs on AMD Radeon cards through its HIP backend, the same engine as on NVIDIA compiled for AMD. This page
-covers the build on Linux for the RX 7900 XT / XTX (RDNA3, gfx1100) and the
++covers the build on Linux (on Windows a ready-made engine, see [Windows](#windows)) for the RX 7900 XT / XTX (RDNA3, gfx1100) and the
RX 9070 / 9070 XT / Radeon AI PRO R9700 (RDNA4, gfx1201; see [RDNA4](#rdna4-gfx1201)). The RX 7800 XT / 7700 XT
(gfx1101) and the RX 9060 XT (gfx1200) were validated by their owners (see [Community-validated
- cards](#community-validated-cards)); the RX 6800 / 6900 series (RDNA2, gfx1030) builds and runs too, reported by a community machine and not yet validated by the maintainers (see [RDNA2](#rdna2-gfx1030)). It is opt-in; the NVIDIA installer and CUDA build remain the default. Other AMD
- architectures, wave64, and mixed AMD/NVIDIA execution are outside this contribution.
+ cards](#community-validated-cards)); the RX 6800 / 6900 series (RDNA2, gfx1030) builds and runs too, reported by a community machine and not yet validated by the maintainers (see [RDNA2](#rdna2-gfx1030)). Setup chooses it by itself on a PC with no NVIDIA card Strata can use (`--backend hip` on a PC with both); the
+ install steps for users are in [INSTALL.md](INSTALL.md#amd-cards). Other AMD architectures, wave64, and mixed
+ AMD/NVIDIA execution in one run are not supported.
The backend maps the CUDA-shaped runtime and BLAS calls to HIP/hipBLAS, uses
RDNA2/RDNA3/RDNA4's signed integer dot instruction for quantized kernels, and supplies
diff --cc docs/INSTALL.md
index 000000000,a8a768555..609277045
mode 000000,100644..100644
--- a/docs/INSTALL.md
+++ b/docs/INSTALL.md
@@@ -1,0 -1,186 +1,187 @@@
+ # Installing Strata
+
+ Everything about installing, starting, updating and configuring Strata, on Windows and Linux, with an NVIDIA or an
+ AMD graphics card. The short version is in the [README](../README.md#install); an AI coding assistant can do all of
+ this for you with [AI_SETUP.md](AI_SETUP.md).
+
+ > **On this page:** [What you need](#what-you-need) · [Windows](#windows) · [Linux](#linux) ·
+ > [AMD cards](#amd-cards) · [Several cards](#two-or-three-cards) · [Docker](#docker-linux) · [Updating](#updating) ·
+ > [Where things are stored](#where-things-are-stored) · [Setup's questions](#setups-questions) ·
+ > [Tuning](#tuning-for-your-pc) · [All options](#options-without-questions)
+
+ ## What you need
+
+ | | |
+ | --- | --- |
+ | **GPU** | **NVIDIA** RTX 20, 30, 40 or 50 series, **12 GB VRAM or more** (8 GB runs, slowly). Measured on an RTX 5070 and an RTX 3090; RTX 20 (Turing, since 0.1.27) was tested by a contributor on an RTX 2070. **AMD** Radeon RX 7900 XT / XTX, RX 9070 / 9070 XT and Radeon AI PRO R9700 (validated), RX 7800 XT / 7700 XT and RX 9060 XT (validated by their owners), RX 6800 / 6900 series (community-reported), with 12 GB of VRAM or more. See [AMD cards](#amd-cards). |
+ | **RAM** | Enough for the size you pick ([which model](MODELS.md#pick-by-ram)); **64 GB** runs every size. A big GPU makes up for less RAM - the [low-RAM mode](MODELS.md#a-big-graphics-card-and-little-ram). |
+ | **CPU** | x86-64 with AVX2 (any Intel/AMD desktop CPU from the last ~8 years). AVX-512 (Ryzen 7000/9000) is a bit faster. |
+ | **Disk** | ~70-80 GB free for the model, ~6 GB for the MTP layer (+1 GB with images). **Q2_0 on an AVX-512 CPU** also writes a one-time ~40 GB copy of its experts for the fast CPU kernel. On Linux with an AMD card, ROCm takes ~10 GB more when setup installs it. An NVMe SSD is strongly recommended: it makes the first start much faster. |
+ | **OS** | Windows 10/11, or Linux (Ubuntu 22.04/24.04 get everything installed automatically). |
+ | **Driver** | **NVIDIA:** a current driver, version 580 or newer ([nvidia.com/drivers](https://www.nvidia.com/drivers) or the NVIDIA App). **AMD:** on Linux the kernel's amdgpu driver (no ROCm install needed); on Windows a current AMD Software: Adrenalin Edition driver ([amd.com/support](https://www.amd.com/en/support)). |
+
+ The driver is the only thing you install yourself. Everything else - Python, the engine, the model - is set up for
+ you the first time: Python 3.12 if you have none (for your user account, no admin), a private Python environment in
+ `.venv/`, the Strata engine, the model and the MTP draft layer. On NVIDIA it uses the ready-made engine for RTX
+ 20/30/40/50 and NVIDIA's CUDA libraries from pip (~0.4 GB); if no ready-made engine fits your PC, it offers to install
+ the build tools (Visual Studio Build Tools + CUDA Toolkit on Windows, `build-essential` + CUDA on Ubuntu) and compiles
+ the engine for your GPU (asks first; 20-40 minutes once). More: [details](DETAILS.md#before-you-start).
+
+ ## Windows
+
+ 1. [Download this project](https://github.com/Niko1221/Strata/archive/refs/heads/main.zip) and unzip it (or
+ `git clone` it).
+ 2. Double-click **`START-HERE.bat`**.
+ 3. Answer a few questions - or just press Enter each time for the recommended choice ([the questions](#setups-questions)).
+
+ Then it downloads everything (the model is ~70 GB, so the first time takes a while - you can stop and it picks up
+ where it left off) and **starts the model**. Your browser opens the Strata app at `http://127.0.0.1:8080`.
+
+ > **While the model starts, your PC can be slow or stop responding for 1-3 minutes** (longest the first time): Strata
+ > loads 35-55 GB into your RAM and locks part of it for the graphics card. That's normal - wait, and don't close the
+ > window. The window tells you what it is doing.
+
+ **Next time**, just double-click `START-HERE.bat` again: it starts right away (30-90 s to load the model), nothing is
+ downloaded twice. Close its window to stop the model. `SETUP.bat` (the same as `START-HERE.bat --setup`) installs
+ another model or changes the settings. Starting Strata from Task Scheduler at logon needs two task settings, or the
+ start is 24x slower: [Running it at startup](DETAILS.md#running-it-at-startup-task-scheduler).
+
+ ## Linux
+
+ ```bash
+ ./setup.sh
+ ```
+
+ The same questions, the same automatic install (it uses `sudo apt` for Python and, only if it has to compile, for
+ the build tools), and the same start: `http://127.0.0.1:8080`. Later runs of `./setup.sh` (or `./run-<model>.sh`)
+ start the model directly; `./setup.sh --setup` installs another model or changes the settings. Other distributions,
+ WSL and compiling: [details](DETAILS.md#linux).
+
+ ## AMD cards
+
+ The steps are the same as with NVIDIA: `START-HERE.bat` on Windows, `./setup.sh` on Linux. Setup finds the Radeon
+ card and chooses the AMD (HIP) engine by itself on a PC with no NVIDIA card Strata can use; `--backend hip` chooses
+ it on a PC that has both. Supported cards: RX 7900 XT / XTX (gfx1100), RX 7800 XT / 7700 XT (gfx1101), RX 9060 XT
+ (gfx1200), RX 9070 / 9070 XT and Radeon AI PRO R9700 (gfx1201), and the RX 6800 / 6900 series (gfx1030). Integrated
+ Radeon GPUs are listed as not supported.
+
+ On Linux setup uses a system ROCm 7 when there is one, or installs ROCm into `.venv` from AMD's wheels (~10 GB, no
+ sudo), and compiles the engine on your PC for the card (10-20 minutes, once; it needs a C++ compiler and git:
+ `sudo apt install build-essential git`). Several AMD cards share the model with `--gpus`, as on NVIDIA.
+
+ What differs from NVIDIA for now: pictures are read by the image encoder on the CPU (`--vision cpu`, 10-30 s per
+ picture), `--calibrate` is NVIDIA-only, and Unsloth's 4-bit model needs an NVIDIA card. Measurements per card, the
+ build by hand and the tuning tables: [AMD_HIP.md](AMD_HIP.md).
+
+ ## Two or three cards
+
+ **Two or three NVIDIA cards?** Just run `START-HERE.bat`: it lists your cards, says which ones Strata can use, and
+ asks whether to share the model across them (recommended when two can). An install made on one card asks once at
+ its next start. Or choose yourself: `START-HERE.bat --gpus 0,2` (both, remembered), `--gpus all`, or `--gpu 0` (one
+ card, this start only). Each card keeps the experts of its own layers, and prompts flow through the cards in a
+ pipeline: on an RTX 5080 + RTX 3090 prompts were read 18-20% faster than on the 5080 alone, decoding on par.
+ Every card must be an RTX 20 series or newer with 8 GB or more. See [MULTI_GPU.md](MULTI_GPU.md).
+
+ **Several AMD cards:** setup takes one card (the one with the most VRAM, or `--gpu N`) unless you name more:
+ `--gpus 1,0` splits the model's layers across them, the first one the main card (numbers as setup lists them). A
+ split pays only when no single card holds the model's experts ([AMD_HIP.md](AMD_HIP.md#rdna4-gfx1201)).
+
+ ## Docker (Linux)
+
+ The same idea, in a container (NVIDIA cards).
+
+ 1. Host: Docker with the [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html)
+ and a driver **580 or newer** (CUDA 13.0).
+ 2. Build (this compiles the engine into the image, so the container never compiles):
+ `docker build -t strata .`
+ `docker build -t strata --build-arg CUDA_ARCHITECTURES=89 .` builds for one card only (faster).
+ The default covers RTX 30 (86), RTX 40 (89), RTX 50 (120) and A-series (80); a card outside that
+ set needs a rebuild with its own arch. Add `--build-arg BUILD_VISION=0` to skip the image encoder.
+ 3. Run (the first start downloads the ~70 GB model, then starts; later starts go straight to serving):
+ `docker run --rm --gpus all -p 8080:8080 --ulimit memlock=-1 -v strata-data:/data strata`
+
+ The setup choices are env vars: `-e MODEL=IQ2_XS -e FAMILY=qwen -e CONTEXT=32768 -e VISION=no`
+ (or `MODEL=Q2_0|IQ3_XXS|IQ3_S`, `FAMILY=swift|coder`; the defaults above are the recommended ones).
+ `-e VISION=cpu` keeps the image encoder on the CPU. `-e KV=int8|q4_0|k8v4` picks the KV cache
+ precision; `k8v4` is INT8 K with 4-bit V and keeps its KV in VRAM from 64K up.
+ Only the model files, the prepared pack, the MTP layer and the install config live in the
+ `strata-data` volume; the engine is part of the image. Switching between models already on the
+ volume needs no setup pass: `-e MODEL=Q2_0 -e FAMILY=coder` picks that model's config. Add
+ `-e REINSTALL=1` only to change settings for a model already set up (context, vision, KV, host,
+ api_key, LOW_RAM), since those are recorded in its config.
+ Strata loads 32-62 GB into RAM. `--gpus all` on a host with two usable cards takes both: the
+ layer split is setup's recommended default ([MULTI_GPU.md](MULTI_GPU.md)), and a volume
+ set up for one card switches to the pair on its first start there. Pin one card with `-e GPU=0`,
+ or name them with `-e GPUS=0,2` and where the later card's layers start with `-e LAYER_SPLIT=18`.
+ A memory limit needs `-e LOW_RAM=on`, which maps the model's experts from the pack instead of
+ keeping them in RAM: setup.py measures the host's RAM, not the container's limit, so it cannot
- see a cap. LOW_RAM runs on one card.
++ see a cap. LOW_RAM runs on one card unless `GPUS` names several (then the experts the cards do not hold are
++ read through the OS file cache, which can fill the RAM during long prompts).
+ The server listens on `0.0.0.0:8080` by default; set `-e API_KEY=<secret>` before exposing the port
+ to a network. The image has a `HEALTHCHECK` on `/health`, so `docker ps` shows the container
+ healthy once the model is loaded, and `GET /v1/status` says what it is running.
+
+ ## Updating
+
+ Download the new version and unzip it anywhere (or `git pull`), then run `START-HERE.bat` (Linux: `./setup.sh`) in
+ it. The model files are kept in a `Strata-data` folder next to your Strata folder, so a new copy finds them and sets
+ itself up the same way - nothing big is downloaded again. On Linux after a `git pull`, setup compiles the engine
+ again when its source changed (a minute or two for the changed files); if that compile fails, it says so and starts
+ the engine you had.
+
+ ## Where things are stored
+
+ - **Your chats: only in your browser.** The Chat tab keeps the conversation, its settings and the API key you typed
+ in the browser's local storage (`strata.*` keys) - not on the server and not in the Strata folder. Pictures are not
+ kept, only their names. Another browser or a private window starts empty; clearing the site's data deletes them.
+ - **How the model starts:** `strata-<model>.json` in the Strata folder (context, GPUs, host, API key, ...), written
+ by setup; next to it `run-<model>.bat` / `.sh`, the log `strata-<model>.log` and, when you use "Use for other
+ apps too", `strata-<model>.shared-settings.json`.
+ - **The model files** (`models/`, `packs/`, `mtp/`, 70-120 GB): in **`Strata-data` next to the Strata folder**, or
+ wherever `--data-dir` put them.
+ - **Where that data folder is:** `%APPDATA%\Strata\settings.json` on Windows, `~/.config/strata/settings.json` on
+ Linux ([details](DETAILS.md#before-you-start)).
+ - **The program itself:** `.venv/`, `engine/` and `third_party/` in the Strata folder.
+
+ ## Setup's questions
+
+ - **Which model and size?** The original, Swift 1.5, the Coder or Unsloth's 4-bit, and Q2_0, IQ2_XS, IQ3_XXS or
+ IQ3_S - see [which model](MODELS.md).
+ - **How much context?** How much text it can keep in mind at once (it suggests one for your card). 384K and
+ 512K (experimental) extend the model past its trained 262K by rope scaling - the setup turns it on itself (yarn and a
+ covering factor; `--rope-scaling`/`--rope-scale` override) ([details](DETAILS.md): "Context extension past
+ 262K").
+ - **Images?** Whether it should also read pictures. The image encoder (0.9 GB) runs on the GPU (0.1-0.5 s per
+ picture, ~1.4 GB of VRAM kept free for it) or on the CPU (10-30 s per picture, nothing on the GPU); with AMD cards
+ on the CPU for now. [Details](DETAILS.md#images-vision).
+ - **Experimental speed projection?** Off unless you say yes - [read what it does](DETAILS.md#experimental-speed-projection-experimental-off-by-default)
+ first. It changes how the model answers, and only the original model offers it.
+
+ With `--yes` setup takes the recommended answer to every question.
+
+ ## Tuning for your PC
+
+ Every PC is different: `START-HERE.bat --calibrate` (Linux: `./setup.sh --calibrate`) measures a few engine settings
+ on yours and keeps the fastest (about 5-10 minutes; on an RTX 5070 with a Ryzen 5 7600 it made the Coder 7% faster).
+ It keeps a setting only when it is more than 3% faster, and the result is remembered per PC and model, so updates
+ keep it. NVIDIA cards for now. [What it measures](DETAILS.md#double-click-start-herebat).
+
+ ## Options without questions
+
+ ```
+ START-HERE.bat --setup install another model, or change context / images
+ SETUP.bat the same (double-click it)
+ START-HERE.bat --model IQ2_XS --context 32768 --vision yes --yes no questions
+ START-HERE.bat --gguf-dir D:\models\IQ2_XS use GGUF files you already have
+ START-HERE.bat --data-dir E:\Strata-data keep the model files somewhere else
+ START-HERE.bat --port 8081 another port
+ START-HERE.bat --gpu 1 another GPU (setup picks the one with the most VRAM)
+ START-HERE.bat --gpus 0,2 several GPUs sharing the model
+ START-HERE.bat --setup --backend hip the AMD engine on a PC that also has an NVIDIA card
+ START-HERE.bat --setup --host 0.0.0.0 --api-key <secret> reachable from other devices, with a key
+ START-HERE.bat --calibrate tune the engine for this PC (about 5-10 minutes), then start
+ START-HERE.bat --check only check this PC
+ ```
+
+ On Linux the same options go to `./setup.sh`. `START-HERE.bat --help` lists them all. The server's own settings
+ (sharing the GPU with games, MCP tools, CORS, API keys, the API itself) are in the [details](DETAILS.md#using-it).
diff --cc setup.py
index 9f42aa4d5,c888f7491..654e2548d
--- a/setup.py
+++ b/setup.py
@@@ -951,7 -896,7 +951,7 @@@ def cuda_lib_dirs()
return [str(d) for d in dirs]
--# ------------------------------------------------------------------------------------------------ AMD (experimental)
++# ------------------------------------------------------------------------------------------------ AMD
# The RX 7900 XT / XTX (gfx1100) and the RX 9070 series / Radeon AI PRO R9700 (gfx1201) on Linux, through the HIP
# backend (docs/AMD_HIP.md); the RX 7800 XT / 7700 XT (gfx1101, #254) and the RX 9060 XT (gfx1200, #256) were run by
# their owners; the RX 6800 / 6900 series (gfx1030, #311) runs but is unvalidated. There is no ready-made AMD engine: ROCm comes from AMD's TheRock Python wheels into .venv (no sudo;
@@@ -2582,20 -2154,12 +2582,20 @@@ def main() -> int
"(for a PC with a big GPU and little RAM); auto: when the experts would not fit the RAM. In "
"this mode the experts the GPU does not hold are copied into RAM once when they fit (resident), "
"else read through the OS file cache (mmap); resident / mmap force one of the two")
+ ap.add_argument("--resident-budget-gib", type=float, metavar="N",
+ help="UD-Q4_K_XL: the GiB of its experts kept in RAM (default: the RAM less 24 GB, 40 on 64 GB; "
+ "more is kept as you choose, with a note)")
+ ap.add_argument("--kv-streaming", choices=["auto", "on", "off"], default="auto",
+ help="from a 64K context: keep the KV cache in RAM and only the attention's window in VRAM (more "
+ "experts fit on the GPU); auto: when the RAM has room for it")
ap.add_argument("--backend", choices=["cuda", "hip"],
help="cuda = NVIDIA (default), hip = AMD RX 7900 / 7800 / 7700 XT, RX 9060 XT / 9070 / AI PRO R9700 on "
- "Linux or Windows (experimental; chosen by itself when the PC has no NVIDIA card Strata can use)")
- "Linux (chosen by itself when the PC has no NVIDIA card Strata can use)")
++ "Linux or Windows (chosen by itself when the PC has no NVIDIA card Strata can use)")
ap.add_argument("--skip-build", action="store_true", help=argparse.SUPPRESS)
a = ap.parse_args()
- if a.gpu is not None: # --gpu 0,2 means --gpus 0,2 (a user tried it: issue report)
+ if a.resident_budget_gib is not None and not a.resident_budget_gib > 0:
+ ap.error("--resident-budget-gib takes a number of GiB above 0, e.g. --resident-budget-gib 32")
+ if a.gpu is not None: # --gpu 0,2 means --gpus 0,2 (a user tried it: issue report)
if "," in a.gpu:
a.gpus, a.gpu = a.gpus or a.gpu, None
elif a.gpu.strip().isdigit():
@@@ -2677,15 -2241,14 +2677,16 @@@
say(" 1) NVIDIA: " + ", ".join(f"{g['name']} ({g['vram_gb']:.0f} GB)" for g in found if gpu_problem(g) is None)
+ " (recommended)")
say(" 2) AMD: " + ", ".join(f"{g['name']} ({g['vram_gb']:.0f} GB)" for g in amd_ok)
- + f" (experimental: {'the ready-made AMD engine' if WIN else 'compiled here'}, no images - docs/AMD_HIP.md)")
- + " (compiled here, images on the CPU - docs/AMD_HIP.md)")
++ + f" ({'the ready-made AMD engine, no images' if WIN else 'compiled here, images on the CPU'}"
++ " - docs/AMD_HIP.md)")
hip = ask("Which cards?", ["1", "2"], "1", a.yes or a.check) == "2"
if a.check and not hip:
- say(" (the AMD card: ./setup.sh --backend hip)")
- if hip: # AMD (experimental): compiled here
- if WIN:
- fail("Strata's AMD backend runs on Linux only", "use an NVIDIA RTX 20 series or newer card on Windows")
- say(" Your AMD GPUs:" if amd else " No AMD GPU found (the amdgpu driver's KFD topology is empty).")
+ say(f" (the AMD card: {'START-HERE.bat' if WIN else './setup.sh'} --backend hip)")
- if hip: # AMD (experimental): compiled here; Windows: ready-made
++ if hip: # AMD: compiled here; Windows: ready-made
+ if WIN and a.gpus:
+ fail("several AMD cards sharing one model (--gpus) is Linux-only for now", "use one card: --gpu N")
+ say(" Your AMD GPUs:" if amd else " No AMD GPU found (" + ("Windows lists no AMD display adapter)." if WIN
+ else "the amdgpu driver's KFD topology is empty)."))
for g in amd:
say(f" GPU {g['index']}: {g['name']}, {g['vram_gb']:.0f} GB VRAM - " + (amd_problem(g) or "can be used"))
usable = [g for g in amd if amd_problem(g) is None]