Qwen3.8-Flash-Next Coder cut240 GGUF for a patched llama.cpp

This GGUF requires the linked patched llama.cpp build; stock llama.cpp cannot load it.

The model of Schiltmans/Qwen3.8-Flash-Next-Coder-cut240, packed as GGUF. It is ISTA-DASLab's IQ1_M Coder GGUF of Qwen3.8-Flash-Next (ISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-Coder-GGUF at 5348543e) with 768 of its 12,288 routed experts removed. Each layer keeps 185 to 255 of 256 routed experts, 240 on average. The kept experts' bytes are unchanged, and each router keeps only the rows of its layer's kept experts.

Tested with Metal on one 48 GB M4 Pro, all layers on the GPU and -fa on; other backends were not checked.

Needs a patched llama.cpp

Stock llama.cpp reads qwen4exp.expert_count as one number and stops with key qwen4exp.expert_count has wrong type arr but expected type u32. The fork alexschiltmans/llama.cpp-per-layer-experts, branch per-layer-experts, holds the change as commit 1f12597d768503aac85479a708e8cc02fd5f3d2a on llama.cpp release b11750: expert_count can hold one count per layer, and qwen4exp builds each layer's router and expert tensors with that layer's count. What the commit changes and how to check it: the fork's README.

Prerequisites: an Apple Silicon Mac, git, CMake, Xcode's command-line tools, uv for the download, and about 58 GB of free disk for the model plus the llama.cpp checkout and build.

git clone --branch per-layer-experts https://github.com/alexschiltmans/llama.cpp-per-layer-experts llama.cpp-per-layer-experts
cd llama.cpp-per-layer-experts
git checkout a66501a998a307b432eb69080f7efee427a1da04
cmake -B build -DGGML_METAL=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release -j
cd ..

Commit a66501a9 has SSD streaming (below) with its optional keep-busy switches, and keeps llama-server answering when nothing reads its output. It gives the same greedy output as the builds the results were measured at (1f12597d; SSD streaming at e2d5c9f9).

Use

uvx --from huggingface_hub hf download Schiltmans/Qwen3.8-Flash-Next-Coder-cut240-GGUF --local-dir cut240-gguf   # 56.75 GB
cd cut240-gguf && shasum -a 256 -c SHA256SUMS && cd ..
llama.cpp-per-layer-experts/build/bin/llama-server \
  -m cut240-gguf/Qwen3.8-Flash-Next-Coder-cut240-IQ1_M-00001-of-00003.gguf \
  -ngl 99 -fa on -c 32768 -np 1 -fit off --cache-ram 2048 --jinja \
  --temp 1.0 --top-p 0.95 --top-k 20 --min-p 0 \
  --chat-template-kwargs '{"enable_thinking":false}' --port 8080

The server listens on http://127.0.0.1:8080/v1 (GET /v1/models returns the model id). Point -m at the -00001-of-00003 file; llama.cpp loads the other two from the same folder.

  • The results used these settings: tool calls in one user turn with thinking off (the server-wide flag above), at about 2.5K and 13K tokens of context. The 32768-token window was not tested in full.
  • --jinja turns on the chat template, which tool calls need; -fa on turns on flash attention (required; -fa off is outside the tested setup). Set the sampling flags yourself: llama-server's defaults differ (for example min_p 0.05).
  • The third file holds the model's n-gram embedding tables, read on demand from the memory-mapped file for every token; it is not a drafting model, and no result used llama.cpp's speculative decoding (--spec-type, --draft-*).

Highest wired memory with these settings: 32.15 GB for the whole machine (2.50 GB before the server started), serving the tool checks with the command above at up to 13,000 tokens of context.

Speed (llama-bench, same build and settings): a 512-token prompt, then 128 generated tokens, after the given number of context tokens; mean ยฑ sd of 3 runs, at most 31.83 GB wired.

context tokens before prompt, tok/s generation, tok/s
0 347.0 ยฑ 1.2 23.2 ยฑ 0.1
8,192 286.8 ยฑ 4.6 21.7 ยฑ 0.1
16,384 281.8 ยฑ 3.9 21.4 ยฑ 0.1
30,000 271.0 ยฑ 2.5 20.6 ยฑ 0.6

Beyond the tested setup

llama.cpp's usual options apply but were not checked with this model:

  • -c: the GGUF's context length is 262144 tokens. The speed table above goes to 30,000 tokens of context; larger windows need more memory for the KV cache and were not measured.
  • --cpu-moe / --n-cpu-moe N: routed-expert weights (all, or those of the first N layers) stay in system memory, for a GPU with less memory; on Apple Silicon that is the same unified memory. --cpu-moe alone ran here but is outside the tested setup (Results).
  • --cache-ram: llama-server's prompt cache in MiB (8192 unless set; the command above uses 2048).

Low memory: SSD streaming (macOS)

With this build, the routed experts stay on the SSD and only a GPU cache of them sits in memory (--moe-cache-mib, large enough for every layer, small -ub). The cache reads the experts it misses past the page cache from a sidecar, an expert-major copy of the 00002 file: 23.9 GB, built in about 30 s, with 2 GiB of free disk kept on top (--headroom-gib). Its .bin and .idx stay next to the 00002 file. Then:

python3 llama.cpp-per-layer-experts/scripts/build-moe-sidecar.py \
  cut240-gguf/Qwen3.8-Flash-Next-Coder-cut240-IQ1_M-00002-of-00003.gguf   # needs Python 3 with numpy
LLAMA_MOE_CACHE_DIRECT_IO=1 \
LLAMA_MOE_CACHE_DIRECT_IO_SIDECAR=cut240-gguf/Qwen3.8-Flash-Next-Coder-cut240-IQ1_M-00002-of-00003.gguf.experts-major.idx \
llama.cpp-per-layer-experts/build/bin/llama-completion \
  -m cut240-gguf/Qwen3.8-Flash-Next-Coder-cut240-IQ1_M-00001-of-00003.gguf -f prompt.txt -n 512 \
  --temp 0 --top-k 1 -s 1 -no-cnv -nr -fit off -fa on -c 4096 -ub 2 -b 2 -ngl 99 --cpu-moe --moe-cache-mib 12288

Optional: keep the GPU busy

Two opt-in switches speed up streaming decode; both need Metal and LLAMA_MOE_CACHE_DIRECT_IO=1. LLAMA_MOE_CACHE_GPU_KEEPALIVE=1 runs a dummy kernel while the missed experts are read, so the GPU does not clock down; LLAMA_MOE_CACHE_DIRECT_IDS=1 reads the router ids in shared memory instead of copying them back. To use them, add both to the environment lines of the command above.

--moe-cache-mib decode tok/s, off keep-busy keep-busy and direct ids energy per token, both vs off: CPU+GPU+ANE (whole machine)
4096 3.99 7.08 7.42 5.1x (2.0x)
12288 11.56 13.81 15.40 1.9x (1.3x)
16384 14.74 16.05 18.22 1.0x (0.95x)

Medians of 3 cold runs per setting in one series, with the streaming command above plus -t 10 --ignore-eos --no-warmup; off is the same build without the switches. The greedy text matched the run without the switches byte for byte. With keep-busy the GPU no longer idles, so power rises. Energy per token is the median power during decode divided by tok/s. Use both switches at 16384 MiB if that cache fits in memory: +24 % at the same energy per token. Otherwise use 12288 MiB: +33 % for about twice the CPU+GPU+ANE energy per token. At 4096 MiB the speed-up is larger (+86 %), but the energy per token is about five times higher, which matters on battery. Measured on one M4 Pro (48 GB); other Macs may differ.

24 GB and 32 GB Macs

The decode figures below use smaller expert caches, measured on the same M4 Pro (48 GB) with the streaming command above and only --moe-cache-mib changed. Runs were cold, and the output text was the same with the switches on and off. Metal total is the GPU memory llama.cpp allocates for the model, the expert cache and the KV and state buffers, from its load lines.

--moe-cache-mib Metal total, GiB decode tok/s, off keep-busy and direct ids
6144 10.0 5.06 9.43
10240 14.0 8.91 13.55

With llama-server, the sidecar and long prompts (-c 32768 --cache-ram 512, and the largest -ub that the smallest per-layer cache group allows: -ub 4 at 6144 MiB, -ub 7 at 10240 MiB), the follow-up turn reused the prompt cache:

--moe-cache-mib switches cold 12.2K-token prompt, s follow-up turn, 1.5K new tokens, s
6144 off 1879 250
6144 keep-busy and direct ids 1023 137
10240 keep-busy and direct ids 541 77

At 6144 MiB the server read the prompt 1.83x as fast with the switches on (11.9 against 6.5 tok/s, from its own timings). In these runs long prompts were too slow for agent use. For agents on a 24 GB or 32 GB Mac, use the MLX runner of Schiltmans/Qwen3.8-Flash-Next-Coder-cut240 with SSD streaming.

Details: docs/moe-ssd-streaming.md.

Results

llama.cpp with this fork serves the same model as the cut240 repository's MLX runner: its output distributions differ from the MLX runner's only slightly more than the MLX runner's own differ between two prefill chunk sizes, no difference in tool-call reliability was detected, and expert routing agreed nearly as closely as the MLX runner agrees with itself. Methods and per-window tables: evidence/checks.md.

check setup result
output distributions 17 held-out windows of 3.2K-8.1K tokens, 98,028 positions, teacher-forced on the same token ids; KL from the MLX runner's top-64 log-probs plus a tail bucket mean KL 0.05120 (highest window 0.22751); MLX chunk-size sensitivity reference 0.04727 (0.22265); top-1 agreement with the MLX reference 0.9465 (chunk-size sensitivity reference 0.9492)
tool calls 7 cases at 2,500 and 13,000 tokens of context, thinking off; 56 greedy and 140 sampled requests per runtime greedy 56 of 56 on llama.cpp, 56 of 56 on MLX; sampled 138 of 140 and 139 of 140 (McNemar p 1.000); wrong arguments 0 on llama.cpp
routing top-10 routed experts per token and layer against the MLX runner, with the MLX chunk-size sensitivity reference mean top-10 overlap 0.9492 against the MLX chunk-size sensitivity reference's 0.9531; largest per-layer gap +0.0123 (layer 1)
--cpu-moe, outside the tested setup against the all-GPU run: output distributions on 2 windows (7,390 positions), greedy runs of 4 prompts top-1 agreement with the all-GPU run 0.9490 (--cpu-moe) and 0.9486 (--cpu-moe --no-op-offload, expert matrix products on the CPU); KL to the MLX runner 0.07337 and 0.07339 (all-GPU 0.06990); greedy text the same in 1 of 4 and 1 of 4 prompts

The runtimes' samplers differ, so a seed gives different draws on each; with 140 sampled requests only large differences can show.

SSD streaming: the streaming command above plus -t 10 --ignore-eos --no-warmup, on a desktop in normal use; streaming runs start cold; -ub 2, unlike the llama-bench table. Wired memory is the whole machine's peak, not a minimum RAM. The experts are computed on the GPU, as in the all-GPU run; at every tested size the logits (6 of 6) and greedy text (4 of 4) matched it bitwise, unlike plain --cpu-moe (table above). Method: evidence/checks.md.

--moe-cache-mib decode tok/s, median (min-max) of 3 runs wired, machine peak, GB direct-I/O read per token, MB bitwise match to all-GPU
4096 3.97 (3.90-4.00) 12.9 302 yes
12288 10.06 (9.92-10.41) 21.2 60 yes
16384 14.14 (13.87-14.54) 25.3 29 yes
all-GPU, no streaming 28.04 (27.83-28.11) 31.7 n/a reference

Limits

  • Checked with Metal on one 48 GB M4 Pro only; CUDA, Vulkan, SYCL and ROCm were not built or tested with this model.
  • Not checked: --n-cpu-moe N, requantized files, gguf-split --merge, a quantized KV cache (-ctk/-ctv), contexts beyond 13K tokens, thinking on, multi-turn agent sessions; --cpu-moe alone is outside the tested setup.
  • The chat template inside the GGUF is ISTA-DASLab's. For one user turn with tools and thinking off it renders the same prompt as the cut240 repository's chat_template.jinja; other conversation shapes were not compared.
  • The cut240 repository's speed figures come from its own MTP drafting and do not apply here.
  • SSD streaming: macOS 26.6 only; measured on one M4 Pro with llama-completion, -c 4096 -ub 2 -b 2 and the sidecar (without it: not measured), and with llama-server at the settings under 24 GB and 32 GB Macs. The keep-busy switches were measured only at the cache sizes in their tables.

Files

file what
Qwen3.8-Flash-Next-Coder-cut240-IQ1_M-00001-of-00003.gguf 4.46 GB: every tensor except the routed experts and the n-gram tables; routers keep the kept experts' rows; tokenizer and chat template
Qwen3.8-Flash-Next-Coder-cut240-IQ1_M-00002-of-00003.gguf 23.50 GB: the kept routed experts, bytes unchanged
Qwen3.8-Flash-Next-Coder-cut240-IQ1_M-00003-of-00003.gguf 28.80 GB: ISTA-DASLab's n-gram embedding tables, unchanged
SHA256SUMS checksums of the three files
evidence/ the measurements behind this card
LICENSE, LICENSE-APACHE-2.0, NOTICE licences and the list of changes

The metadata keeps ISTA-DASLab's general.quantized_by and general.repo_url as provenance.

Licences

  • Weights: Qwen Community License 1.0 (LICENSE), as a derivative of Qwen3.8-Flash-Next.
  • ISTA-DASLab's source GGUF: Apache-2.0 (LICENSE-APACHE-2.0); NOTICE lists the changes made here.
  • The llama.cpp fork: MIT, as llama.cpp.
Downloads last month
160
GGUF
Model size
113B params
Architecture
qwen4exp
Hardware compatibility
Log In to add your hardware

1-bit

Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for Schiltmans/Qwen3.8-Flash-Next-Coder-cut240-GGUF

Collection including Schiltmans/Qwen3.8-Flash-Next-Coder-cut240-GGUF