Skip to content

feat(moe): suggest an expert residency that leaves room for prompts - #4858

Merged
jundot merged 1 commit into
mainfrom
feat/moe-offload-fit-hint
Oct 26, 2026
Merged

jundot merged 1 commit into
mainfrom
feat/moe-offload-fit-hint

Conversation

@jundot

@jundot jundot commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

The MoE Expert Offload field in Model Settings now suggests a resident percent, and clicking the hint fills the field. Before and after the click, with a 12 GiB ceiling:

Screenshot 2026-10-26 at 6 25 33 PM

The suggestion is the largest whole percent whose admission estimate stays about 4 GiB under the scheduler's prompt line, so the model loads and still has room to take a prompt. The line is (memory ceiling - hot cache) x the memory-guard tier headroom, and models that are already loaded count against it. When even 5% leaves less than 4 GiB, a short notice shows instead. Nothing shows when the model fits without offload.

Based on #3676 by @beatakouchnir, who is co-author on the commit.

How it works

  • EnginePool.moe_offload_fit() sizes each candidate percent through _entry_runtime_resident_size, the same arithmetic load admission uses, starting from the checkpoint size even when the model is loaded. A log_decision flag keeps these probes from logging or recording forced offload decisions.
  • For Qwen4-Exp and DeepSeek V4.1 a larger percent can fit only because the load moves the PLE or Engram table to SSD. The hint keeps the table resident at a lower percent when one fits, and uses the SSD case only when nothing else fits.
  • GET /admin/api/models/{model_id}/moe-offload-fit returns the hint. Optional mtp_enabled, qwen4_ple_ssd_offload and deepseek_v41_engram_ssd_offload query flags size unsaved edits.
  • The dashboard asks when the settings modal opens or one of those toggles changes, not on the model list poll. Computing it for DeepSeek-V4.1-Flash (371 GiB, 65 shards) takes about 0.03 s.
  • The docs page gets a short section with the measurements below.

Validation

M3 Ultra with the ceiling held at 12 GiB (balanced tier, prompt line 11.85 GB). Each model was loaded at the suggested percent and sent one 16K-token prompt.

Model Suggested Loaded 16K-token prompt Peak
gemma-4-26b-a4b-it-4bit 33% 8.3 GB served 11.4 GB
Qwen3.6-35B-A3B-MLX-4bit 28% 7.7 GB served 10.0 GB

The suggestion stays the same after the model is loaded with offload on.

The MoE offload field now offers the largest whole resident percent whose admission estimate stays 4 GiB under the scheduler's prompt line, after the hot cache and other loaded models. A Qwen4-Exp PLE or DeepSeek V4.1 Engram table stays resident when a lower percent fits that way. GET /admin/api/models/{id}/moe-offload-fit also sizes unsaved MTP and table toggles, and its probes skip the forced-offload logs.

Co-Authored-By: Beata Kouchnir <12824699+beatakouchnir@users.noreply.github.com>
@jundot
jundot merged commit d520df3 into main Oct 26, 2026
1 check passed
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