Skip to content

serve: --moe-slots auto, --moe-prefetch (off by default) - #169

Merged
bong-water-water-bong merged 3 commits into
mainfrom
moe/serve-auto
Sep 27, 2026
Merged

bong-water-water-bong merged 3 commits into
mainfrom
moe/serve-auto

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator
  • --moe-slots auto sizes the expert cache from free memory: MemAvailable, less the other tensors the GPU holds and a reserve (8 GiB or 15%), divided by the mean expert size from moe/GgufIndex. It's clamped to the model's experts, with a floor of 64 per layer.
  • --moe-prefetch N controls the gate-ahead prefetch, now off by default. On Flash-Next it doubled decode time because the drive is already the limit.
  • Docs: serve.md, plus moe-streaming.md Next item 0. Prompts above 8 tokens run the experts on the CPU from the mapped file, which is slow.

Verified on strixhalo with 1bit serve -m Qwen3.8-Flash-Next-UD-Q4_K_XL-00001-of-00004.gguf --moe-slots auto --ctx-size 4096:

  • auto picked 9331 of 24576 experts (27.2 GiB), with 40.4 GiB free and 5.1 GiB of other tensors on the GPU.
  • Both answers were correct ("The capital of France is Paris.", and a Fibonacci function). Decode ran at 2.6-4.4 tok/s from a cold cache.
  • The serve process tree held 145 MiB of anonymous memory.
  • Prompt speed was 0.4-0.8 tok/s, the open item above.

🤖 Generated with Claude Code

bong-water-water-bong and others added 2 commits September 26, 2026 20:04
…e-prefetch, off by default

auto reads the model's expert sizes (moe/GgufIndex) and takes MemAvailable, less the other
tensors the GPU holds and a reserve (8 GiB or 15%), divided by the mean expert size, clamped to
the model's experts with a floor of 64 per layer. The gate-ahead prefetch is now off unless
--moe-prefetch N asks for it: on Qwen3.8-Flash-Next it doubled decode time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… streaming

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bong-water-water-bong
bong-water-water-bong enabled auto-merge (squash) September 26, 2026 23:50
@context7

context7 Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Docs7 for 1bit-monster/engine

Result Status Action
Deployment ➖ Not used —
Content review ➖ Did not run. This site has no agent runs available this month. Wait for the monthly reset or check your Docs7 plan. —

Commit 0e72711

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Reviewed. auto_moe_slots reads right for unified memory: it subtracts the tensors the GPU holds, and reserves the larger of 8 GiB or 15% free. The docs now cover the prefetch default. One nit, not blocking: any negative --moe-slots value is taken as auto. Rejecting everything below 0 except the word auto would catch typos.

@bong-water-water-bong
bong-water-water-bong merged commit cb5459e into main Sep 27, 2026
10 of 11 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the moe/serve-auto branch September 27, 2026 00:01
bong-water-water-bong added a commit that referenced this pull request Nov 1, 2026
…ation, #170 -ot/input-layer) + held hrx-system (#786)

* hw-gate: pass the gfx device library to its own configure, and recognise the zero-cases exit

The gate's build failed at #772 with
  clang++: error: cannot find ROCm device library; provide its path via '--rocm-path' or
  '--rocm-device-lib-path', or pass '-nogpulib' to build without ROCm device library
- not a kernel result and not the pin: hw-gate.sh configures third_party/llama.cpp directly, so
cmake/hrx.cmake's fix (engine#713, #771) never reached it, and the kernel-corpus compile is its own
amdclang++ invocation that does not inherit the llama.cpp build's CMAKE_C/CXX_FLAGS either. The box
only builds because build-candidate{19,20}.sh export HIP_DEVICE_LIB_PATH into the whole run - which
the workflow does not.

- Read the gfx device library from the resolved toolchain (its pip tree, where the 2026-10-31 layout
  put it) and pass it as GGML_HRX_HIP_FLAGS="-O3 --rocm-device-lib-path=…" plus
  GGML_HRX_HIP_COMPILER=<toolchain>/bin/amdclang++ - the same pair cmake/hrx.cmake now passes - and
  export HIP_DEVICE_LIB_PATH as a fallback for anything else in the tree.
- A changed flag set drops the cached CMakeCache.txt (a marker beside .gpu-kernels-pin), so an
  existing build tree cannot keep configuring without it.
- ops: the pin carries the zero-cases guard (tests/test-backend-ops.cpp, fork engine#657) - a run that
  executed no case exits 1 and says "error: no test case ran (check -b/-o/-p and --test-file):
  refusing to report a pass". Recognise that as its own outcome: ops SKIP naming the selection that
  matched nothing, never a PASS (an empty selection must not look green) and never a bare FAIL that
  reads like a kernel fault.

Verified on the box without a GPU, with HIP_DEVICE_LIB_PATH/ROCM_PATH/HIP_PATH unset: the gate's own
configure arguments against /opt/rocm-therock produce all 50 gfx1151 code objects and the embedded
.inc, where the same configure without the flag reproduces the CI error. bash -n clean.

* Bump HRX: llama.cpp 1d32c22609d6 + held hrx-system 82804197bcbe

The fork line moved two commits past 1991650479db - #169 (hrx: host-weight residency instrumentation,
weak leases, and an opt-in bound, engine #669) and #170 (loader: an explicit -ot wins over the arch's
lazy-read hint, LLAMA_INPUT_LAYER_ON_DEV moves the input layer) - so this cut carries the new tip
1d32c22609d6eb23d48a26ba14e680e40afd6e17. Replaces the 1991650479db cut (#772), which was gated on
the previous run.

- third_party/llama.cpp: 1991650479db -> 1d32c22609d6
- hrx-system: unchanged at the held 82804197bcbe (config/hrx-system-hold.config); the hold is not
  lifted by this PR
- registry/architectures.json: regenerated against the new gitlink (tools/registry_build.py): 294 hrx
  / 7 npu, 0 architectures added or removed, so the only change is the recorded source pin;
  --check-pins says "records the committed pins"

Checked on the new tip before cutting: the ggml-hrx HIP add-on hook (GGML_HRX_HIP_ADDON_DIR) is
present, tools/mtmd/models/models.h exists (the file whose absence in the runner's checkout failed the
first #772 gate), and test-backend-ops still carries the zero-cases guard the improved gate row now
recognises.

---------

Co-authored-by: bong-water-water-bong <bong-water-water-bong@1bit.gg>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant