Skip to content

[Other] setup: a --custom-gguf Qwen4 file without the MTP block drafts from its mtp-*.gguf sidecar - #481

Closed
Rustandi wants to merge 1 commit into
simplexai-labs:mainfrom
Rustandi:qwen4-single-file-mtp-sidecar
Closed

Rustandi wants to merge 1 commit into
simplexai-labs:mainfrom
Rustandi:qwen4-single-file-mtp-sidecar

Conversation

@Rustandi

@Rustandi Rustandi commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

Problem and result

Setup assumes every Qwen4 GGUF carries its draft block (blk.40, nextn_predict_layers = 1), as Unsloth's files do.
A single-file GGUF converted with llama.cpp's --no-mtp has 40 blocks and keeps its MTP head in a file of its own,
mtp-<name>-<quant>.gguf.

Before: --custom-gguf on such a file prints drafter: embedded MTP layer (native strata-poly) and writes a run config
with no --draft-model. The sidecar beside the model is never passed to the engine.

After: setup reads the file's header. When the file has no draft block, it looks for an mtp-*.gguf of the same
architecture in the same folder, prints drafter: MTP sidecar <file> (--draft-model) and writes --draft-model <file>
to the run config. With no sidecar it installs the model and warns that it runs without drafting.

Related discussion

None. I searched open and closed issues and pull requests for sidecar, draft-model qwen4, custom-gguf, no-mtp
and found no thread on this. PR 430 uses a Q8_0 sidecar through a different route (--mtp, a repackaged drafter
runtime) and does not change --custom-gguf.

Approach

  • qwen4_mtp_sidecar() in terminal/setup.py returns whether the file carries the block and, if not, the sidecar.
    A sidecar is taken only if its header has the same architecture and the tensor blk.<n>.nextn.eh_proj.weight
    for the block after the model's last one.
  • Of several sidecars: one named after this model before another model's, then the model's own quantization, then
    Q8_0, then the smallest.
  • --mtp off / --no-draft and --drafter dflash2 behave as before.
  • The lookup runs only for --custom-gguf. A normal install never calls it and its run config is unchanged. A custom
    file in Unsloth's layout gets one more header read and the same message and arguments as before.
  • No engine or server change: strata-poly already reads a .gguf given to --draft-model.
  • One sentence added to docs/models/qwen4.md under "Bring your own GGUF".

Validation

Revision: df2c3ff30 (v0.2.20-poly.10) plus this change. Windows 11, Python 3.14.7.

Passed:

  • python terminal/tools/test_setup_qwen4.py: 10 tests, OK. Two are new: sidecar choice, and a full custom install
    (run config with the sidecar, --mtp off, and the no-sidecar warning).
  • python terminal/tools/test_setup_choices.py: 66 tests, OK.
  • python terminal/tools/test_setup_custom_gguf.py: 21 tests, OK.
  • python tools/check --only docs: passed, 6 of 6.
  • Hardware run, RTX 4080 16 GB (CUDA, release engine), Ryzen 7 9800X3D, 64 GB RAM, Windows 11. Model:
    Qwen4-35B-A3B-Uncensored-Q4_K_M.gguf (36.0 GB) with mtp-Qwen4-35B-A3B-Uncensored-Q4_K_M.gguf (1.29 GB),
    installed with --custom-gguf. The engine started with --draft-model <sidecar> and loaded in 5.5 s with 5,985 of
    10,496 routed experts in VRAM. From the server log:
    • 62-token prompt: 900 tokens at 137.1 tok/s, drafts accepted 464 of 719.
    • 8,774-token prompt read at 1,186.9 tok/s: 700 tokens at 135.3 tok/s, drafts accepted 397 of 590.
    • 126,585-token prompt read at 1,370.9 tok/s: 700 tokens at 122.4 tok/s, drafts accepted 404 of 528.

Failed:

  • python terminal/tools/test_setup_amd.py (77 tests) reported one failure in the first of six runs and passed the
    other five. I did not capture the failing test's name and could not reproduce it. That file does not call the new
    function.

Not run:

  • The same model with --no-draft on the same card. This pull request makes no speed claim: the numbers above only
    show that the engine loads the sidecar and accepts its drafts.
  • python tools/check --only py-tools: pytest is not installed in this environment. The test files above were run
    directly instead.
  • Linux, HIP, SYCL and Metal. Only Windows with CUDA was run.
  • Any other single-file GGUF. Only the one model above was run on hardware.

Limits

  • Unconfirmed static analysis: the engine appears to read attention.compress_ratios from the model file only, so the
    sidecar's draft block would run dense attention rather than its own sparse setting. The acceptance rates above
    (65% to 77%, up to a 126,585-token prompt) are with that behaviour.
  • Unconfirmed static analysis: the server's has_mtp looks for --mtp in the engine's arguments and at the engine's
    own report. A sidecar passed with --draft-model may not count as MTP there, so a request with no sampling fields
    may get the model card's sampling where an embedded-MTP install stays greedy. This change does not touch the server.
  • A sidecar of another model in the same folder is taken when it is the only one. Setup prints its name. I can make
    setup refuse it instead if you prefer.

…s from its mtp-*.gguf sidecar

Setup assumed every Qwen4 GGUF carries its draft block (blk.40), as Unsloth's files do. A single-file GGUF converted
with llama.cpp's --no-mtp has 40 blocks and its MTP head in a file of its own, mtp-<name>-<quant>.gguf. Setup printed
"embedded MTP layer" for it and never passed the sidecar to the engine.

With --custom-gguf, setup now reads the file's header. Without a draft block it takes the mtp-*.gguf of the same
architecture beside the model (one named after this model first, then the model's own quantization, Q8_0, the
smallest) and writes --draft-model to the run config. With no sidecar it warns that the model runs without drafting.

A normal install never calls the lookup; its run config is unchanged.
@Rustandi
Rustandi marked this pull request as ready for review December 5, 2026 12:45
@VecSzn

VecSzn commented Dec 6, 2026

Copy link
Copy Markdown
Collaborator

Integrated on main in commits 4578ed9a6 and 7cef9524a (extended to scan trailing shards in multi-shard custom GGUFs as well; included in upcoming v0.2.20-poly.11). Thanks @Rustandi!

@VecSzn VecSzn closed this Dec 6, 2026
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.

2 participants