Skip to content

馃毀 [WIP] MoE cache, CPU experts and GGUF support聽#671

Open

Description

@jason-fxz

Tracks the refactor of the MoE expert cache and the CPU expert path and GGUF support.

Where it stands

Work items

Cache

Mixed quant per layer

  • Engine, loaders and FTW checkpoints take each layer's own expert method; the CPU executor gets every layer's format as (name, options) and treats all formats alike. feat(moe): serve experts of several formats through per-format slot pools聽#700 @andy-yang-1 @jason-fxz
  • Resident (fused) experts of several formats.
  • Record each layer's expert quant in ModelConfig (keep expert_quant as the most common one for compatibility) and make the decisions taken before the model is built per layer: fused eligibility, --moe-cpu-layers auto, the automatic offload / hybrid pick, and the family weight readers (qwen3_5_moe reads stacked bf16 experts only when expert_quant == "none").
  • ft bench bw: record one entry per layer kind, keyed by (format, (H, I), options), e.g. ("bf16", (H, I)), ("nvfp4", (H, I)), ("gguf", (H, I), Q4_0, Q6_K), and let the engine pick hybrid and the fetch fraction per layer. Today the profile is keyed by format only and the automatic fetch cap reads the most common format's entry for every layer. (feat(moe): bench hybrid fetch fractions per moe layer kind聽#734)

CPU expert executor

GGUF

Kernels and loading

Model Support

Every model family FreeToken registers; the backticked name is the GGUF architecture llama.cpp's converter writes.

Known issues

  • MoE MMQ (the GPU path above 8 tokens) hits an illegal memory access when one token routes to the same expert slot more than once. hybrid does this on every step that has CPU routes: they are parked on slot 0 with weight 0 because the GGUF MoE kernel cannot skip inactive slots. So hybrid crashes above 8 tokens per step for any quantized expert type; Q4_0 is the only one it runs today.
  • Qwen3.8-Flash-Next with --ple-backend disk (wait-sync): the first CUDA graph replay of a batch size can hang, because the graph waits on a host flag that the engine sets only after replay() returns and the first replay also uploads the graph. Seen at 16 concurrent requests on the GGUF; not GGUF-specific. fix(engine): upload cuda graphs at capture so a stream wait cannot block the first launch聽#697 @jason-fxz
  • MMQ / MMVQ use 32-bit block offsets, so a weight view of more than 2^31 blocks is not supported, e.g. a Qwen3.8-Flash-Next offload pool of Q4_0 / Q8_0 experts above 20,971 slots. fix(gguf): reject ggml weights past the 32-bit block offsets of MMQ / MMVQ聽#699 makes it raise instead of faulting. @jason-fxz
  • IQ1_M experts have no MMQ kernel, so MoE steps above 8 tokens fail.
  • NVFP4 GGUF .scale: llama.cpp's converter keeps each NVFP4 tensor's weight_scale_2 in a separate <name>.scale tensor. It is now applied on the GPU and CPU paths, and the gemma4, llama, qwen3, qwen3moe, qwen35 and qwen35moe loaders read it (feat(gguf): apply the weight scales of nvfp4 gguf tensors聽#732).
  • NVFP4 GGUF, still refused: an NVFP4 token_embd (the vendored get_rows has no NVFP4 case), and .scale on glm4moe, qwen2, minimax-m2, minimax-m3, muse-glimmer and qwen4exp, which have no tested NVFP4 GGUF. llama.cpp's converter cannot produce a valid one for minimax-m2 and muse-glimmer.

Performance

do after basic GGUF CUDA/CPU kernel support.

  • ggml CPU kernels for GGUF experts (measured on a Xeon 8480+, 12 threads): x86 quantize_row_q8_K is scalar (about 5 us per row at K=2560); IQ types are compute-bound (30-40 GB/s per expert vs about 140 GB/s for Q4_K); with several tokens on the same experts, Q4_0 / Q4_K / Q8_0 run slower than on distinct experts (cause not investigated).
  • MoE MMQ: tune the tile width J of the flat grid; the automatic choice was up to 23% slower than the best J in a sweep.
  • Native FP4 MMA (off unless GGML_CUDA_FP4_MMA; needs an sm_120a / sm_120f build).

Activity

  1. added
    featureNew feature or request
    and removed
    featureNew feature or request
    on Oct 13, 2026
  2. changed the title [-]MoE cache and CPU expert refactor[/-] [+]馃毀 WIP: MoE cache and CPU expert refactor[/+] on Oct 14, 2026
  3. changed the title [-]馃毀 WIP: MoE cache and CPU expert refactor[/-] [+][WIP] MoE cache and CPU expert refactor[/+] on Oct 14, 2026
  4. changed the title [-][WIP] MoE cache and CPU expert refactor[/-] [+]馃毀 [WIP] MoE cache and CPU expert refactor[/+] on Oct 15, 2026
  5. pinned this issue on Oct 16, 2026
  6. changed the title [-]馃毀 [WIP] MoE cache and CPU expert refactor[/-] [+]馃毀 [WIP] MoE cache, CPU experts and GGUF support[/+] on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions