[PR #2105] [CLOSED] feat(mtp): support native Q4_0 and Q8_0 experts #3860

Closed
opened 2026-11-07 15:31:16 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2105
Author: @xszwow
Created: 10/12/2026
Status: ❌ Closed

Base: main ← Head: feature/mtp-native-experts


📝 Commits (1)

  • 0c4583e feat(mtp): support native Q4_0 and Q8_0 experts

📊 Changes

4 files changed (+124 additions, -23 deletions)

View changed files

📝 include/strata/core/mtp.hpp (+6 -1)
📝 src/core/mtp.cpp (+70 -11)
📝 tools/mtp_fetch.py (+6 -1)
📝 tools/mtp_rt.py (+42 -10)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/2105 **Author:** [@xszwow](https://github.com/xszwow) **Created:** 10/12/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feature/mtp-native-experts` --- ### 📝 Commits (1) - [`0c4583e`](https://github.com/Niko1221/Strata/commit/0c4583e1ec332f1d798d7c19e3ae98d402e8eedc) feat(mtp): support native Q4_0 and Q8_0 experts ### 📊 Changes **4 files changed** (+124 additions, -23 deletions) <details> <summary>View changed files</summary> 📝 `include/strata/core/mtp.hpp` (+6 -1) 📝 `src/core/mtp.cpp` (+70 -11) 📝 `tools/mtp_fetch.py` (+6 -1) 📝 `tools/mtp_rt.py` (+42 -10) </details> ### 📄 Description ## 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:31:16 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#3860
No description provided.