[PR #4347] [Engine] q36: give the packed Q8_0 decode copies back to the expert slots in the hybrid mode #5018

Open
opened 2026-11-07 16:32:03 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4347
Author: @rynwang
Created: 10/27/2026
Status: 🔄 Open

Base: main ← Head: q36-hybrid-drop-packed


📝 Commits (1)

  • 911fde4 q36: give the packed Q8_0 decode copies back to the expert slots in the hybrid mode

📊 Changes

1 file changed (+21 additions, -13 deletions)

View changed files

📝 src/qwen35/q36_engine.cu (+21 -13)

📄 Description

Problem and result

The q36 hybrid mode keeps 1.78 GiB of packed Q8_0 decode copies in VRAM (place_experts), which speed up the dense
1-4 column GEMVs of the decode. In the hybrid mode the decode waits on the CPU expert pool instead, so that VRAM is
worth more as expert slots: 66 → 92 of 256 per layer at 8192 cells (50 → 76 at 32768). Measured on an RTX 4080
SUPER 16 GB (WSL2, i7-14700KF, engine 0.1.54 at 870aedd, CUDA 12.4, Qwen3.6-35B-A3B-UD-Q4_K_XL, --chunk 4096,
--mtp 0), three alternating runs per arm, same binary:

cells packed copies slots/layer prompt tok/s (ms) decode tok/s
8192 kept 66 1,285 (3,187 / 3,083 / 3,246) 45.6 (45.6 / 44.5 / 45.6)
8192 given back 92 1,361 (2,973 / 3,017 / 3,010) 49.9 (50.5 / 49.9 / 49.5)
32768 kept 50 1,307 43.3
32768 given back 76 1,324 / 1,398 47.6 / 48.5

With the MTP drafts on (--mtp 2, 8192 cells) the same arms were 60.8 vs 63.8 tok/s. So: decode +9% and prompt +6%
at 8K, decode +10% at 32K
, with no text change — the give-back path already exists and reads the GGUF layout, which
the engine documents as bitwise the same outputs.

On the 11 GB GTX 1080 Ti (sm_61, the same model and settings) the copies take almost all of the slots there are:
3 of 256 per layer with them, 30 without, decode 31.1 -> 33.5 tok/s, prompt 6,867 -> 7,171 ms (-4%).

Approach

The existing give-back block (which frees the copies when that makes every expert fit) is extended to the hybrid
mode: free them when fewer than a third of the experts fit with them, i.e. when the placement is far from fitting
and the slots are the scarce thing. A hybrid placement that holds most of the experts keeps the copies, where the
dense GEMVs are what the decode waits on. STRATA_Q36_KEEP_PACKED=1 keeps today's behaviour either way, and the
log line says which of the two reasons applied.

Validation

Passed (RTX 4080 SUPER 16 GB, WSL2 Ubuntu 22.04, driver 581.80, CUDA 12.4, sm_89 + sm_61 build):

  • Same binary, STRATA_Q36_KEEP_PACKED=1 (today's arm) against the new default, three alternating runs per arm at
    8192 cells and three at 32768 cells (table above).
  • The new default logs the packed Q8_0 decode copies (1.78 GiB) given back to the expert slots: the hybrid mode's decode waits on the CPU pool, and the placement is the same as the old code with STRATA_Q8_PACKED=0
    (92 against 92 experts per layer).
  • The model loads and runs on the GTX 1080 Ti (sm_61) with the change; the freed slots are 3 -> 30 per layer there and
    the decode is 31.1 -> 33.5 tok/s (the prompt is 4% slower in that pair, 6,867 -> 7,171 ms).
  • ctest (-DSTRATA_BUILD_TESTS=ON): 201 of 205 in the same build; the 4 failures are environment/build ones
    described in #4335 and none touch place_experts.

Not run:

  • A hybrid placement that holds most experts (e.g. 24 GB with a 26 GB model): the one-third line keeps the copies
    there by construction, but I could not run it.
  • HIP, SYCL, Metal, Windows builds (host-side VRAM placement only).
  • Batched sessions (--batch), where the give-back applies too.

Independent validation (from the comments)

  • RTX 5060 Ti 16 GB, Windows (Thymos2027): 16K-token generation +4.0% (5/5 pairs, 3,323 -> 3,187 ms), with a
    1.6% prefill+generation cost in that arm; with residency frozen, the kept and released placements each match
    main's explicit 63 / 89 placement bitwise, and packed on/off at the same 63 slots gives identical logits. The
    dynamic-run divergence they first saw reproduces on unmodified main (the hybrid mode's slot adaptation).
  • RX 6900 XT 16 GB, gfx1030, ROCm 7.2.4 (schmittcn): the give-back fires with setup's own config, slots 82 -> 108,
    decode +14% chat / +9% agent, prompt unchanged. Above the line (92 and 98 kept slots, forced with a local test
    switch on this PR's head), releasing gave 119 / 124 slots and +13.2% / +12.2% chat, +9.3% agent, prompt -0.2% — so
    the ne/3 line is conservative. This PR keeps it: both validators recommend that until the 90-150 slot range and
    long prompts are measured, and the only long-prompt data (Thymos2027's fixed-history arm) shows a prefill cost there.

Limits

  • The rule is a heuristic: the one-third line is not measured on a large hybrid card, only derived from the two
    contexts measured here and the fact that the copies are meant to speed the dense path.
  • This is a change to a default; STRATA_Q36_KEEP_PACKED=1 restores today's placement.

Related: #4332 (prompt chunk in the same hybrid mode) and #4335 (its PR).


🔄 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/4347 **Author:** [@rynwang](https://github.com/rynwang) **Created:** 10/27/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `q36-hybrid-drop-packed` --- ### 📝 Commits (1) - [`911fde4`](https://github.com/Niko1221/Strata/commit/911fde404a823a82d1d59279e0ce0292e7b435a9) q36: give the packed Q8_0 decode copies back to the expert slots in the hybrid mode ### 📊 Changes **1 file changed** (+21 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `src/qwen35/q36_engine.cu` (+21 -13) </details> ### 📄 Description ## Problem and result The q36 hybrid mode keeps 1.78 GiB of packed Q8_0 decode copies in VRAM (`place_experts`), which speed up the dense 1-4 column GEMVs of the decode. In the hybrid mode the decode waits on the CPU expert pool instead, so that VRAM is worth more as expert slots: **66 → 92 of 256 per layer at 8192 cells** (50 → 76 at 32768). Measured on an RTX 4080 SUPER 16 GB (WSL2, i7-14700KF, engine 0.1.54 at 870aedd, CUDA 12.4, Qwen3.6-35B-A3B-UD-Q4_K_XL, `--chunk 4096`, `--mtp 0`), three alternating runs per arm, same binary: | cells | packed copies | slots/layer | prompt tok/s (ms) | decode tok/s | | --- | --- | --- | --- | --- | | 8192 | kept | 66 | 1,285 (3,187 / 3,083 / 3,246) | 45.6 (45.6 / 44.5 / 45.6) | | 8192 | given back | 92 | **1,361** (2,973 / 3,017 / 3,010) | **49.9** (50.5 / 49.9 / 49.5) | | 32768 | kept | 50 | 1,307 | 43.3 | | 32768 | given back | 76 | **1,324 / 1,398** | **47.6 / 48.5** | With the MTP drafts on (`--mtp 2`, 8192 cells) the same arms were 60.8 vs 63.8 tok/s. So: **decode +9% and prompt +6% at 8K, decode +10% at 32K**, with no text change — the give-back path already exists and reads the GGUF layout, which the engine documents as bitwise the same outputs. On the 11 GB GTX 1080 Ti (sm_61, the same model and settings) the copies take almost all of the slots there are: **3 of 256 per layer with them, 30 without**, decode 31.1 -> 33.5 tok/s, prompt 6,867 -> 7,171 ms (-4%). ## Approach The existing give-back block (which frees the copies when that makes every expert fit) is extended to the hybrid mode: free them when fewer than a third of the experts fit with them, i.e. when the placement is far from fitting and the slots are the scarce thing. A hybrid placement that holds most of the experts keeps the copies, where the dense GEMVs are what the decode waits on. `STRATA_Q36_KEEP_PACKED=1` keeps today's behaviour either way, and the log line says which of the two reasons applied. ## Validation Passed (RTX 4080 SUPER 16 GB, WSL2 Ubuntu 22.04, driver 581.80, CUDA 12.4, sm_89 + sm_61 build): - Same binary, `STRATA_Q36_KEEP_PACKED=1` (today's arm) against the new default, three alternating runs per arm at 8192 cells and three at 32768 cells (table above). - The new default logs `the packed Q8_0 decode copies (1.78 GiB) given back to the expert slots: the hybrid mode's decode waits on the CPU pool`, and the placement is the same as the old code with `STRATA_Q8_PACKED=0` (92 against 92 experts per layer). - The model loads and runs on the GTX 1080 Ti (sm_61) with the change; the freed slots are 3 -> 30 per layer there and the decode is 31.1 -> 33.5 tok/s (the prompt is 4% slower in that pair, 6,867 -> 7,171 ms). - `ctest` (`-DSTRATA_BUILD_TESTS=ON`): 201 of 205 in the same build; the 4 failures are environment/build ones described in #4335 and none touch `place_experts`. Not run: - A hybrid placement that holds most experts (e.g. 24 GB with a 26 GB model): the one-third line keeps the copies there by construction, but I could not run it. - HIP, SYCL, Metal, Windows builds (host-side VRAM placement only). - Batched sessions (`--batch`), where the give-back applies too. ## Independent validation (from the comments) - **RTX 5060 Ti 16 GB, Windows** (Thymos2027): 16K-token generation +4.0% (5/5 pairs, 3,323 -> 3,187 ms), with a 1.6% prefill+generation cost in that arm; with residency frozen, the kept and released placements each match `main`'s explicit 63 / 89 placement bitwise, and packed on/off at the same 63 slots gives identical logits. The dynamic-run divergence they first saw reproduces on unmodified `main` (the hybrid mode's slot adaptation). - **RX 6900 XT 16 GB, gfx1030, ROCm 7.2.4** (schmittcn): the give-back fires with setup's own config, slots 82 -> 108, decode +14% chat / +9% agent, prompt unchanged. Above the line (92 and 98 kept slots, forced with a local test switch on this PR's head), releasing gave 119 / 124 slots and +13.2% / +12.2% chat, +9.3% agent, prompt -0.2% — so the `ne/3` line is conservative. This PR keeps it: both validators recommend that until the 90-150 slot range and long prompts are measured, and the only long-prompt data (Thymos2027's fixed-history arm) shows a prefill cost there. ## Limits - The rule is a heuristic: the one-third line is not measured on a large hybrid card, only derived from the two contexts measured here and the fact that the copies are meant to speed the dense path. - This is a change to a default; `STRATA_Q36_KEEP_PACKED=1` restores today's placement. Related: #4332 (prompt chunk in the same hybrid mode) and #4335 (its PR). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#5018
No description provided.