Files
strata/docs/GYRO.md
T
Laurent Zuijdwijk 390da5d905 Trellis numerics: say which codebook each path reads and what is bitwise
Decode reads the int8 codebook tq_lut_i8 (one global scale, 0.85% relative
RMS); the FP16 prompt path reads the fp16 codebook and the MMQ path is the
GGML fork's tile loader. The comment over tq_load / tq_apply now says that
only the decode-once and per-entry kernels are bitwise equal to each other,
and that native_expert_parity bounds the decode path against ggml's float
dequantizer at relative L1 error < 3e-2 (the prompt dequantizers at < 1e-6).
The same goes into a short "Numerics" section of docs/GYRO.md and the parity
test's header.

Ported from agentionai/Strata rc2 457047e (rc2 = 9ff02c9), author Laurent Zuijdwijk.
2026-10-15 21:31:20 +02:00

9.7 KiB
Raw Blame History

Gyro (agentionai rotor quants) on Strata

Validated on Linux with an RTX 5090 (32 GB, CUDA 13.0, sm_120; 2026-10-02 and 2026-10-03), an RTX 3090 (24 GB, sm_86; 2026-10-03) and two RTX 4090s (24 GB each, sm_89; 2026-10-04, single and dual GPU). A short end-to-end run on AMD (Strix Halo, gfx1151, ROCm) passed on 2026-10-03.

The targets are the published files of agentionai/Qwen3.8-Flash-Next-Gyro-GGUF, used unchanged:

File Experts GPU memory for the experts Status
Qwen3.8-Flash-Next-Gyro-S-TQ1_0.gguf (58.5 GB) TQK6 gate/up, TQK7 down, block-128 Hadamard 24.0 GiB validated end to end (RTX 5090, RTX 3090)
Qwen3.8-Flash-Next-Gyro-M-TQ2_0.gguf (92.0 GB) TQ2_T, block-128 Hadamard 29.9 GiB validated end to end (RTX 5090, RTX 3090); the experts do not all fit a 32 GB card, auto streams the rest

Both files carry their own experts in the trellis types TQ2_T/TQK6/TQK7 and record the activation rotation in prism.hadamard.* metadata. Strata reads both natively. About half of each file is the n-gram (PLE) table, which stays on disk and is read row by row; it is not loaded into RAM or VRAM.

The draft head is Strata's own MTP runtime, prepared from the original model's MTP weights as for the other Qwen3.8-Flash-Next models. It is not the GGUF draft file from the Gyro repository.

Quick setup

From a Strata checkout:

tools/gyro_setup.sh does every step below on Linux:

tools/gyro_setup.sh --model S --backend cuda --cuda-arch 120       # RTX 50 series
tools/gyro_setup.sh --model S --backend cuda --cuda-arch 89        # RTX 40 series
tools/gyro_setup.sh --model S --backend cuda --cuda-arch 86        # RTX 30 series / RTX A6000
tools/gyro_setup.sh --model S --backend hip  --hip-arch gfx1201    # Radeon RX 9070 / AI PRO R9700 (experimental)

It prints the command that starts the server. The steps, by hand:

1. Build

Strata's GGML dependency must be the agentionai llama.cpp fork, which has the trellis types:

git clone --depth 1 https://github.com/agentionai/llama.cpp ../agention-llama.cpp
# NVIDIA. RTX 50 series: use CUDA 13 (CUDA 12.8 crashes the prompt path on sm_120: issues #220, #224)
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DSTRATA_ENABLE_CUDA=ON \
  -DCMAKE_CUDA_ARCHITECTURES=120 -DSTRATA_GGML_DIR=$PWD/../agention-llama.cpp
# AMD (experimental: kernel parity and an end-to-end run validated on gfx1151; in a non-root container add
# --group-add $(getent group render | cut -d: -f3), otherwise HIP finds no device)
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DSTRATA_ENABLE_HIP=ON -DSTRATA_PREFILL_MMQ=ON \
  -DCMAKE_HIP_ARCHITECTURES=gfx1201 -DSTRATA_GGML_DIR=$PWD/../agention-llama.cpp
cmake --build build -j
python3 -m venv .venv && .venv/bin/pip install -r requirements.txt

2. Download and pack

.venv/bin/pip install huggingface_hub hf_transfer
HF_HUB_ENABLE_HF_TRANSFER=1 .venv/bin/hf download agentionai/Qwen3.8-Flash-Next-Gyro-GGUF \
  Qwen3.8-Flash-Next-Gyro-S-TQ1_0.gguf --local-dir models
STRATA_GGUF_PY=../agention-llama.cpp/gguf-py .venv/bin/python tools/iq_pack.py \
  --gguf models/Qwen3.8-Flash-Next-Gyro-S-TQ1_0.gguf --out packs/gyro-s --compat-bf16
build/native_expert_parity --load-check packs/gyro-s models/Qwen3.8-Flash-Next-Gyro-S-TQ1_0.gguf

The pack is 1.5 GB (dense weights, tokenizer, the Hadamard and expert tables); the experts are read from the GGUF. Keep the GGUF on a fast local SSD: the n-gram table is read from it for every token. --load-check must end with 0 failures.

3. Draft head

.venv/bin/python tools/mtp_fetch.py fetch --out mtp
.venv/bin/python tools/mtp_pack.py --src mtp --experts q2_0 --out mtp/mtp-q2_0.gguf
.venv/bin/python tools/mtp_rt.py --gguf mtp/mtp-q2_0.gguf --out mtp/rt
cp data/draft_vocab.bin mtp/rt/draft_vocab.bin

4. Serve

Save as strata-gyro-s.json at the repository root:

{
  "exe": "build/strata",
  "args": [
    "--pack", "packs/gyro-s",
    "--native", "models/Qwen3.8-Flash-Next-Gyro-S-TQ1_0.gguf",
    "--expert-profile", "data/expert-profile.bin", "--expert-cache", "auto",
    "--prefill", "auto", "--spec", "4", "--spec-min-p", "0.5",
    "--mtp", "mtp/rt", "--max-context", "131072", "--kv", "int8"
  ],
  "cwd": ".",
  "tokenizer": "packs/gyro-s/tokenizer",
  "model_name": "gyro-s-strata",
  "log": "strata-gyro-s.log",
  "host": "127.0.0.1",
  "port": 8080
}
.venv/bin/python -m serve.server --engine strata --config strata-gyro-s.json --port 8080

The web interface is at http://127.0.0.1:8080; API clients use http://127.0.0.1:8080/v1 (OpenAI) or /v1/messages (Anthropic). --expert-cache auto sizes the expert cache to the free VRAM: on a 32 GB card at 128k context it holds 23,464 of 24,576 experts (22.9 GiB). On smaller cards it holds fewer and streams the rest from RAM; nothing else changes.

Measured

All runs: greedy or the stated sampling, same prompt tokens as llama.cpp, MTP draft --spec 4 --spec-min-p 0.5, int8 KV. "llama.cpp" is the agentionai fork with the CUDA trellis fixes (in its main since 2026-10-04).

RTX 5090 (32 GB), Gyro-S, all experts on the GPU (2026-10-03)

Decode tokens/s, single prompts of 34-177 tokens, 384 new tokens, --max-context 16384 (all 24,576 experts cached):

prose JSON code
Strata 139.9 221.3 209.0

Server, tools/gyro_setup.sh config (128k context, 23,463 experts cached), thinking off, temperature 0.7, top-k 20, top-p 0.95, min-p 0.05, 512 new tokens, 3 repetitions:

prose JSON code copy
Strata 131.7 200.1 195.2 201.8
llama.cpp, MTP draft 116.8 213.0 179.0 220.7
llama.cpp, no draft 121.8 123.2 122.5 121.2

Long real-text prompts, prefill tokens/s: 4k tokens 3,456 (llama.cpp 2,520), 16k tokens 4,883 (llama.cpp 2,471).

RTX 5090, Gyro-M (2026-10-03)

The experts (29.9 GiB) do not all fit next to the KV cache; auto caches 18,007 of 24,576. Same server protocol: prose 113.8, JSON 170.8, code 153.0, copy 175.7 tokens/s; prefill 4k 3,369, 16k 4,854 tokens/s. llama.cpp needs -ncmoe 8 for this file on a 32 GB card and decodes at 70.8 tokens/s without a draft.

RTX 3090 (24 GB), 2026-10-03

Same server protocol, 128k context, auto cache:

experts cached prose JSON code copy prefill 4k prefill 16k
Gyro-S 15,756 31.8 45.2 42.2 45.1 1,402 1,863
Gyro-M 11,811 27.8 39.4 34.4 37.7 1,363 1,910
llama.cpp, Gyro-S, -ncmoe 10, 32k context, no draft (10 layers on the CPU) 16.0 16.2 16.2 16.5 468 (-ncmoe 11) 479

On a 24 GB card, cache misses run on the CPU, so the CPU matters: this box had a Zen 2 EPYC (AVX2, no AVX-512). The llama.cpp row is the build before the CUDA trellis fixes; those added about 3 % at 24 GB, where the CPU layers dominate.

Smaller caches (RTX 5090, 2026-10-02, before the int8 decode kernels)

Expert cache prose JSON code
24,576 slots (all experts) 116.4 194.3 173.5
22,000 slots 111.4 175.7 166.1
9,000 slots (about a 16 GB card's room) 81.4 74.0 96.8
3,000 slots (about an 8 GB card's room) 48.0 52.4 57.9

The smaller caches were emulated on the 5090 (fast GPU, PCIe 5.0 x16 at ~51 GB/s). A real 8 or 16 GB card is a slower GPU, often on a slower link: read those rows as "it stays usable", not as a prediction for a specific card. The decoded output was read and is fluent and correct; token-level parity against llama.cpp has not been checked. A real chat at 128k context worked through the web interface.

Two GPUs (2026-10-04, 2× RTX 4090, no NVLink/P2P)

  • Layer split (Strata splits the layers across both cards automatically) works with Gyro, including the idle-card prompt helper (STRATA_PREFILL_HELP=1). Repeated runs give identical output.
  • Decode with a second card (--peer-device 1 or --expert-cache-device1 auto) works and matches single-GPU output.
  • Prompt processing on the peer card needs GPU-to-GPU access (NVLink or data-centre GPUs); without it Strata keeps the prompt on the first GPU and logs no P2P.

Single RTX 4090 smoke run (Gyro-S, MTP draft, greedy): code 107.5, prose 84.3, JSON 76.3 tokens/s.

Numerics

  • Decode (Strata's own expert kernels) reads the trellis weights through an int8 copy of the codebook with one global scale (tq_lut_i8, relative RMS error 0.85 % of the codebook's standard deviation, far below the quantization error itself), against q8_1 activations.
  • Prompt processing decodes them otherwise: the FP16 path through the fp16 codebook (tq_lut_f16, what GGML's own dequantizer reads); the MMQ path through the llama.cpp fork's kernels, which read the int8 codebook as well on the fork's current main.
  • So decode and prompt results agree within tolerance, not bit for bit. native_expert_parity checks one expert on the decode kernels against GGML's float dequantizer and a float SwiGLU: relative L1 error below 3e-2, the bound every expert type gets there. Its "bitwise equal" lines compare Strata's decode-once and per-entry decode kernels with each other, not with a float reference.

Known limits

  • Not measured yet: token parity against llama.cpp.
  • Benchmark mode only: strata --tokens-file ... --max-new N decodes N tokens past the end of the answer; compare speeds only up to the answer's end.
  • AMD: the trellis kernels pass parity on gfx1151 (ROCm 7.2.1) and a short end-to-end run there generated correctly (~28-31 tokens/s); no speed tuning or RDNA4 run yet.
  • Gyro-M: 29.9 GiB of experts do not all fit a 32 GB card next to the KV cache; auto streams the rest.
  • Not validated end to end yet (Strata runs them and logs a warning): an AMD GPU other than gfx1151, and prompt processing on a peer GPU over P2P.