[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-110382":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":19,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":22,"hasPages":22,"topics":24,"createdAt":10,"pushedAt":25,"updatedAt":26,"readmeContent":27,"aiSummary":28,"trendingCount":16,"starSnapshotCount":16,"syncStatus":15,"lastSyncTime":29,"discoverSource":30},110382,"saber-engine","GGZ14\u002Fsaber-engine","GGZ14","A Rust inference engine currently targeting AMD R9700 GPU's.   buymeacoffee.com\u002Fbkuyper","https:\u002F\u002Fx.com\u002Fbkuyper",null,"Rust",74,5,1,2,0,7,22,3,48.24,"Apache License 2.0",false,"main",[],"2026-11-19 16:58:32","2026-11-21 02:51:41","# Saber\n\nA Rust inference engine for the Qwen3.8 family on AMD Radeon AI PRO R9700 (gfx1201 \u002F RDNA4).\nKernels ship as HIP code objects plus a manifest, the host owns every launch decision, and one\nresolved plan replaces a flat environment-variable namespace. The server speaks the OpenAI API.\n\n**Qwen3.8-27B** runs at tensor-parallel 2 on two R9700s with the DFlash2 speculative drafter:\nabout 229 tok\u002Fs single-stream decode, TTFT around 47 ms, and 5,000+ tok\u002Fs prefill at a 210 W\nper-card cap, with a 262,144-token context, prefix caching and optional vision.\nIt also runs on **one card** (TP=1, `tools\u002Fserve_27b.sh --tp 1`) with smaller context and concurrency\ndefaults; see \"One card (TP=1)\" below.\n**Qwen3.8 Flash-Next** (MoE) is served by the same binary.\n\n## What you need\n\n| | |\n|---|---|\n| GPUs | 2x Radeon AI PRO R9700 (gfx1201), PCIe; one card works for TP=1 |\n| OS \u002F runtime | Linux with the ROCm kernel driver (`\u002Fdev\u002Fkfd`, `\u002Fdev\u002Fdri`) and **podman or docker** |\n| Host | a fast NVMe for the weight packs (`\u002Fmnt\u002Fnvme\u002Fsaber-packs`; 27B about 26 GB; Flash-Next about 70 GB, with its 170 GB checkpoint under `models\u002F`) |\n| Weights | the prebuilt packs from `tools\u002Ffetch_packs.sh`: 27B ~26 GB (TP=2) or ~25 GB (`27b-tp1`, one card); Flash-Next ~70 GB of packs plus the original 170 GB checkpoint |\n\nAll builds and GPU runs happen inside the dev container, so the host needs no ROCm toolchain.\n\n## Podman or docker\n\nEvery launcher in `tools\u002F` runs on either. It uses podman when installed, otherwise docker; force\none with `SABER_CONTAINER`:\n\n```bash\nSABER_CONTAINER=docker tools\u002Fserve_27b.sh --no-build\nexport SABER_CONTAINER=docker      # or set it once for the shell\n```\n\n| | podman (rootless) | docker |\n|---|---|---|\n| GPU access | `--device \u002Fdev\u002Fkfd --device \u002Fdev\u002Fdri --group-add keep-groups` | same devices, plus `--group-add \u003Cgid>` for the owners of `\u002Fdev\u002Fkfd` and `\u002Fdev\u002Fdri\u002F*` (usually `video` and `render`) |\n| File ownership | container root maps to you | the launchers pass `--user $(id -u):$(id -g)`, so `.cache\u002F` stays yours |\n| Logs \u002F stop | `podman logs -f saber-27b-serve` | `docker logs -f saber-27b-serve` |\n\nYour user needs read\u002Fwrite on `\u002Fdev\u002Fkfd` and `\u002Fdev\u002Fdri\u002FrenderD*` (`sudo usermod -aG video,render $USER`,\nthen log in again). On an SELinux host the launchers already pass `--security-opt label=disable`.\nThe shim is `tools\u002Flib\u002Fcontainer.sh` (it sets `CTR`, `CTR_GPU` and `CTR_USER`); a new script sources it\nand calls `\"$CTR\" run \"${CTR_GPU[@]}\" ...`.\n\n`tools\u002Fbuild-image.sh` needs nothing but the container runtime and network: it builds\n[`Containerfile.public`](Containerfile.public) on a public ROCm 7.x base\n(`docker.io\u002Frocm\u002Fdev-ubuntu-24.04:7.2.4`; pick another with `SABER_ROCM_IMAGE`) plus Rust and\nbindgen. The image compiles the whole\nworkspace and builds kernels with `hipcc`. It has not yet booted a model; the project's own image\ncarries a newer ROCm (HIP 7.16, ROCr 1.21), and on the public 7.x tags each rank may spin more CPU\nin ROCr's async-event loop.\n\n## Guided setup (terminal UI)\n\n```bash\ntools\u002Fsaber-setup\n```\n\nA text-mode wizard (Python 3 standard library only, no installs) that does the setup for you:\n\n1. **System** checks the GPU driver, that you have two supported GPUs (one for the 27B at TP=1), podman\n   or docker, the dev image, the Hugging Face CLI, and free disk space.\n2. **Configure** picks the model (27B or Flash-Next), the parallelism (TP=2 on two GPUs, or TP=1 on one\n   GPU for the 27B) and shows a checklist of the common options with our recommended defaults already\n   selected: prefix caching, images (vision) off \u002F lazy \u002F on, thinking, max context, concurrent\n   sequences, port, packs directory, and which GPU(s) to use. `d` puts everything back to the defaults.\n3. **Review & run** shows the exact launch command, what is installed and what is missing, and can\n   install the missing pieces (builds the image, downloads the weights, each step asks first), save a\n   re-runnable launch script, start the server, or stop it.\n\nKeys: arrows or `j`\u002F`k` move, Space\u002FEnter change a row, `←`\u002F`→` cycle choices, Tab switches page, `q`\nquits. Settings are saved to `~\u002F.config\u002Fsaber\u002Fsetup.json` and the launch script to\n`~\u002F.config\u002Fsaber\u002Flaunch-\u003Cmodel>.sh`. `tools\u002Fsaber-setup --print` shows the plan without the UI.\n\nParallelism is **TP=2** (both cards) by default, and the wizard lets you choose which two GPUs. For the\n27B you can pick **TP=1** instead: it then asks for ONE GPU, downloads the single-card packs\n(`tools\u002Ffetch_packs.sh 27b-tp1`) and launches `tools\u002Fserve_27b.sh --tp 1` with the TP=1 context and\nsequence defaults (see \"One card (TP=1)\" below; `tools\u002Fsaber-setup --tp 1 --print` shows that plan).\nFlash-Next is TP=2 only (no single-card Flash-Next pack is hosted), and the wizard says so on its TP=1\nrow. The engine refuses any other TP (3, 4, ...) by name: it is built for TP=1 and TP=2. The manual\nsteps below do the same thing without the wizard.\n\n## Get running\n\nSaber runs **two models**, each from prebuilt weight packs hosted on Hugging Face. Pick one (or both;\nonly one server runs at a time, they share the cards).\n\n| | Qwen3.8-27B | Qwen3.8 Flash-Next (MoE) |\n|---|---|---|\n| Download | about 26 GB | about 70 GB of packs **plus the original 170 GB checkpoint** (see below) |\n| Hugging Face | [`Launch80\u002FQwen3.8-27B-NVFP4-SABER`](https:\u002F\u002Fhuggingface.co\u002FLaunch80\u002FQwen3.8-27B-NVFP4-SABER) | [`Launch80\u002FQwen3.8-Flash-Next-SABER`](https:\u002F\u002Fhuggingface.co\u002FLaunch80\u002FQwen3.8-Flash-Next-SABER) + [`amd\u002FQwen3.8-Flash-Next-Quark-MXFP4`](https:\u002F\u002Fhuggingface.co\u002Famd\u002FQwen3.8-Flash-Next-Quark-MXFP4) |\n| Fetch | `tools\u002Ffetch_packs.sh 27b` (two cards, TP=2); `tools\u002Ffetch_packs.sh 27b-tp1` (one card, TP=1, about 25 GB) | `tools\u002Ffetch_packs.sh flashnext` |\n| Serve | `tools\u002Fserve_27b.sh` (two cards); `tools\u002Fserve_27b.sh --tp 1` (one card) | `tools\u002Fserve_flashnext.sh` |\n\n```bash\ngit clone git@github.com:GGZ14\u002Fsaber-engine.git && cd saber-engine\n\n# 1. Build the dev image once (ROCm, Rust, hipcc).\ntools\u002Fbuild-image.sh\n\n# 2. Pull the weights. Downloads resume if interrupted. Packs land in \u002Fmnt\u002Fnvme\u002Fsaber-packs\n#    (override with SABER_PACKS); it also needs `pip install -U 'huggingface_hub[cli]'`.\ntools\u002Ffetch_packs.sh 27b            # or: flashnext   (or: all = 27b + flashnext, both TP=2)\n#    One card? use the TP=1 packs instead:  tools\u002Ffetch_packs.sh 27b-tp1   (see \"One card (TP=1)\" below;\n#    `all` does not include them)\n\n# 3. Serve. Builds the release binary, boots both cards, waits for \u002Fv1\u002Fmodels.\ntools\u002Fserve_27b.sh --enable-prefix-caching on        # or: tools\u002Fserve_flashnext.sh\n#    One card (with the 27b-tp1 packs):  tools\u002Fserve_27b.sh --tp 1 --enable-prefix-caching on\n\n# 4. Talk to it.\ncurl -s localhost:8080\u002Fv1\u002Fchat\u002Fcompletions -H 'content-type: application\u002Fjson' -d '{\n  \"model\": \"Qwen3.8\",\n  \"messages\": [{\"role\": \"user\", \"content\": \"Write a haiku about GPUs.\"}],\n  \"max_tokens\": 128\n}'\n```\n\n(Use model id `Qwen3.8-Flash-Next` for Flash-Next.)\n\n**One card (TP=1).** A pack is cut for one TP degree: its rows and columns are already sharded per\nrank, so the TP=2 packs above (`rank0.pack` + `rank1.pack`) cannot be loaded on one card. The same\nHugging Face repo hosts the single-card packs as separate folders, each with one `rank0.pack`:\n`qwen38-27b-nvfp4-devfinal-tp1-fp8head` (18.5 GB) and `qwen38-dflash2-drafter-tp1-fp8head` (6.4 GB).\n`tools\u002Ffetch_packs.sh 27b-tp1` downloads them into the packs directory (the tokenizer and chat template\nare the same files as TP=2's). Then:\n\n```bash\ntools\u002Fserve_27b.sh --tp 1 --enable-prefix-caching on          # card 0\nDEVICE=1 tools\u002Fserve_27b.sh --tp 1 --no-build                 # or card 1 (container saber-27b-tp1-serve)\n```\n\nOne card holds the 18.5 GB target pack and the 6.4 GB drafter pack, so the KV pool is far smaller than\nTP=2's, and the TP=1 defaults are **`MAX_CTX=65536` per sequence, `MAX_SEQS=4`, decode batches\n`1,2,4`** (draft block 8 and verify widths `1,8` as at TP=2). At those defaults the pool holds 10,548\nblocks = 168,768 tokens, about 2.5 full-length sequences. Measured on one R9700 (card 0 at a 210 W cap;\nROCm 10.1 dev image; the optional 2 GiB P2P pool carved out of the card):\n\n| TP=1, one R9700 | measured |\n|---|---|\n| Single-stream decode, 256 tokens, temperature 0 | 67 tok\u002Fs (prose) \u002F 148 tok\u002Fs (code) \u002F 231 tok\u002Fs (counting): the speculative drafter's acceptance sets the rate (card 1 at a 300 W cap: 68 \u002F 152 \u002F 237) |\n| Max context per sequence | 65,536 by default; 131,072 and 163,840 also boot (a 145k-token prompt answered, prefill ~2,650 tok\u002Fs); 196,608 is refused at boot (one sequence would not fit the pool) |\n| Max sequences | 4 by default; 8 boots and serves (`MAX_SEQS=8 BATCHES=1,2,4,8`: the GDN state doubles, the pool drops to 101,120 tokens) |\n| VRAM | 29.5 GiB used at the served peak (31.5 GiB with the P2P pool), of 32 GiB |\n| Images | `--vision lazy` and `--vision on` both work (`on` keeps the tower resident: the pool drops to 122k tokens, so keep `MAX_CTX` at 65,536 or below and `MAX_SEQS` at 4) |\n\nBoot takes under 10 s with the packs in the page cache. The chat, streaming, 1k- and 2.6k-token prompts\nand a 3-request burst were checked on both cards; no TP=1 BetterBench run, prefill sweep or long soak\nhas been done, and the speculative tree verify form is planned for TP=2 only (a TP=1 boot runs the\nchain form and says so in its log). No single-card Flash-Next pack is hosted.\n\n**What the 27B download contains.** The target pack (`qwen38-27b-nvfp4-devfinal-fp8head`), the DFlash2\ndrafter pack (`qwen38-dflash2-drafter-fp8head`), and the tokenizer and chat template, which\n`fetch_packs.sh` puts in `.cache\u002F`. Nothing else is needed.\n\n**What Flash-Next needs, and why it is bigger.** The Flash-Next pack is not self-contained: for the\nembeddings, norms and router, and for the 102 GB per-layer-embedding (PLE) table, it points into the\noriginal checkpoint's safetensors files and reads them in place. `fetch_packs.sh flashnext` therefore\ndownloads both the pack (`qwen38-flashnext-quark-trunk8`) and the checkpoint. The pack's manifest names\nthe checkpoint by absolute path, so it goes in `\u002Fmnt\u002Fnvme\u002Fmodels\u002FQwen3.8-Flash-Next-Quark-MXFP4`; the\nscript reads the path from the manifest and downloads there. The launcher mounts\n`$SABER_NVME\u002Fmodels` into the container, so keep `SABER_NVME` at its default (`\u002Fmnt\u002Fnvme`) unless you\nalso change that path. The checkpoint is AMD's, under its own license.\n\n**The n-gram (PLE) table.** Flash-Next's per-layer-embedding table is the n-gram lookup behind every\ntoken: 320,001,536 rows of 160 bf16 values (95.4 GiB, 128 shards, tensors named\n`model.language_model.layers.1.ple.ple_embedding.ngram_embedding.shard_N.weight`). It is not a separate\ndownload and not in the pack: it lives inside 33 of the checkpoint's 131 safetensors files, and the\npack's `ple\u002Fple_index.json` maps each row to its file and byte offset. Each token reads 16 rows\n(5,120 bytes) from the drive with `O_DIRECT`, so keep the checkpoint on a fast NVMe, which is where the\ndefault path puts it. The location is fixed in two places, both absolute paths:\n`manifest.json` (`checkpoint.dir`) and `ple\u002Fple_index.json` (`sources.ckpt_bf16.checkpoint`). The\nindex also lists a first-party fp8 copy of the table (half the size), but it is off by default,\ngated on a numerics check, and not part of the hosted files.\n\n## Can I run any MXFP4 model?\n\nNo. There are two separate things in the way, and neither is the quantization format.\n\n1. **Saber does not load checkpoints directly.** It boots from a *pack* (`SBRPACK1`, one\n   4096-byte-aligned file per GPU with a sha256 per record): the weights pre-arranged for its GPU kernels (WMMA fragment\n   order, scales transposed, tensor-parallel split, projections merged, fp8 trunk where used). That is\n   why even a checkpoint that is already MXFP4, like AMD's Flash-Next one, gets packed first. For\n   that checkpoint the packer copies the 4-bit values and scales byte for byte (no requantization); it\n   only rearranges them. The 27B packer starts from an NVFP4, per-channel fp8 or bf16 checkpoint and\n   requantizes it to MXFP4.\n2. **Only two model architectures are implemented:** Qwen3.8-27B (dense, with the DFlash2 drafter) and\n   Qwen3.8 Flash-Next (MoE). The engine, kernels and plans are written for those layer graphs. A different\n   model family (Llama, Mistral, another Qwen) is not a repack: it needs a new model definition in\n   `crates\u002Fsaber-model` and new kernel tuning rules.\n\nSo: for the two supported models, download the prebuilt packs (above). **Pack builders are not part of\nthis release**, so a model we do not host cannot be packed with the tools here yet.\n\nThe server listens on port 8080 and exposes `\u002Fv1\u002Fmodels`, `\u002Fv1\u002Fchat\u002Fcompletions`,\n`\u002Fv1\u002Fcompletions` and `\u002Fmetrics`. Only one server runs at a time; they share the cards.\n\n## Flags and options\n\nBoth launchers take their own flags first, then pass everything else straight to `saber`.\n\n### 27B: `tools\u002Fserve_27b.sh [flags]` (model id `Qwen3.8`)\n\n| Flag | What it does |\n|---|---|\n| `--no-build` | Skip the `cargo build`; reuse `.cache\u002Ftarget-container\u002Frelease\u002Fsaber`. Use this for every boot after the first (a build takes about two minutes). |\n| `--tp 1` | Serve on ONE card (TP=1) from the `-tp1-fp8head` packs (`tools\u002Ffetch_packs.sh 27b-tp1`), on HIP device `DEVICE` (default 0), container `saber-27b-tp1-serve`. `TP=1` in the environment does the same; `--tp 2` (the default) is the two-card server. See \"One card (TP=1)\". |\n| `--vision` | Accept images (`image_url` parts). Same as `--vision lazy`: the vision tower lives in pinned host RAM and streams through the idle prefill arena per image. No VRAM is billed and the full 262k context stays, at about +30 ms per image. |\n| `--vision on` | Keep the tower resident (about 1.9 GiB a rank). Needs `MAX_CTX=131072`. |\n| `--vision off` | Text only (the default). |\n| `--vision-max-patches N` | Largest image, in patches, the resident tower is sized for. |\n| `--enable-prefix-caching on` | Cache finished prompts, so a returning conversation prefills only its new tail. Default `off`. |\n| `--warm-prompts FILE` | Prefill the system prompt(s) in `FILE` at boot and report ready only when done. Turns prefix caching on. |\n| `--tool-call-parser NAME` \u002F `--reasoning-parser NAME` | Tool-call and reasoning-block parsing. Default `qwen3_coder` and `qwen3`. |\n| `stop` | Stop the server container: whichever 27B server (TP=2 or TP=1) is running. `--tp 1 stop` stops only the TP=1 one. |\n\nEnvironment variables (put them before the command):\n\n| Variable | Default | Meaning |\n|---|---|---|\n| `PORT` | `8080` | Listen port |\n| `MAX_CTX` | `262144` (TP=1: `65536`) | Context per sequence; lower it for more concurrent sessions or `--vision on` |\n| `MAX_SEQS` | `8` (TP=1: `4`) | Concurrent sequences |\n| `BATCHES` | `1,2,3,4,8` (TP=1: `1,2,4`) | Captured decode batch sizes |\n| `DEVICE` | `0` | TP=1 only: the one HIP device to serve on (the container sees only that card) |\n| `HIP_DEVICES` | `0,1` | TP=2 only: the two HIP devices |\n| `WIDTHS` | `1,8` | Speculative verify widths |\n| `DRAFT_BLOCK` | `8` | Drafter block size (`4` halves the GDN slots) |\n| `MODEL` | `Qwen3.8` | Served model id |\n| `SABER_PACKS` | `\u002Fmnt\u002Fnvme\u002Fsaber-packs` | Where the weight packs live |\n| `SABER_SHARED` | `~\u002Fsaber-cache` | Scratch and logs shared between runs |\n| `SABER_IMAGE` | `localhost\u002Fsaber-dev:latest` | The dev image |\n| `SABER_CONTAINER` | autodetect | `podman` or `docker` |\n| `CNAME` | `saber-27b-serve` (TP=1: `saber-27b-tp1-serve`) | Container name |\n\n### Flash-Next: `tools\u002Fserve_flashnext.sh [flags]` (model id `Qwen3.8-Flash-Next`)\n\n| Flag | What it does |\n|---|---|\n| `--no-build` | Reuse the last release build, as above. |\n| `--fn-vision [lazy\\|on\\|off]` | Images. `lazy` (the default boot) loads the tower on the first image request and unloads it after 300 s idle. `off` is text only. Image prompts are prefix-cached by content hash (`--fn-image-cache`, on by default), and oversized images are downscaled, not refused. |\n| `--fn-thinking off` | Do not think by default (a request can still set `enable_thinking`). Default `on`. |\n| `--fn-max-ctx N` | Context limit; the default boot serves 262,144. |\n| `--fn-prefix-tree off` | Disable the tiered prefix cache (on by default). |\n| `--warm-prompts FILE` | As above. |\n| `--record-routes` | Record expert routes from your traffic under `$SABER_NVME\u002Fsaber-kv\u002Froutes\u002F` (see the script header for the rebuild step). |\n| `stop` | Stop the server container. |\n\n| Variable | Default | Meaning |\n|---|---|---|\n| `PORT` | `8080` | Listen port |\n| `SABER_NVME` | `\u002Fmnt\u002Fnvme` | Parent of `models\u002F`, `saber-packs\u002F`, `saber-kv\u002F` |\n| `PACK` | `$SABER_NVME\u002Fsaber-packs\u002Fqwen38-flashnext-quark-trunk8` | Weight pack |\n| `FN_TRUNK` | `w8-hc8-head` | `w8`, `w8-hc8` or `bf16` select slower, higher-precision trunks |\n| `FN_KV` | `fp8` | `bf16` for a bf16 KV cache |\n| `FN_EXPERTS` | `tp2` | `ep` for expert parallelism |\n| `FN_AGENT_DEFAULTS` | `1` | `0` drops the agent-load tuning flags (lazy KV, bigger prefix tree, prefill yield) |\n| `GPU_MAX_HW_QUEUES` | `3` | ROCm hardware queues per process |\n\nEvery other `saber engine` flag goes after the launcher's own; `saber engine --help` lists them.\n\n### Images\n\n```bash\ntools\u002Fserve_27b.sh --no-build --vision          # or: tools\u002Fserve_flashnext.sh --no-build\n```\n\n```bash\nIMG=$(base64 -w0 photo.jpg)\ncurl -s localhost:8080\u002Fv1\u002Fchat\u002Fcompletions -H 'content-type: application\u002Fjson' -d '{\n  \"model\": \"Qwen3.8\",\n  \"messages\": [{\"role\": \"user\", \"content\": [\n    {\"type\": \"text\", \"text\": \"What is in this picture?\"},\n    {\"type\": \"image_url\", \"image_url\": {\"url\": \"data:image\u002Fjpeg;base64,'\"$IMG\"'\"}}\n  ]}],\n  \"max_tokens\": 200\n}'\n```\n\nWithout a vision flag the 27B refuses an image part by name.\n\n### Everyday commands\n\n| Task | Command |\n|---|---|\n| Stop the server | `tools\u002Fserve_27b.sh stop` |\n| Reuse the last build | `tools\u002Fserve_27b.sh --no-build` |\n| Another port | `PORT=8100 tools\u002Fserve_27b.sh ...` |\n| Smaller context | `MAX_CTX=65536 tools\u002Fserve_27b.sh ...` |\n| One card | `tools\u002Fserve_27b.sh --tp 1` (card 1: `DEVICE=1 tools\u002Fserve_27b.sh --tp 1`) |\n| Logs | `podman logs -f saber-27b-serve` (or `docker logs -f ...`) |\n| Exit code of a dead server | `podman wait saber-27b-serve` |\n| Flash-Next | `tools\u002Fserve_flashnext.sh` |\n\n### Troubleshooting\n\n| You see | Cause |\n|---|---|\n| `missing pack ...` \u002F `missing .cache\u002Ftemplate_corpus...` | A step in \"Get running\" was skipped; the message names the file. |\n| `port 8080 is already in use` | Another server is up; stop it or set `PORT`. |\n| `another saber server or an agent hold holds the cards` | A `saber-*` container is running; `ps` it and stop it. |\n| `container ... holds HIP device N` (TP=1) | A running `saber-*` container already uses that card; stop it or pick another `DEVICE`. |\n| `... is a TP=2 pack (it has rank1.pack)` | TP=1 needs the single-card packs: `tools\u002Ffetch_packs.sh 27b-tp1`. |\n| Exit code **86**, last log line `saber: FATAL rank R: \u003Creason>` | A rank failed. The server exits, answers queued requests 503 and frees both cards within 10 s. |\n| `permission denied` on `\u002Fdev\u002Fkfd` | Add yourself to `video` and `render`, log in again. Under docker, check the printed `--group-add` gids. |\n| `neither podman nor docker is installed` | Install one, or set `SABER_CONTAINER`. |\n\n## Optional: SSD to VRAM peer-to-peer\n\nStock `amdgpu` cannot be the target of an NVMe read, so everything loaded from the drive\nreaches VRAM through host RAM and costs host memory bandwidth twice. `tools\u002Fkernel\u002Ffn71\u002F`\ncarries a patch that adds `amdgpu.p2pmem_mb=N`: N MiB of each card's VRAM is registered at boot\nas a PCI P2PDMA pool, so the drive writes it directly and the GPU reads the same bytes.\nMeasured on the R9700s: 9.5 to 10.7 GB\u002Fs drive to VRAM, byte-equal, with host memory bandwidth\nuntouched (a CPU stream keeps 51.7 of 52 GB\u002Fs, against 32.4 beside the bounce copy).\n\n- It needs a custom kernel build (`CONFIG_PCI_P2PDMA`, tested on 7.1.3) and a reboot:\n  `sudo FN71_P2PMEM_MB=2048 bash tools\u002Fkernel\u002Ffn71\u002Finstall.sh`. To turn it off, boot with\n  `amdgpu.p2pmem_mb=0`.\n- Cost: the pool is carved out of VRAM (2 GiB a card at 2048). Both servers subtract it from their\n  budgets on their own.\n- Nothing requires it. `saber_hsa::NvmeVram` uses the pool route when it exists and falls back to\n  the bounce copy otherwise. It speeds up loads and reloads; the decode step path does not read\n  from the drive.\n\n## Develop\n\n```bash\ntools\u002Fdev.sh cargo test -p saber-plan        # any crate, inside the dev image\ntools\u002Fdev.sh cargo build --release -p saber-cli\ncargo fmt --all --check && cargo clippy --workspace --all-targets -- -D warnings\n```\n\n`tools\u002Fdev.sh` and `tools\u002Fhipcc.sh` use podman or docker like the launchers. Host `cargo` is fine for pure-Rust unit tests; anything that touches HIP or a GPU goes through\n`tools\u002Fdev.sh`. Compile a kernel with `tools\u002Fhipcc.sh crates\u002Fsaber-kernels\u002Fhip\u002F\u003Ck>.hip out.hsaco`.\n`saber --help` lists the CLI: `serve`, `engine` (one-prompt gate with ms\u002Fstep), `probe`, `gate`,\n`explain` and the per-feature gates.\n\n## Reproducing the code objects\n\n`prebuilt\u002Fgfx1201\u002F` holds 116 compiled GPU code objects. Each has a manifest next to it recording the\nsource file, its sha256, the compiler flags, a build hash (sha256 of the preprocessed source plus\nflags) and the object's own sha256. The sources are in `crates\u002Fsaber-kernels\u002Fhip`.\n\n**Two ROCm toolchains built them**, both AMD \"TheRock\" builds. Each object records its compiler in\nthe file; `tools\u002Fverify_prebuilt.py --table` lists it per object.\n\n| Objects | ROCm | TheRock commit | LLVM (`ROCm\u002Fllvm-project`) | Patches on LLVM |\n|---|---|---|---|---|\n| 64 | 10.1.0rc3 (HIP 7.16.26385) | `b324869fb311` | `d6f6cb69` (clang 24.0.0git) | none |\n| 52 | 7.14.0rc3 (HIP 7.14.60850) | `418cd5f63abb` | `46fcb339` (clang 23.0.0git) | 2 TheRock patches, both `hipcc` driver path handling (Windows include path, `HIP_PATH` precedence); the clang string carries `+PATCHED:` for them |\n\nSaber applies no patches to LLVM. The container image from `tools\u002Fbuild-image.sh` uses the public\nROCm 7.2.4 image, whose compiler (clang 22) emits different code, so it will not reproduce these\nobjects. To check them you need the matching toolchain:\n\n```bash\n# rebuild with a toolchain that has the right ROCm (SABER_IMAGE names the image tools\u002Fhipcc.sh uses)\nSABER_IMAGE=\u003Cimage with that ROCm> cargo run -p saber-kernels --bin saber-kbuild -- --out \u002Fabs\u002Fpath\u002Finside\u002Frepo\u002Frebuilt\ntools\u002Fverify_prebuilt.py --rebuilt \u002Fabs\u002Fpath\u002Finside\u002Frepo\u002Frebuilt\n```\n\n**Compare the machine code, not the files.** Two builds of one source with one compiler differ in\nthe dynamic symbol-table sections, so file hashes never match. `verify_prebuilt.py` compares `.text`,\n`.rodata` and the register limits, and only against a rebuild by the same compiler. When we ran it,\nevery shipped object matched: 64 of 64 on ROCm 10.1 and 52 of 52 on ROCm 7.14, none different.\n\nThe MXFP4 GEMM sources were derived from `tools\u002Freference\u002Fref_mxfp4_fp8.hip` by\n`tools\u002Fgen_hip_sources.py`. The committed `.hip` files are the inputs that were compiled, not the\ngenerator output: they have been renamed since, and the generator no longer reproduces every file\n(its header says which). Its reference differs from the one the file headers record by one comment and an identifier-prefix rename (the generator was renamed to match).\n\n## Layout\n\n| Path | What |\n|---|---|\n| `crates\u002Fsaber-cli` | the `saber` binary |\n| `crates\u002Fsaber-engine`, `-exec`, `-plan`, `-sched` | engine, execution graphs, launch plan, scheduler |\n| `crates\u002Fsaber-serve` | the OpenAI HTTP plane |\n| `crates\u002Fsaber-kernels`, `prebuilt\u002Fgfx1201` | HIP kernel sources and their compiled code objects with manifests |\n| `crates\u002Fsaber-mem`, `-model` | weight packs and the model graph |\n| `tools\u002F` | launchers, the setup wizard, kernel generators and their MXFP4 reference, `verify_prebuilt.py`, the optional kernel patch |\n\n## License\n\nSaber is licensed under the [Apache License 2.0](LICENSE). Copyright 2026 GGZ14. If you redistribute it\nor a fork, keep the [`LICENSE`](LICENSE) and [`NOTICE`](NOTICE) files with it: the Apache License\nrequires the `NOTICE` attribution to be carried into your distribution.\n\nTwo things in this repository are not covered by that license. `tools\u002Fkernel\u002Ffn71\u002F` holds a patch to the\nLinux kernel, which is under the kernel's own license (GPL-2.0). The model weights the launchers download\n(Qwen3.8 and AMD's Flash-Next checkpoint) keep their own licenses.\n","Saber 是一个专为 AMD Radeon AI PRO R9700（gfx1201 \u002F RDNA4）GPU 优化的 Rust 编写推理引擎，支持 Qwen3.8-27B 及 Flash-Next（MoE）模型的高效部署。核心特点包括：基于 HIP 的定制化算子内核、显式控制的张量并行调度、OpenAI 兼容 API 服务接口、支持前缀缓存与可选多模态（vision）能力，并通过容器化（Podman\u002FDocker）实现开箱即用的 ROCm 运行时隔离。适用于在 AMD AI 加速卡上部署大语言模型的生产级推理场景，尤其适合对低延迟（TTFT ~47ms）、高吞吐（5000+ tok\u002Fs 预填充）和长上下文（262k tokens）有要求的本地或私有云 AI 服务。","2026-11-24 04:38:49","CREATED_QUERY"]