Expert predictor for Qwen3.8-Flash-Next

This is not a language model, and it does nothing on its own. It is a small companion file for Qwen/Qwen3.8-Flash-Next. An inference engine that keeps that model's experts in system RAM and caches some of them in VRAM loads it to decide which experts to keep on the GPU. It doesn't generate text and can't be run, chatted with, merged or fine-tuned.

For the model Qwen/Qwen3.8-Flash-Next (arch qwen4exp: 48 layers, 512 routed experts, 10 per token)
Trained on the routing of unsloth/Qwen3.8-Flash-Next-GGUF UD-Q4_K_XL; checked on UD-Q6_K_XL
Works with the Polaris llama.cpp fork (branch polaris): --moe-cache-predictor in the hot spare cache mode
Won't work with upstream llama.cpp, Ollama, LM Studio or any other engine; any other model, including other Qwen MoE models
Size 36 MB (main predictor), 31 MB (start predictor), float32

What it does

Qwen3.8-Flash-Next routes each token through 10 of 512 experts in each of its 48 layers. On a GPU that can't hold all the experts, the fork's hot spare cache keeps as many as fit in VRAM and computes the rest on the CPU. Every expert the cache misses costs CPU time. So the question the cache keeps asking is which experts the next tokens will use.

The predictor answers that question. It runs every 16 generated tokens and at the start of each answer, and predicts for each layer how often each expert will be selected over the next 128 and 512 tokens. The cache swaps in the experts the prediction ranks highest, within its upload budget. Without a predictor, the cache can only rank experts by how often they were selected recently.

It reads:

  • the model's own hidden state at the newest token: the mean of the hyper-connection streams entering layers 16 and 32 (2 Γ— 2560 floats);
  • nine count maps of the selections so far: decayed over all tokens (half-lives 64 and 512), the conversation, the current turn's prompt, the previous answer, the answer so far (whole, and decayed with half-lives 32 and 8), and a fixed prior;
  • how far into the answer it is (13 position buckets, 0 to 1024 tokens).

The model is a 2-layer MLP (5133 β†’ 512 β†’ 128, GELU) and one low-rank head per horizon. A head's logits for layer l, expert e are a bias, plus a per-bucket weighting of the log count maps, plus a rank-128 projection of the MLP's output. A softmax over each layer's 512 experts gives the prediction. One prediction is about 2 ms on one CPU core.

Files

File What it is
flashnext-pred-v3.moepred The main predictor. Pass it with --moe-cache-predictor.
flashnext-start-v3.moepred Optional start predictor (--moe-cache-predictor-start). It predicts from a turn's text before the prompt runs, so uploads can overlap the prompt. It measured slower on the R9700 (docs/moe-predictor.md), so leave it out unless you measure a gain.
checks/pred-v3.vec, checks/start-v3.vec Test vectors from the exporter: inputs and the expected outputs of the original PyTorch model.

The files are GGUF containers (general.architecture = moe-predictor, version 1). They're named .moepred so that tools that open GGUF models don't offer to run them. The fork reads them by path, whatever the extension. The format and the contract are in src/llama-moe-predictor.cpp.

Usage

Build the fork (branch polaris) and add the predictor to a hot spare setup. This is the setup of the current results, on an AMD Radeon AI PRO R9700 (32 GB) with a Threadripper 1920X:

llama-server -m Qwen3.8-Flash-Next-UD-Q4_K_XL-00001-of-00004.gguf -c 65536 \
    -dev Vulkan0 -ngl 99 -ncmoe 49 -ot per_layer_token_embd.weight=CPU -t 12 -np 1 -b 16384 -ub 16384 \
    --moe-cache-mode hot-spare --moe-cache-resize --moe-cache-mib 20900 --moe-cache-budget 10 --moe-cache-batch 0 \
    --moe-cache-predictor flashnext-pred-v3.moepred --moe-cache-refill 0 --moe-cache-jit 8 \
    --moe-cache-predictor-answer-cap 500 \
    -md mtp-Qwen3.8-Flash-Next-Q8_0.gguf -ngld 99 -devd Vulkan0 \
    --spec-type draft-mtp --spec-draft-n-max 3 --spec-draft-n-ubatch 2048 --load-mode mmap+mlock
  • UD-Q6_K_XL uses the same file, with --moe-cache-budget 20 --moe-cache-predictor-answer-cap 125.
  • The environment and the rest of that machine's setup: FORK.md.
  • It assumes one conversation at a time (-np 1).
  • It runs on the CPU with 4 threads by default (LLAMA_MOE_PREDICTOR_THREADS, or --moe-cache-predictor-device).
  • To check that a file loads and computes what it should:
llama-moe-predictor-check flashnext-pred-v3.moepred checks/pred-v3.vec

How the cache uses it: docs/moe-hot-spare.md. How it was trained, with every result: docs/moe-predictor.md. The training scripts are in tools/moe-predictor, so you can train one for another model or quant.

Results

All from docs/moe-predictor.md.

Offline, on held-out conversations (every 5th conversation of each source, 6,828 answers). The hit rate is the share of the next 128 tokens' expert selections that the experts it ranks highest would serve, at 164 per layer (what fits beside UD-Q4_K_XL in the setup above):

tokens into the answer recent selections (decayed) this predictor best possible in hindsight
0 (the answer's start) 75.8% 86.7% 95.7%
64 80.5% 86.7% 95.7%
256 84.2% 86.5% 95.6%
  • At Q6_K_XL's cache size (115 per layer): 65.8% β†’ 78.2% at the answer's start.
  • The previous version (trained on 948 conversations, without the 236 below): 86.4% and 77.9% on the same answers. The new one gains most on agent turns and multilingual chat.
  • Sources it never saw: with whole sources held out (the model's own sessions, a coding agent's runs, math), going from the first version's traces to the 948 conversations took the answer's start from 74.1% to 83.5%.
  • Q6_K_XL routing: on 46 conversations traced through both quants, Q6 selects 93.8% of the same experts. A predictor that hadn't seen those conversations scored 84.1% on both.
  • Other quants (IQ4_XS and the like) are untested.

Live, on the R9700 + 1920X above, temperature 0, generation speed weighted by tokens, two passes each.

This version against the previous one, in the setup above:

UD-Q4_K_XL UD-Q6_K_XL
usual answers 40.82 β†’ 40.62 tok/s (βˆ’0.5%) 31.75 β†’ 31.85 (+0.3%)
follow-up turns 44.67 β†’ 47.34 (+6.0%) 34.34 β†’ 35.03 (+2.0%)
agent turns 45.50 β†’ 45.17 (βˆ’0.7%) 35.10 β†’ 35.76 (+1.9%)
the whole run 205.2 β†’ 203.4 s 248.7 β†’ 247.0 s
hits 81.13% β†’ 81.18% 71.27% β†’ 72.03%

The previous version against no predictor, in that day's setup (2026-11-01: hot spare at 23500 MiB, 2 drafts):

hit rate all answers answers after a large prompt
UD-Q4_K_XL, the cache without a predictor 82.1% 29.17 tok/s 26.75 tok/s
UD-Q4_K_XL, with the predictor (budget 10) 88.5% 31.14 tok/s 32.46 tok/s
UD-Q6_K_XL, the cache without a predictor 74.0% 25.60 tok/s 23.88 tok/s
UD-Q6_K_XL, with the predictor (budget 5) 78.9% 26.45 tok/s 27.31 tok/s

These are one machine's numbers. The gain depends on how much of the model fits in VRAM and how slow the CPU's experts are.

Training data

The predictor was trained on expert-routing traces: which experts Qwen3.8-Flash-Next (UD-Q4_K_XL, in llama.cpp) selected for each token, plus its hidden state at layers 16 and 32 every 16 tokens. The traces cover 1,181 conversations, 21.0M tokens and 34,603 answers: 945 conversations (13.1M tokens) traced on the R9700 + 1920X, and 236 (7.9M tokens, 36% of them agent turns, none of the same conversations) on a 14600KF + RTX 4070 Ti. The two machines' routing agrees within 1.3 points at the predictor's 128-token windows. The files hold only the predictor's own weights: no text, no tokens and none of Qwen's weights.

The text the model read came from these public datasets. Some were read as given (teacher-forced). In others the model wrote its own answers to their first messages, in synthetic multi-turn sessions (the R9700's traces only):

Training

  • Split: every 5th conversation of each source is held out (6,828 answers); the other 27,775 answers train it.
  • Run: PyTorch, 6 epochs, about 11 minutes on the 14600KF + RTX 4070 Ti (plus 1.5 minutes to read the ~82 GB of prepared records from disk). The model's size isn't the limit: on earlier data, a rank-256 head and twice the epochs gave no gain.
  • Export: to GGUF, then checked against PyTorch on 24 test vectors (checks/): the largest difference 1.3e-7, and the top 164 experts of every layer the same.
  • Scripts: tracing, the corpus, training and export are in tools/moe-predictor.

Limitations

  • One model. It's tied to Qwen3.8-Flash-Next's layer count, expert count, hidden size and router. A different model, or a retrained or fine-tuned Flash-Next, needs a predictor trained on its own traces.
  • Quants. It was trained on UD-Q4_K_XL routing and checked on UD-Q6_K_XL. Other quants route a little differently and are untested.
  • One conversation at a time: the counts follow a single conversation (-np 1).
  • It doesn't change outputs. It only decides where experts are computed. The GPU and the CPU round differently, so text at temperature 0 can still differ slightly from a run with another cache state, as with any cache setting.
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support