Server Installation Guide

From environment setup to a running service, in five steps.

English · 简体中文

Quick start · Server · Configuration · Client installation

01
Check
GPU

02
Install
Python

03
Model
Weights

04
Start
Warmup

05
Verify
HTTP

> By default, the game and Client run on Windows, with Server in WSL2 on the same PC. Run these commands from `server/` in the **WSL2 Ubuntu terminal**. For a separate Linux GPU server, run them directly on that host.
Quick installation: use the script (recommended) Set up WSL2 and the NVIDIA driver ([step 1](#step-1)) and download the complete checkpoint ([step 3](#step-3)), then run from `server/` in WSL2: ```bash bash install.sh --model-path /path/to/model bash start.sh --idle-reset-secs 3600 ``` `install.sh` installs the environment and `start.sh` starts Server; continue to [step 5](#step-5) to verify it. See [step 2 notes](#installer-notes) for installer options and [step 4 notes](#launch-notes) for checkpoint changes, memory issues and logs. For a manual installation, follow all five steps below.
## 1. Check Environment | Item | Requirement | |---|---| | OS | Linux `x86_64`; the default same-PC setup uses WSL2 | | Python | 3.13 | | CUDA Toolkit | 13.0 / 13.3, including `nvcc` | | Build tools | C++ compiler and Python headers | | GPU | NVIDIA RTX 5090 (Blackwell SM120) / H100 (Hopper SM90); only these two have been adapted and tested, other GPUs are not guaranteed | | VRAM | At least 16 GB recommended for the default 128K context; prefer 24 GB | ```bash uname -sm python3.13 --version nvcc --version nvidia-smi ``` > **Completion check** > > The platform and versions meet the requirements, and `nvidia-smi` shows the target GPU.
Notes: same-PC setup, hardware and memory **Prepare the same-PC environment** If WSL2 is not installed, run the following in an administrator Windows PowerShell terminal, restart when prompted, and finish initializing the Linux distribution: ```powershell wsl --install -d Ubuntu-24.04 wsl --update wsl --list --verbose ``` Confirm that the distribution version is `2`. Follow the [NVIDIA CUDA on WSL guide](https://docs.nvidia.com/cuda/wsl-user-guide/index.html#getting-started-with-cuda-on-wsl): install a WSL-capable NVIDIA driver on Windows and the required CUDA Toolkit from the table above inside WSL2. Do not install a Linux GPU driver inside WSL2. Then run this step's environment checks. Use Windows Python for Client, and create Server's Python environment and `.venv` inside WSL2. Use project and model paths accessible from the current environment; keep the two virtual environments separate. Validate kernels and serving on the target machine in steps 2 and 5. **Share resources with the game** On one PC, the game and inference share the GPU, VRAM and system resources. The figures below cover the server only, excluding the game and desktop. Size the workload for the actual available VRAM on an RTX 5090 desktop or laptop; reduce `MAX_LEN` through [model and capacity settings](CONFIGURATION.md#model) when more room is needed for the game. Check resource headroom during both server warmup and gameplay. **Backends and server memory** - **Blackwell SM120**: Uses native CuTeDSL FP8 TMA paged split-KV prefill through `nvidia-cutlass-dsl`. - **Hopper SM90**: Uses `ATTENTION_BACKEND=fa3`, with `flash_attn_3` installed separately. Other GPUs use FlashAttention-2 (`ATTENTION_BACKEND=fa2`). - **Memory breakdown**: Steady-state peak VRAM at full 128K context is approximately **13.6 GB**, including FP8 weights, paged FP8 KV pools and CUDA graphs. One-time weight quantization at startup needs additional room, hence the recommendation of at least 16 GB, preferably 24 GB. - **BF16 KV cache**: `KV_CACHE_DTYPE=bf16` doubles KV cache memory; total peak VRAM at 128K is approximately **16.1 GB**. Related settings are in [appendix G: KV cache and compute backends](CONFIGURATION.md#hardware).
Notes: project paths, caches and WSL storage **Project and model paths** Choose your own locations for source, models and the WSL distribution. Windows and WSL use different path formats; run `wslpath 'absolute Windows path'` in Ubuntu to obtain the corresponding Linux path. Replace example paths in installation and startup commands with your actual locations. **Environments and caches** Both installers keep downloaded Python runtimes, uv / pip caches and installation temporary files in their own `.install-cache/`, with virtual environments in `.venv/`. The server startup script also defaults Hugging Face, Triton, CUDA and PyTorch extension caches to `server/.install-cache/`; environment variables can override these paths. CUDA Toolkit and apt packages use standard Linux directories stored in the WSL distribution's virtual disk. Existing Python environments are reused, not relocated. After moving a project, rerun the installers to create environments instead of moving virtual environments directly. **Custom WSL storage (optional)** For a fresh installation, append `--location ""` to `wsl --install -d Ubuntu-24.04`, replacing the placeholder with your Windows directory; see the [official WSL commands](https://learn.microsoft.com/en-us/windows/wsl/basic-commands#install). If unavailable, run `wsl --update` and check `wsl --help`. To move an existing distribution, save your work and exit WSL programs, then run in Windows PowerShell with an unused destination: ```powershell wsl --update wsl --shutdown wsl --manage Ubuntu-24.04 --move "" ``` Replace the distribution name if needed. See the [official command help](https://github.com/microsoft/WSL/blob/master/localization/strings/en-US/Resources.resw) for `--manage --move`; do not unregister the distribution as a substitute for moving it. **WSL swap file (optional)** The swap location is separate; neither `--location` nor moving a distribution changes it automatically. Run `notepad "$env:USERPROFILE\.wslconfig"` in Windows PowerShell. Preserve existing settings and set `swapFile` in the `[wsl2]` section to the destination file's absolute Windows path, escaping backslashes as double backslashes. Create its parent directory first. Save your work and exit WSL programs, then run `wsl --shutdown`; the change takes effect at the next startup. It applies to all WSL2 distributions; see [Microsoft's configuration reference](https://learn.microsoft.com/en-us/windows/wsl/wsl-config) for the full format. Windows components, drivers and this configuration file still use system-defined locations.
## 2. Install Dependencies Create a Python environment, then install PyTorch and the project dependencies. Hopper users also need the FA3 installation below. **Create the environment** ```bash python3.13 -m venv .venv source .venv/bin/activate python -m pip install --upgrade pip setuptools wheel packaging ninja ``` **Install PyTorch and project dependencies** Use the CUDA 13.0 PyTorch packages, matching [pyproject.toml](../pyproject.toml) ([official installation instructions](https://pytorch.org/get-started/previous-versions/#v2120)). ```bash python -m pip install torch==2.12.0 torchvision==0.27.0 \ --index-url https://download.pytorch.org/whl/cu130 python -m pip install --no-build-isolation -e . ``` `--no-build-isolation` builds CUDA extensions against the installed PyTorch. Keep using this environment for the following steps. **Hopper SM90: install FlashAttention-3** Blackwell users can continue to the installation check below. Install FA3 from the [Hopper implementation in FlashAttention v2.8.3](https://github.com/Dao-AILab/flash-attention/tree/v2.8.3#flashattention-3-beta-release), which provides the `flash_attn_interface` API used by this project. Git is required; compilation can take time. ```bash python -m pip install --no-build-isolation \ "git+https://github.com/Dao-AILab/flash-attention.git@v2.8.3#subdirectory=hopper" ``` **Check the installation** Check dependencies and GPU kernels. Model weights are not needed yet: ```bash python -m sash.check_install --smoke ``` > **Completion check** > > The command exits successfully and its output includes `"gpu_smoke": "passed"`.
Notes: installer options and behavior The script checks the NVIDIA GPU, installs build tools and a missing CUDA Toolkit 13.0 on Ubuntu 22.04 / 24.04 `x86_64`, creates a Python 3.13 environment, installs pinned dependencies and checks GPU kernels. Hopper also gets FA3. Other Linux distributions need a C++ compiler, Git, curl and CUDA Toolkit 13.0 / 13.3 installed beforehand. Install the GPU driver first; WSL2 uses the Windows driver. System package installation requires `sudo` privileges. Download the complete checkpoint first. Without `--model-path`, the installer uses a saved path or asks interactively. Model and CUDA paths are saved locally in `.install-cache/launch.env`, excluded from version control. The installer exits when setup is complete. Start Server separately with `bash start.sh --idle-reset-secs 3600`. Select an existing CUDA Toolkit with `CUDA_HOME=/usr/local/cuda-13.3 bash install.sh`. An incompatible environment or dependency failure stops the installer immediately. Fix the issue and rerun; existing environments are not deleted. Bootstrap references: [uv installation](https://docs.astral.sh/uv/getting-started/installation/) and [NVIDIA CUDA installation](https://docs.nvidia.com/cuda/cuda-installation-guide-linux/).
Notes: dependencies, backends and check coverage **Dependencies** `--no-build-isolation` lets `flash-attn` and `causal-conv1d` compile against the installed PyTorch. The pinned dependencies also include `flash-linear-attention`, `triton`, and the SM120 CuTeDSL stack: `nvidia-cutlass-dsl`, `apache-tvm-ffi` and `cuda-bindings`. **Backend selection** `sash/config.py` defaults to `ATTENTION_BACKEND=fa3` on Hopper SM90 and `ATTENTION_BACKEND=fa2` on SM120 and other GPUs. `sash/kernels/attention_backend.py` never silently falls back when a backend is unavailable; install Hopper's `flash_attn_3` separately with the command above. See [appendix G](CONFIGURATION.md#hardware) for backend and kernel switches. **GPU checks** `--smoke` requires a GPU but does not load model weights. On SM120, it exercises `sm120_fmha_fp8_paged_prefill` in `sash/kernels/sm120_fmha.py`, plus `paged_kv.merge_split_kv` and `paged_kv.fused_decode_attn_fp8_paged`. On other GPUs, the `sm120_fmha` checks are skipped. **Import-only check** In a build environment without a GPU, use `--imports-only` to check dependency imports. This does not replace the GPU smoke test. Explicitly select an installed backend (`fa2` or `fa3`): ```bash ATTENTION_BACKEND=fa2 python -m sash.check_install --imports-only ```
## 3. Prepare Model **Model download:** [Lumine2](https://huggingface.co/LumineResearch/Lumine2) or [Lumine2-EN](https://huggingface.co/LumineResearch/Lumine2-EN) on Hugging Face. Both use the same server; see the model notes in the [README](../../README.md#prepare). For example: ```bash hf download LumineResearch/Lumine2 --local-dir ~/models/Lumine2 ``` Replace the path with your local model checkpoint directory. It must contain `config.json`, safetensors weights and tokenizer/processor files. ```bash export MODEL_PATH=/path/to/local/model ls "$MODEL_PATH/config.json" ``` > **Completion check** > > The command prints the path to `config.json`, and all model files have finished downloading. For automatic downloads, use the alternative in this step's notes.
Notes: model downloads, prompts and draft vocabulary **Automatic download** After step 2, `start.sh` can download a checkpoint from Hugging Face and start the server, replacing steps 3 and 4. Replace `owner/repo` with an accessible model repository: ```bash env -u MODEL_PATH MODEL_REPO=owner/repo bash start.sh --port 8000 ``` Set `MODEL_REVISION` (revision) and `MODEL_CHECKPOINT` (checkpoint subdirectory) if needed. Wait for download, loading and warmup to finish; continue to step 5 once the listening message described in step 4 appears. **System prompt** Clients must send the system prompt themselves; `sash/assets/default_prompt.txt` is the template used during training. See the [API request example](API.md#using-the-server) for usage. **Draft vocabulary** The shortlist defaults to `sash/assets/draft_vocab.json`. Override it with `DRAFT_VOCAB`, or set `DRAFT_VOCAB=0` to use the full vocabulary. See [appendix A](CONFIGURATION.md#model) for model paths and capacity, and [appendix D](CONFIGURATION.md#mtp) for draft vocabularies. **Other settings** The full list of runtime environment variables, defaults and descriptions is in the [configuration appendix](CONFIGURATION.md).
## 4. Start Server Run in the same terminal, using the default configuration for the first launch: ```bash bash start.sh --port 8000 ``` Startup checks dependencies, loads the model and runs warmup. Warmup still needs to finish after `Model ready.` appears. > **Completion check** > > The terminal shows `Uvicorn running on ...:8000`. Leave this terminal running.
Notes: later sessions, checkpoint changes, memory and logs For later sessions, run `bash start.sh --idle-reset-secs 3600` in this directory. Stop and restart any running service after changing checkpoints. Rerun the installer to save a different checkpoint, or temporarily override it with `MODEL_PATH=/new/path bash start.sh`; an explicit `MODEL_REPO` still supports checkpoint downloads. The game and model share VRAM on one PC. If startup runs out of memory, try `MAX_LEN=32768 bash start.sh --idle-reset-secs 3600`, then run Client with Python on Windows to connect to that service. Server output appears in the current terminal; when launched from `client/`, Client saves logs in `client/execution_data/`.
Notes: operating modes and two-GPU startup **Python interpreter** `start.sh` uses `.venv/bin/python` when available, otherwise `python3`. Set `VENV_DIR=/path/to/venv` to select another environment, or `PYTHON_BIN=/path/to/python` to select the interpreter directly; `PYTHON_BIN` takes precedence. **Defaults** Context capacity is `131072` tokens with `T=4` Multi-Token Prediction (MTP). `--reasoning` is enabled by default. | Parameter | Default | |---|---| | `--reasoning-history-rounds` | `15` | | `--action-window-frames` | `120` | | `--force-thinking-steps` | `120` | **Reasoning mode** Each new thought clears the action frames and is folded into the reasoning prefix. The defaults produce sawtooth window growth and reset. Set `--force-thinking-steps -1` to disable forced thinking and evict action frames with a sliding window when its capacity is exceeded. To specify the defaults explicitly: ```bash MODEL_PATH=/path/to/local/model bash start.sh \ --reasoning-history-rounds 15 \ --action-window-frames 120 \ --force-thinking-steps 120 ``` **Action-only mode** `--no-reasoning` disables thoughts, generates actions only and keeps a sliding window of the most recent 135 frames: ```bash MODEL_PATH=/path/to/local/model bash start.sh \ --no-reasoning --action-window-frames 135 ``` **Direct startup** After checking dependencies and preparing the local model, you can also run the server module directly: ```bash MODEL_PATH=/path/to/local/model python -m sash.server --port 8000 ``` **Two-GPU startup** Set `TP_SIZE=2` for tensor parallelism across two Hopper GPUs connected by NVLink; also set `TP2_ALLOW_ANY_PAIR=1` on SXM5 NVSwitch: ```bash CUDA_VISIBLE_DEVICES=0,1 TP_SIZE=2 MODEL_PATH=/path/to/local/model \ python -m sash.server --port 8000 ``` Look up [context and reasoning history](CONFIGURATION.md#context), [sampling](CONFIGURATION.md#sampling), [tensor parallelism](CONFIGURATION.md#parallel) or [command-line flags](CONFIGURATION.md#command-line) in the appendix.
## 5. Check Service Open a **second terminal on the same machine** and run: ```bash curl --fail --silent --show-error http://127.0.0.1:8000/health ``` > **Completion check** > > The response is JSON containing `"status": "ok"` and `"engine": "sash"`. Installation is complete. Send your first request using the [API example](API.md#using-the-server), or explore the [configuration appendix](CONFIGURATION.md).
Notes: extended verification and developer tests These extended checks are optional. Stop the server first, then run the checks you need in the Python environment from step 2. Dependency import and GPU smoke-test coverage is described in the step 2 notes. Diagnostic switches and their meanings are in [appendix I: diagnostics and auditing](CONFIGURATION.md#diagnostics). **Zero-JIT warmup check** Requires a GPU and model weights. `--verify-warmup` loads the model, runs warmup and checks that no new Triton compilation occurs afterward: ```bash MODEL_PATH=/path/to/local/model STRICT_NO_POST_WARMUP_JIT=1 \ python -m sash.check_install --verify-warmup ``` **Unit tests** No model weights are required. Leave `MODEL_PATH` unset, or test discovery also loads the model for `tests/test_server.py`: ```bash env -u MODEL_PATH python -m unittest discover -s tests -v ``` These cover configuration, special tokens, action grammar and validation, reasoning history and cache bookkeeping, HTTP endpoints and decode retries on CPU fakes, plus Triton kernel tests when the corresponding GPU is available. **Triton kernel self-tests and server-logic smoke test with the full model** Require a GPU and `MODEL_PATH`: ```bash MODEL_PATH=/path/to/local/model python -m unittest tests.test_kernels -v MODEL_PATH=/path/to/local/model MAX_LEN=131072 \ python tests/test_server.py ```
## If a Step Fails | Step | Problem | What to check | |:---:|---|---| | [02](#step-2) | missing `nvcc` or a build failure | Check that CUDA Toolkit, `nvcc`, a C++ compiler and Python headers are installed and available | | [02](#step-2) | missing `flash_attn_interface` | Complete the Hopper FA3 installation above, using the same Python environment | | [02](#step-2) | no visible CUDA GPU | Check `nvidia-smi`, the CUDA build of PyTorch, and whether `CUDA_VISIBLE_DEVICES` hides the GPU | | [04](#step-4) | out of GPU memory | Free GPU memory first; try `MAX_LEN=32768 bash start.sh --port 8000` to reduce context capacity | | [05](#step-5) | connection failure | Check that step 4 reached the listening message, the server is still running and the port matches |