Repository navigation
[w2] llama-bench: --moe-cache-mib / --moe-cache-cpu-share (Qwen4 baseline kit) - #161
Merged
Merged
Conversation
Sweepable like -ncmoe (comma lists, default 0 = disabled). They map to llama_context_params moe_cache_size (MiB) and moe_cache_cpu_share, so the MoE expert cache (#154) can be measured per depth with -d. Markdown output shows the columns only when set or swept; jsonl/csv/sql carry the new fields. The cache needs a GPU backend; a CPU-only llama-bench reports that error. Assisted-by: Claude Sonnet 5.5
Owner
Author
|
Reverted from master on 2026-12-04 (w2 build crashed Qwen4-single at >20k ctx; no measured gain). Commit preserved on branch archive/w2-25f0def; will be re-landed individually after GPU validation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
llama-benchgets two sweepable options so the MoE expert cache (#154) can be measured per depth (-d) like-ncmoe:-mcm, --moe-cache-mib <n>(comma list/ranges, default 0) ->llama_context_params.moe_cache_size(MiB * 1024 * 1024)-mcs, --moe-cache-cpu-share <f>(comma list, default 0.0, must be 0..1) ->moe_cache_cpu_shareSame plumbing as
n_cpu_moe: help text, parser,cmd_params,cmd_params_instance,to_llama_cparams,testfields (jsonl/csv/sql carrymoe_cache_mib,moe_cache_cpu_share), README. The markdown table shows the columns (mcm,mcs) only when swept or non-default, so default output is unchanged. They are context parameters, so changing them does not reload the model.Why
Qwen4-35B-A3B runs 8-11 expert layers on the CPU of a Zen1 host with 15 GB RAM, and the production preset sets no
moe-cache-mib. Configuration (n-cpu-moe, cache size, threads) may be the largest unmeasured Qwen4 lever. This PR is only the tool; the baseline/tuning kit (VRAM fit, n-cpu-moe/moe-cache/threads sweeps, traces, MTP, engram page faults, KLD base, byte/launch budget) is local:/home/tom/docker/projects/llama.cpp-RDNA3/build-bins/w2/qwen4-bench-prep/README.md(not committed). Any preset change is the user's decision.Expected gain (estimate)
No direct speedup. budget.py on the real GGUF header: experts are 416 MiB/layer (13 MiB/layer read per token); the 11 CPU layers read 143 MiB/token, about 6 ms of a modelled ~10 ms token at an assumed 25 GB/s, so each extra GPU-resident layer is about 0.5 ms. Measurements tonight replace the assumptions.
Env switch
None. Defaults 0 = previous behaviour.
Files
tools/llama-bench/llama-bench.cpp,tools/llama-bench/README.mdRisks
-mcm > 0needs a GPU backend (the cache is device-only); CPU-only llama-bench exits with "MoE cache requires a GPU backend" (verified).-dthen.Checked (CPU only, no GPU used)
llama-bench --helplists both flags; on a tinyqwen4expGGUF fromtest-llama-archs -o:-mcm 0,64 -mcs 0,0.5 -p 8 -n 4 -ncmoe 1 -r 1runs the 0 cases and the sweep columns appear; the-mcm 64case fails with the CPU-only error above;-mcs 1.5and-mcm -1give parse errors; default jsonl just gains the two fields.bash -non every script,py_compileon the python helpers,budget.pyrun on the finished GGUF header (header only).GPU validation tonight (NOT YET RUN)
Preamble:
R=/home/tom/docker/projects/llama.cpp-RDNA3; K=$R/build-bins/kern; TB=$R/build-bins/tools/bench; cd $K; B0=$R/build-bins/w2/base-build/bin; BA=$R/build-bins/w2/all-build/bin; Q4=qwen/qwen-4-35b-a3b/UD-IQ4_XS/Qwen4-35B-A3B-UD-IQ4_XS-00001-of-00002.gguf; Q4A='-ctk q8_0 -ctv q8_0 -ncmoe 11 -b 1024 -ub 512'; Q4F='-ctk f16 -ctv f16 -ncmoe 8 -b 1024 -ub 512'; S=$R/build-bins/w2/qwen4-bench-prep. Run first tonight, on B0 (the -mcm line needs a build with this PR: BA). Long blocks:BLOCK_TIMEOUT=7200.Rules followed
No GPU was used or locked while preparing this; no production, router, docker compose,
llama-cpp-rocm:*image or homelab file was touched; nothing was sent to ggml-org/llama.cpp; the build tree was deleted.Assisted-by: Claude Sonnet 5.5