Pull requests / #2105
#2105 feat(mtp): support native Q4_0 and Q8_0 experts
open · draft · @xszwow · 0 コメント · GitHub で見る
AMD / HIPNVIDIA / CUDAModels & quantsWindows
本文
## Summary Teach the Flash-Next MTP drafter to load routed experts in native GGUF Q4_0 or Q8_0 row layout, in addition to the existing Q2_0 S2 runtime. This is opt-in through a runtime generated by `tools/mtp_rt.py`. Existing runtimes without `experts.txt` keep the legacy Q2_0 S2 path and default behavior. ## What changed - `tools/mtp_rt.py` now: - detects the routed experts' GGML type; - preserves Q4_0 and Q8_0 rows in native `[gate | up | down]` order; - keeps Q2_0 in the existing S2 relayout; - writes `experts.txt` with a version, layout, types, and bytes per expert. - `MtpDrafter` reads and validates that metadata, checks the exact `experts.bin` size, allocates the correct expert blob size, and dispatches native runtimes through the existing grouped native-expert kernels. - `tools/mtp_fetch.py` accepts opt-in `STRATA_MTP_REPO` and `STRATA_MTP_REVISION` values for a compatible fine-tune's MTP tensors. With neither variable set, the original Qwen URL, pinned revision, and SHA-256 verification path are unchanged. - Shared slot drafters inherit the selected layout and types from their owner. The model geometry, server defaults, CLI defaults, legacy Q2_0 runtime, and non-MTP paths are unchanged. ## Validation Rebased cleanly onto `main` at `7695859a`; the four touched files had no intervening upstream changes since the tested 0.1.42 base (`61b3fb5d`). Static/tool checks: - `python -m py_compile tools/mtp_fetch.py tools/mtp_rt.py` - `python -m unittest tools.test_mtp_fetch`: 8 passed - `git diff --check` Conversion check: - Converted a 1,596,806,016-byte Q4_0 MTP GGUF with this branch. - The generated `experts.bin` (1,415,577,600 bytes), `experts.txt`, `dense.bin`, and `dense.txt` were byte-identical to the runtime used for the HIP tests. - `experts.bin` SHA-256: `cb101ab35f946698ef09dddc942c41620ac03de40483a661ea07052b59ff16c5` - `experts.txt` SHA-256: `c6fed393954caefd784ba689f7cc23f045f82051631406333c3b37c34e4ba44f` - A Q8_0 runtime was also converted successfully; it was not used for the end-to-end run below. End-to-end run: - Windows 11, Ryzen AI Max+ 395 / Radeon 8060S (`gfx1151`), 128 GB unified RAM, Windows HIP Release build from the tested 0.1.42 source. - The engine reported `native types 2/2`, loaded 1,350 MiB of Q4_0 MTP experts, reached `session is up`, and served repeated text, long-context, tool-use, and vision-integrated requests. - The deployed Q4_0 runtime has been used with `--spec 6..8`, an 8,192-token MTP window, INT8 KV, and up to 262,144 total context capacity. ## Compatibility and limits - A missing `experts.txt` means the legacy Q2_0 S2 layout, preserving old runtimes. - Metadata rejects unknown versions, keys, layouts, types, shapes, blob sizes, and truncated/oversized expert files before inference. - Q4_0 was built and run on Windows HIP. Q8_0 conversion was checked, but Q8_0 inference was not run. - CUDA build/runtime validation is still outstanding, so this is a draft under the repository's backend-validation rule. - SYCL has its separate engine path and was not changed. Related performance/configuration evidence is kept separate from this code change in #1947.
関連リンク
インストール・モデル・リリースへの站内リンク。