feat: replace llama.cpp Tiel-Coder with FreeToken v0.1.2 serving Qwen3.6-35B-A3B-FP8

Replace the llama.cpp Tiel-Coder-35B-A3B (UD-Q6_K_XL) deployment with
FreeToken v0.1.2 — an edge-native MoE serving engine that keeps expert
weights in host RAM with an LRU GPU cache and paged KV with radix prefix
sharing.

Model: Qwen/Qwen3.6-35B-A3B-FP8 (modelopt block-fp8, 128×128 weight_block_size).
Architecture: qwen3_5_moe — 40 layers (10 attention + 30 GDN), 256 experts/8 used.

Production config:
- 2048 MoE cache slots (20% of 10240 expert instances, ~6.0 GiB VRAM)
- 453005 KV tokens (~8.6 GiB, ~20 KiB/token for 10 attn layers)
- 4 max-running-requests (mamba slot pool: 24 slots)
- bs4 decode: ~87 tok/s aggregate, ~30 tok/s bs1
- Prefill: ~1,130 tok/s at 4k prompt

Quirk: FreeToken v0.1.2 supports modelopt block-fp8, NVFP4, and per-tensor
FP8, but NOT compressed-tensors per-channel FP8 (Huihui/Ornith both failed).
Live KV resize via ft ctl cache grows KV by shrinking MoE; reverse needs restart.

Old llama.cpp scripts archived to .AGENTTRASH/.
Full benchmark sweep (bs1/bs3/bs4/bs6, 8k–700k KV) documented in
docs/LLM/freetoken-benchmark-sweep.md.
This commit is contained in:
Frank
2026-08-27 02:01:16 -07:00
parent e219fdf939
commit 6efb0fb231
14 changed files with 494 additions and 470 deletions
+37 -57
View File
@@ -1,71 +1,51 @@
# Tunables for frank-default-small (Tiel-Coder-35B-A3B UD-Q6_K_XL,
# qwen35moe hybrid MoE, Dankserver, RTX 3090).
# Tunables for frank-default-small (Qwen3.6-35B-A3B-FP8,
# qwen3_5_moe hybrid MoE, Dankserver, RTX 3090).
#
# Runtime: upstream llama.cpp (latest master, CUDA build with
# -DGGML_CUDA_FA_ALL_QUANTS=ON -DCMAKE_CUDA_ARCHITECTURES=86) on RTX 3090
# 24 GB; Ryzen 7 7700X; 62 GB RAM. Replaced the ik_llama.cpp Ornith
# CRACK Q8_0 deployment on 2026-09-01.
# Runtime: FreeToken v0.1.2 (edge-native MoE serving engine).
# Installed via uv into /home/dank/freetoken/.venv (CPython 3.12).
# FreeToken keeps expert weights in host RAM with an LRU GPU cache;
# KV is paged with radix prefix sharing. Only the 10 full-attention
# layers page KV (~20 KiB/token); the 30 GDN layers use constant-size
# per-sequence state (mamba slot pool).
#
# Model: peculiar-ragdoll/Tiel-Coder-35B-A3B-GGUF, UD-Q6_K_XL quant
# (30 GB). Architecture: qwen35moe — 40 layers, full_attention_interval=4
# (10 attention + 30 SSM/Mamba), 256 experts / 8 used, 2 KV heads × 256
# dim, embedding 2048, rope dimension_count 64, rope freq_base 10 000 000.
# Text-only (no mmproj). Built-in chat template in the GGUF.
# Model: Qwen/Qwen3.6-35B-A3B-FP8 (HuggingFace safetensors, modelopt
# block-fp8 quant, 128x128 weight_block_size, 35 GB on disk).
# Architecture: qwen3_5_moe — 40 layers (10 attention + 30 GDN),
# 256 experts / 8 used, 2 KV heads × 256 dim, full_attention_interval=4.
#
# Expert offload: --cpu-moe keeps all 256 expert weights in CPU RAM.
# Non-expert weights (~1.6 GB) fit entirely on the 24 GB card.
# Replaced the llama.cpp Tiel-Coder-35B-A3B (UD-Q6_K_XL) deployment on
# 2026-09-02. The old serve script and env are in .AGENTTRASH/.
#
# KV cache: Q8_0 for both K and V. With CTX_SIZE=200700 (66 900 per slot
# × 3 parallel) and 10 attention layers, the KV cache is ~2 GB — the
# requested 2 GB VRAM buffer.
# Pool sizing: GPU budget (~17.6 GiB after weights + fixed caches) is
# split MoE-first. MOE_CACHE_SIZE pins resident expert slots; NUM_TOKENS
# pins the KV pool. At 2048 slots / 453005 tokens the split is ~20%
# residency (2048/10240) and ~8.6 GiB KV. Live resize via
# `ft ctl cache --kv N --moe M` can grow KV by shrinking MoE without
# restart (the reverse requires a restart).
#
# WARNING: do not name any variable TEMP, HOST, or GPU_MAX_HEAP_SIZE. The
# ROCm HIP runtime reads those bare env vars (see the 2026-08-13 TEMP
# incident). This box is NVIDIA/CUDA, but the rule keeps the env portable.
# WARNING: do not name any variable TEMP, HOST, or GPU_MAX_HEAP_SIZE.
# The ROCm HIP runtime reads those bare env vars (see the 2026-08-13 TEMP
# incident). This box is NVIDIA/CUDA, but the rule keeps the env portable.
# Model file (UD-Q6_K_XL, 30 GB, text-only MoE hybrid).
MODEL_DIR=/home/dank/models/tiel-coder-35b
MODEL_FILE=Tiel-Coder-35B-A3B-UD-Q6_K_XL.gguf
# Model directory (safetensors checkpoint, 35 GB).
MODEL_DIR=/home/dank/models/qwen36-35b-a3b-fp8
# Upstream llama.cpp llama-server (CUDA build, latest master).
# Built with -DGGML_CUDA_FA_ALL_QUANTS=ON -DCMAKE_CUDA_ARCHITECTURES=86
# using the staged CUDA 13.2 toolkit at /home/dank/cuda13-stage.
LLAMA_SERVER=/home/dank/llama.cpp/build/bin/llama-server
# FreeToken venv (uv-managed CPython 3.12, ft CLI, flashinfer, torch+cu130).
FT_VENV=/home/dank/freetoken/.venv
CUDA_HOME_DIR=/home/dank/freetoken/.venv/lib/python3.12/site-packages/nvidia/cu13
ALIAS=frank-default-small
BIND_ADDR=0.0.0.0
LISTEN_PORT=7770
# Total context budget across all parallel slots. 200700 / 3 = 66 900
# per slot. The model's context_length is 262 144, so 66 900 is well
# within range.
CTX_SIZE=200700
PARALLEL=3
# Expert residency: 2048 of 10240 total expert instances (20%).
# Each slot ~3 MiB → ~6.0 GiB VRAM for the MoE cache.
MOE_CACHE_SIZE=2048
# Expert offload: all MoE expert weights pinned to CPU RAM.
CPU_MOE=1
# KV pool: 453005 tokens (~8.6 GiB at ~20 KiB/token).
# Covers 4 concurrent sessions at ~113k unique context each
# (more with radix prefix sharing for common prefixes).
NUM_TOKENS=453005
# All non-expert layers on GPU (auto-fit will determine the exact count;
# with --cpu-moe the non-expert footprint is ~1.6 GB, leaving ample room).
N_GPU_LAYERS=999
# KV cache: Q8_0 for both K and V. ~2 GB total for 200700 ctx × 3 slots
# × 10 attention layers × (2 KV heads × 256 dim × 1 byte) × 2 (K+V).
CACHE_TYPE_K=q8_0
CACHE_TYPE_V=q8_0
VERBOSITY=2
# Prefill batch sizing.
BATCH_SIZE=4096
UBATCH_SIZE=1024
# Sampling.
TEMPERATURE=1.0
TOP_K=20
TOP_P=0.95
MIN_P=0.0
# Compute threads lowered so other processes keep a core.
THREADS=7
THREADS_HTTP=8
# Max concurrent decoding requests (also caps mamba slot allocation).
MAX_RUNNING_REQUESTS=4
+2 -2
View File
@@ -1,5 +1,5 @@
[Unit]
Description=llama.cpp Tiel-Coder-35B-A3B Q6_K_XL qwen35moe hybrid MoE (dankserver, frank-default-small)
Description=FreeToken Qwen3.6-35B-A3B-FP8 qwen3_5_moe hybrid MoE (dankserver, frank-default-small)
After=network-online.target
Wants=network-online.target
@@ -13,4 +13,4 @@ Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
WantedBy=multi-user.target
+42 -56
View File
@@ -1,23 +1,25 @@
#!/usr/bin/env bash
# Serve peculiar-ragdoll/Tiel-Coder-35B-A3B (UD-Q6_K_XL) as
# frank-default-small via stock llama.cpp on Dankserver (RTX 3090).
# Serve Qwen/Qwen3.6-35B-A3B-FP8 as frank-default-small via FreeToken
# on Dankserver (RTX 3090, 60 GB RAM).
#
# Runtime: upstream llama.cpp (latest master, CUDA build with
# -DGGML_CUDA_FA_ALL_QUANTS=ON -DCMAKE_CUDA_ARCHITECTURES=86).
# The model is a 35B-total / 8-active MoE hybrid (qwen35moe arch) with
# SSM/Mamba layers (full_attention_interval=4: 10 attention + 30 SSM
# layers out of 40). 256 experts, 8 used per token.
# Runtime: FreeToken v0.1.2 (edge-native MoE serving engine).
# - Experts live in host RAM; an LRU cache of expert slots is resident
# on the GPU. Misses are streamed over PCIe.
# - Paged KV cache (radix prefix sharing). Only the 10 full-attention
# layers page KV (~20 KiB/token); the 30 GDN/linear-attention layers
# hold constant-size per-sequence state (mamba slots).
# - OpenAI-compatible API (/v1/chat/completions, /v1/models).
#
# Expert offload: --cpu-moe keeps all 256 expert weights in CPU RAM.
# Non-expert weights (attention, SSM, shared expert, embeddings, output)
# are ~1.6 GB and fit entirely on the 24 GB RTX 3090.
# Model: Qwen/Qwen3.6-35B-A3B-FP8 (safetensors, modelopt block-fp8,
# 128x128 weight_block_size). Architecture: qwen3_5_moe — 40 layers,
# full_attention_interval=4 (10 attention + 30 GDN), 256 experts / 8 used,
# 2 KV heads × 256 dim. 35 GB on disk.
#
# KV cache: Q8_0 for both K and V. With CTX_SIZE=200700 (66 900 per
# slot × 3 parallel) and 10 attention layers (2 KV heads × 256 dim),
# the KV cache is ~2 GB — the requested 2 GB VRAM buffer.
#
# Model is loaded with mmap (default). The 30 GB Q6_K_XL file is
# memory-mapped; only accessed pages enter RAM.
# Pool sizing: the GPU budget is split MoE-first between expert residency
# and KV pages. --moe-cache-size pins the number of resident expert
# slots; --num-tokens pins the KV pool capacity. Live resize is possible
# via `ft ctl cache --kv N --moe M` (grows KV by shrinking MoE; shrinking
# KV requires a restart due to the swap-during-rebuild memory cost).
#
# Tunables come from frank-default-small.env unless FRANK_SMALL_ENV_FILE
# overrides that path.
@@ -33,55 +35,39 @@ if [[ -f "$ENV_FILE" ]]; then
fi
# --- defaults (used when the env file does not set them) -----------------
: "${MODEL_DIR:=/home/dank/models/tiel-coder-35b}"
: "${MODEL_FILE:=Tiel-Coder-35B-A3B-UD-Q6_K_XL.gguf}"
: "${LLAMA_SERVER:=/home/dank/llama.cpp/build/bin/llama-server}"
: "${MODEL_DIR:=/home/dank/models/qwen36-35b-a3b-fp8}"
: "${ALIAS:=frank-default-small}"
: "${BIND_ADDR:=0.0.0.0}"
: "${LISTEN_PORT:=7770}"
: "${CTX_SIZE:=200700}"
: "${PARALLEL:=3}"
: "${CACHE_TYPE_K:=q8_0}"
: "${CACHE_TYPE_V:=q8_0}"
: "${N_GPU_LAYERS:=999}"
: "${BATCH_SIZE:=4096}"
: "${UBATCH_SIZE:=1024}"
: "${VERBOSITY:=2}"
: "${CPU_MOE:=1}"
: "${TEMPERATURE:=1.0}"
: "${TOP_K:=20}"
: "${TOP_P:=0.95}"
: "${MIN_P:=0.0}"
: "${THREADS:=7}"
: "${THREADS_HTTP:=8}"
: "${FT_VENV:=/home/dank/freetoken/.venv}"
: "${CUDA_HOME_DIR:=${FT_VENV}/lib/python3.12/site-packages/nvidia/cu13}"
MODEL="$MODEL_DIR/$MODEL_FILE"
# Pool sizing (expert residency vs KV cache tradeoff).
: "${MOE_CACHE_SIZE:=2048}"
: "${NUM_TOKENS:=453005}"
: "${MAX_RUNNING_REQUESTS:=4}"
if [[ ! -f "$MODEL" ]]; then
echo "missing required file: $MODEL" >&2
# Paths
FT_BIN="${FT_VENV}/bin/ft"
MODEL="${MODEL_DIR}"
if [[ ! -x "$FT_BIN" ]]; then
echo "missing FreeToken CLI: $FT_BIN" >&2
exit 1
fi
if [[ ! -x "$LLAMA_SERVER" ]]; then
echo "missing llama-server binary: $LLAMA_SERVER" >&2
if [[ ! -d "$MODEL" ]]; then
echo "missing model directory: $MODEL" >&2
exit 1
fi
exec "$LLAMA_SERVER" \
export PATH="${FT_VENV}/bin:${PATH}"
export CUDA_HOME="${CUDA_HOME_DIR}"
exec "$FT_BIN" serve \
--model "$MODEL" \
$([ "$CPU_MOE" = "1" ] && printf -- "--cpu-moe") \
--cache-type-k "$CACHE_TYPE_K" \
--cache-type-v "$CACHE_TYPE_V" \
--ctx-size "$CTX_SIZE" \
--parallel "$PARALLEL" \
--gpu-layers "$N_GPU_LAYERS" \
--batch-size "$BATCH_SIZE" \
--ubatch-size "$UBATCH_SIZE" \
--temp "$TEMPERATURE" \
--top-k "$TOP_K" \
--top-p "$TOP_P" \
--min-p "$MIN_P" \
--threads "$THREADS" \
--threads-http "$THREADS_HTTP" \
--alias "$ALIAS" \
--served-model-name "$ALIAS" \
--host "$BIND_ADDR" \
--port "$LISTEN_PORT"
--port "$LISTEN_PORT" \
--moe-cache-size "$MOE_CACHE_SIZE" \
--num-tokens "$NUM_TOKENS" \
--max-running-requests "$MAX_RUNNING_REQUESTS"