[PR #1381] [CLOSED] mtp: the draft layer's experts at Q8_0 and BF16, alongside Q2_0 #3418

Closed
opened 2026-11-07 14:41:21 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1381
Author: @gopinath87607
Created: 10/7/2026
Status: ❌ Closed

Base: main ← Head: mtp-q8-bf16-support


📝 Commits (2)

  • 7dfc06e mtp: the draft layer's experts at Q8_0 and BF16, alongside Q2_0
  • c2b91d3 Merge remote-tracking branch 'origin/main' into mtp-q8-bf16-support

📊 Changes

6 files changed (+212 additions, -38 deletions)

View changed files

📝 include/strata/core/mtp.hpp (+12 -2)
📝 src/core/mtp.cpp (+74 -12)
📝 src/kernels/cuda/iq_kernels.cu (+33 -8)
📝 src/kernels/iq_multi_parity.cpp (+21 -4)
📝 tools/mtp_pack.py (+24 -3)
📝 tools/mtp_rt.py (+48 -9)

📄 Description

The MTP draft layer's 512 routed experts were Q2_0 only: a format picked by measured draft acceptance, carrying a relative RMS error of 0.42 on the first experts. Higher precision buys better drafts, hence a higher accept rate, hence speed - never a different output, since the verify window decides every emitted token. This adds Q8_0 (2.49 GiB) and BF16 (4.69 GiB) as opt-in arms and leaves Q2_0 the default.

Which arm a run uses is the runtime directory, not a flag: --mtp rt-q8_0 or --mtp rt-bf16. The selection is an experts.fmt marker that tools/mtp_rt.py writes beside experts.bin, one line <format> <gu_type> <d_type>. No marker means Q2_0, so every rt/ that exists today keeps taking exactly the path it always did.

Engine:

  • iq_kernels.cu: Fmt<30> (BF16 weights against a q8_1 activation), and 30 in STRATA_GU_FMTS / STRATA_D_FMTS / STRATA_MMVQ_FMTS. Q8_0's grouped path at this shape is covered here for the first time as well.
  • native_expert_supported asks embed_type_supported rather than is_iq, which is the set dq_dispatch implements; is_iq is left alone, so nothing that gates on it moves.
  • mtp.cpp: one branch in load(), taken once. The per-expert stride is a function of the chosen layout rather than cpu::BLOB, and the activation buffer is carved at q8_1's 36 bytes per 32 values with Q2_0 reading its 34-byte prefix. A shared drafter now inherits the layout with the buffer it shares: without that a second session would stride a q8_0 buffer by the Q2_0 blob, silently.
  • The size of experts.bin is checked against the layout, because a mismatch does not crash - it drafts from the wrong bytes and is merely accepted less often.

tools/mtp_pack.py gains a lossless bf16 arm (the checkpoint's own 16-bit words, no round trip, so its reconstruction error is exactly zero) and tools/mtp_rt.py writes the per-expert native blob: gate_up[e] then down[e]. Whole-tensor order would hand every expert the head of its neighbour.

Measured on the 4-GPU rig (iq3_s, 256 greedy tokens): BF16 does not fit - the draft layer lands entirely on the last stage's 8 GB card and 4.84 GiB of experts leaves too few cache slots for the prompt path. Q8_0 runs at 48.9 tok/s against Q2_0's 49.5-49.9, with an accept rate indistinguishable within the engine's ~8-point run-to-run spread, at a 2007 -> 1134 slot cost on that card. So this is an arm to measure, not a win to claim.

Title

Issue: Resolves #

Summary

What changed

Extra Notes


🔄 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/1381 **Author:** [@gopinath87607](https://github.com/gopinath87607) **Created:** 10/7/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `mtp-q8-bf16-support` --- ### 📝 Commits (2) - [`7dfc06e`](https://github.com/Niko1221/Strata/commit/7dfc06ec8fe3456727af27bbb71443303d71b284) mtp: the draft layer's experts at Q8_0 and BF16, alongside Q2_0 - [`c2b91d3`](https://github.com/Niko1221/Strata/commit/c2b91d3c66cbced0544b5338af3dce703737b6e4) Merge remote-tracking branch 'origin/main' into mtp-q8-bf16-support ### 📊 Changes **6 files changed** (+212 additions, -38 deletions) <details> <summary>View changed files</summary> 📝 `include/strata/core/mtp.hpp` (+12 -2) 📝 `src/core/mtp.cpp` (+74 -12) 📝 `src/kernels/cuda/iq_kernels.cu` (+33 -8) 📝 `src/kernels/iq_multi_parity.cpp` (+21 -4) 📝 `tools/mtp_pack.py` (+24 -3) 📝 `tools/mtp_rt.py` (+48 -9) </details> ### 📄 Description The MTP draft layer's 512 routed experts were Q2_0 only: a format picked by measured draft acceptance, carrying a relative RMS error of 0.42 on the first experts. Higher precision buys better drafts, hence a higher accept rate, hence speed - never a different output, since the verify window decides every emitted token. This adds Q8_0 (2.49 GiB) and BF16 (4.69 GiB) as opt-in arms and leaves Q2_0 the default. Which arm a run uses is the runtime directory, not a flag: `--mtp rt-q8_0` or `--mtp rt-bf16`. The selection is an `experts.fmt` marker that tools/mtp_rt.py writes beside experts.bin, one line `<format> <gu_type> <d_type>`. No marker means Q2_0, so every `rt/` that exists today keeps taking exactly the path it always did. Engine: * iq_kernels.cu: Fmt<30> (BF16 weights against a q8_1 activation), and 30 in STRATA_GU_FMTS / STRATA_D_FMTS / STRATA_MMVQ_FMTS. Q8_0's grouped path at this shape is covered here for the first time as well. * `native_expert_supported` asks `embed_type_supported` rather than `is_iq`, which is the set dq_dispatch implements; `is_iq` is left alone, so nothing that gates on it moves. * mtp.cpp: one branch in load(), taken once. The per-expert stride is a function of the chosen layout rather than cpu::BLOB, and the activation buffer is carved at q8_1's 36 bytes per 32 values with Q2_0 reading its 34-byte prefix. A shared drafter now inherits the layout with the buffer it shares: without that a second session would stride a q8_0 buffer by the Q2_0 blob, silently. * The size of experts.bin is checked against the layout, because a mismatch does not crash - it drafts from the wrong bytes and is merely accepted less often. tools/mtp_pack.py gains a lossless bf16 arm (the checkpoint's own 16-bit words, no round trip, so its reconstruction error is exactly zero) and tools/mtp_rt.py writes the per-expert native blob: gate_up[e] then down[e]. Whole-tensor order would hand every expert the head of its neighbour. Measured on the 4-GPU rig (iq3_s, 256 greedy tokens): BF16 does not fit - the draft layer lands entirely on the last stage's 8 GB card and 4.84 GiB of experts leaves too few cache slots for the prompt path. Q8_0 runs at 48.9 tok/s against Q2_0's 49.5-49.9, with an accept rate indistinguishable within the engine's ~8-point run-to-run spread, at a 2007 -> 1134 slot cost on that card. So this is an arm to measure, not a win to claim. ## Title <!-- If Applicable, reference the GitHub issue --> Issue: Resolves # ## Summary <!-- Quick Summary of changes --> ## What changed <!-- Specifics on files changed, and what changes were made there --> ## Extra Notes <!-- Any extra notes, delete if there are none --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 14:41:21 +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#3418
No description provided.