Serve a large mixture-of-experts model across used data-centre GPUs with Strata
At the end of this tutorial you will have a large 4-bit mixture-of-experts model answering requests through an OpenAI-style API, spread across your NVIDIA cards, started by systemd and protected by an API key. It is for anyone with used data-centre cards such as the Tesla V100 or P100 and a machine with plenty of RAM.
Requirements: 1 to 4 NVIDIA cards, compute capability 6.0 or newer · Linux with systemd · NVIDIA driver 575.51 or newer for the CUDA 12 engine · CUDA 12.x toolkit, CMake for Pascal or Volta builds · current Strata release
A mixture-of-experts model uses only a small share of its weights for each token. That is why a file larger than your VRAM can still run at a useful speed: the experts used most often sit on the GPUs, and the rest wait in RAM or on disk. Most of the settings below decide where each part lives.
Requirements
- One to four NVIDIA cards; Pascal (6.x) and Volta (7.0) cards need the CUDA 12 engine, because CUDA 13 cannot compile for them
- VRAM plus spare RAM larger than the model file, with several GB to spare
- A CUDA 12.x toolkit and CMake if you build for older cards yourself
- The model's GGUF files on a local NVMe or fast SSD
- A Linux user that will own the service, and a long random API key
Steps
1. Choose the quantisation for your memory
Add your VRAM and the RAM you can give the engine, then pick the largest quantisation that fits with a margin of several GB. A larger 5- or 6-bit file pushes more experts off the cards and into RAM, which costs speed. For example, three 32 GB cards and 144 GB of RAM carry a 111 GB 4-bit file with every expert on the GPUs (our test). A 4-bit file is not automatically a large loss in accuracy: see our MMLU-Pro run before you pay for a bigger one.
2. Install Strata, or build it for older cards
On recent cards, use the installer. Download install.sh from the latest release on the project's releases page, read it, then run it:
sh install.sh
The installer also handles older cards: it looks for the newest CUDA 12.x toolkit and builds the engine. To build it yourself for Pascal and Volta, use the form in the project's older GPUs guide:
cmake -S engine -B build-cuda12 -DSTRATA_ENABLE_CUDA=ON -DSTRATA_BUILD_TESTS=OFF -DSTRATA_EXPERIMENTAL_SM60=ON \
-DCMAKE_CUDA_ARCHITECTURES="61;70" -DCMAKE_CUDA_COMPILER=<cuda12-dir>/bin/nvcc
cmake --build build-cuda12 --target strata -j
Set the architecture list to your cards: 70 for V100 or Titan V, 60 for P100, 61 for P40 and consumer Pascal. Older cards are used only when you name them, so pass --gpu in the next step.
3. Name the cards and the slots
With several cards, Strata gives each card a run of consecutive layers. Name the cards and the number of requests to serve at once:
strata launch --gpu 0,1,2 --parallel 1
Parallel slots are the choice that most changes how the server feels. One request alone can use the model's draft layer, which guesses tokens ahead and checks them in one pass. Several requests together share the cards. Use 1 for one person and one agent. Use 2 to 4 for several users or agents at once. On three cards we'd pick three slots rather than four, so the slots divide evenly across the cards.
4. Set the context length
The context limit costs memory on every card even when no request uses it, and that memory comes out of the room for experts.
strata launch --gpu 0,1,2 --context 128k --kv int8
int8 is the documented default for the cache; q4_0 and k8v4 save more memory. If you do not need very long prompts, a smaller limit is the cheaper choice. A larger one makes long prompts slower to read, because fewer experts fit on the cards (our test).
5. Tune the engine options in the config file
Engine options go in the "args" list of the model's strata-<model>.json run config, as described in the project's settings reference. The ones that matter most here:
"args": [
"--vram-reserve-mib", "1024",
"--kv-resident", "32768",
"--resident-budget-gib", "24",
"--conversation-cache-mib", "20480",
"--conversation-cache-slots", "8",
"--conversation-cache-min-tokens", "4000",
"--ple-io", "ram"
]
--vram-reserve-mibkeeps headroom on every card. Leave it near 1024. A very small reserve can make the engine run out of memory while it builds its batch graphs.--kv-residentkeeps that many tokens of each layer's cache on the cards and the rest in RAM, so a long context limit costs less VRAM.--resident-budget-gibsizes the RAM copy of experts that do not fit on the cards. Without it they are read from the model file. Give it what your RAM allows after the system and the conversation cache.- The conversation cache parks a finished conversation in RAM so the next turn does not re-read the whole prompt. Set it explicitly, so a busy page cache at start cannot leave it small.
--ple-io ramkeeps the model's n-gram table in RAM instead of reading it from disk. Use it if your model has one and your disks are SATA (our analysis).
Most of these settings apply only after a full restart of the server.
6. Set an API key
Keep the key in an environment variable, never on the command line where other users can see it:
strata launch --api-key-env STRATA_API_KEY
7. Run it as a service
Save a unit such as this as <unit-dir>/strata-server.service. Run strata launch --help to find the start command and mode that suit a service; --no-tui serves without the terminal monitor.
[Unit]
Description=Strata inference server
After=network-online.target nvidia-persistenced.service
Wants=network-online.target nvidia-persistenced.service
[Service]
User=<service-user>
EnvironmentFile=<unit-dir>/strata.env
ExecStart=<your start command>
LimitMEMLOCK=infinity
MemoryHigh=70G
MemoryMax=88G
TimeoutStartSec=900
Restart=on-failure
RestartSec=15
[Install]
WantedBy=multi-user.target
Set MemoryHigh and MemoryMax to your machine, with room for the RAM copy and the conversation cache. A cold start of a file this size takes minutes, so keep the long start timeout. Then:
systemctl daemon-reload
systemctl enable --now strata-server
Check it worked
Follow the service log until the engine reports that it is ready and prints its address. Check that it names all your cards and that it says an API key is required. Then send one request:
curl -s http://<server-address>:<port>/v1/chat/completions \
-H "Authorization: Bearer <your-key>" -H "Content-Type: application/json" \
-d '{"model":"<model-name>","messages":[{"role":"user","content":"Say hello."}],"max_tokens":64}'
Look for a JSON body with a choices array and a message. The same request without the key should be refused. strata launch --status shows what is running.
Common problems
- Out-of-memory crashes during start or the first batch: raise
--vram-reserve-mibback to about 1024 and restart the service. - Long prompts read slowly after raising the context: raise
--resident-budget-gib, or lower the context limit. - The conversation cache is small or off: free RAM was short at start; set
--conversation-cache-mibexplicitly. - The start timed out: a cold model file on slow disks takes longer; raise
TimeoutStartSec. - The service is killed by its memory limit: raise
MemoryMax, and keepMemoryHighbelow it. - The build fails for Pascal or Volta: CUDA 13 cannot compile for them; use a 12.x toolkit.
Our recommendation
For one person we'd run one slot, because drafting makes a single request much faster. For a small team or several agents we'd run as many slots as cards and accept a lower speed per request (our comparison). We'd spend spare RAM on the expert copy before a longer context, set the conversation cache by hand, and leave the VRAM reserve alone.