[GH-ISSUE #4157] [Engine] gfx906 prefill: native MMVQ for the dense projections of small prompt chunks #1820

Closed
opened 2026-11-04 01:54:21 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @KevinX8 on GitHub (Oct 25, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4157

Problem: on gfx906 (MI50, no matrix cores) an agent turn that adds 100-500 tokens to a cached conversation spends most of its batched prompt pass in the dense projections. Swift 1.5 GSQ-RCO IQ3_S, STRATA_PREFILL_TIMING=1, a 170-token chunk: about 930 of 1,730 ms GPU time in hc read / gdn / qsa proj / gdn out proj. For each quantized projection the prompt path dequantizes the GGUF blocks to FP16 into the scratch and runs a rocBLAS GEMM; at small T neither is close to what the card can do.

Proposed behavior (opt-in, no default change): STRATA_PF_MMVQ=1 makes Gemm::native take chunks of up to STRATA_PF_MMVQ_MAX_T tokens (default 256) through decode's existing native MMVQ on the GGUF blocks, 8 token columns per call (activations FP16 -> FP32 -> Q8_1, as decode does). It declines (old path, nothing written) for beta != 0, strided X or Y, a type native_mmvq_supported() rejects, or K not a whole number of the type's blocks. One fixed 16 MiB workspace per Gemm, allocated at first use.

Tradeoffs:

  • The small-chunk result now depends on the chunk size (Q8_1 activations below the threshold, FP16 above).
  • The flag is process-wide: it also reaches the other users of Gemm::native (the q36 engine for T 9..256, the MTP draft Q8_0 projections, the PLE key). Only Qwen3.8-Flash-Next was quality-checked.
  • Measured on one card class.

Numbers (MI50, Swift 1.5, --kv int8, 20k cached context, read wall time per turn, two passes; both columns with STRATA_HIP_PROMPT_F16=1, STRATA_PREFILL_CPU_SHARE=auto, STRATA_PREFILL_CPU_SHARE_MAX=4096, --short-read 128):

fresh tokens without STRATA_PF_MMVQ=1 (<= 256)
164-166 1.88 / 1.78 s 1.59 / 1.54 s
469-484 2.79 / 2.78 s 2.79 / 2.78 s (above the threshold, unchanged)
1,293-1,504 4.49 / 4.85 s 4.50 / 4.86 s

Thresholds of 512 and up slow ~480-token chunks (3.06-3.24 s); 2048 slows ~1,300-token chunks (6.73-7.61 s).

Quality (a 2,048-token prefix read by the batched path, then the code and agent segments of data/quant_quality/v1 scored through the decode windows, top-64 KL against the unchanged build): with the threshold raised to 512 so the harness's 512-token chunks take the path, mean KL 0.065, top-1 93.4%, PPL 2.869 against 2.860. The unchanged build with only --prefill 768 / 1024 instead of 512 scores 0.052 / 0.052 (PPL -2.2% / -4.1%), so this sits at the level of a pure reordering of the prefix's sums.

Asking: is an opt-in, gfx906-measured switch in Gemm::native acceptable, and should it stay gfx906-only? A draft PR with the change and a parity test is ready (linked below once opened).

Originally created by @KevinX8 on GitHub (Oct 25, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4157 **Problem:** on gfx906 (MI50, no matrix cores) an agent turn that adds 100-500 tokens to a cached conversation spends most of its batched prompt pass in the dense projections. Swift 1.5 GSQ-RCO IQ3_S, `STRATA_PREFILL_TIMING=1`, a 170-token chunk: about 930 of 1,730 ms GPU time in hc read / gdn / qsa proj / gdn out proj. For each quantized projection the prompt path dequantizes the GGUF blocks to FP16 into the scratch and runs a rocBLAS GEMM; at small T neither is close to what the card can do. **Proposed behavior (opt-in, no default change):** `STRATA_PF_MMVQ=1` makes `Gemm::native` take chunks of up to `STRATA_PF_MMVQ_MAX_T` tokens (default 256) through decode's existing native MMVQ on the GGUF blocks, 8 token columns per call (activations FP16 -> FP32 -> Q8_1, as decode does). It declines (old path, nothing written) for beta != 0, strided X or Y, a type `native_mmvq_supported()` rejects, or K not a whole number of the type's blocks. One fixed 16 MiB workspace per `Gemm`, allocated at first use. **Tradeoffs:** - The small-chunk result now depends on the chunk size (Q8_1 activations below the threshold, FP16 above). - The flag is process-wide: it also reaches the other users of `Gemm::native` (the q36 engine for T 9..256, the MTP draft Q8_0 projections, the PLE key). Only Qwen3.8-Flash-Next was quality-checked. - Measured on one card class. **Numbers** (MI50, Swift 1.5, `--kv int8`, 20k cached context, read wall time per turn, two passes; both columns with `STRATA_HIP_PROMPT_F16=1`, `STRATA_PREFILL_CPU_SHARE=auto`, `STRATA_PREFILL_CPU_SHARE_MAX=4096`, `--short-read 128`): | fresh tokens | without | `STRATA_PF_MMVQ=1` (<= 256) | |---|---|---| | 164-166 | 1.88 / 1.78 s | 1.59 / 1.54 s | | 469-484 | 2.79 / 2.78 s | 2.79 / 2.78 s (above the threshold, unchanged) | | 1,293-1,504 | 4.49 / 4.85 s | 4.50 / 4.86 s | Thresholds of 512 and up slow ~480-token chunks (3.06-3.24 s); 2048 slows ~1,300-token chunks (6.73-7.61 s). Quality (a 2,048-token prefix read by the batched path, then the `code` and `agent` segments of `data/quant_quality/v1` scored through the decode windows, top-64 KL against the unchanged build): with the threshold raised to 512 so the harness's 512-token chunks take the path, mean KL 0.065, top-1 93.4%, PPL 2.869 against 2.860. The unchanged build with only `--prefill 768` / `1024` instead of 512 scores 0.052 / 0.052 (PPL -2.2% / -4.1%), so this sits at the level of a pure reordering of the prefix's sums. **Asking:** is an opt-in, gfx906-measured switch in `Gemm::native` acceptable, and should it stay gfx906-only? A draft PR with the change and a parity test is ready (linked below once opened).
Author
Owner

@KevinX8 commented on GitHub (Oct 25, 2026):

Draft PR with the change and the parity test: https://github.com/Niko1221/Strata/pull/4158 (stacked on #4156, which the gfx906 build needs). Measurements of the related existing switches: https://github.com/Niko1221/Strata/issues/4159

<!-- gh-comment-id:6404025916 --> @KevinX8 commented on GitHub (Oct 25, 2026): Draft PR with the change and the parity test: https://github.com/Niko1221/Strata/pull/4158 (stacked on #4156, which the gfx906 build needs). Measurements of the related existing switches: https://github.com/Niko1221/Strata/issues/4159
Author
Owner

@KevinX8 commented on GitHub (Oct 28, 2026):

Update: #4158 is rebased onto v0.2.7.1 and no longer carries the stream-priority shim; the gfx906 build needs #3986 for that. Rebuilt with #3986 applied, pf_mmvq_parity passes again (rel RMS 5.7e-3 to 6.1e-3).

<!-- gh-comment-id:6465886051 --> @KevinX8 commented on GitHub (Oct 28, 2026): Update: #4158 is rebased onto v0.2.7.1 and no longer carries the stream-priority shim; the gfx906 build needs #3986 for that. Rebuilt with #3986 applied, `pf_mmvq_parity` passes again (rel RMS 5.7e-3 to 6.1e-3).
Author
Owner

@Niko1221 commented on GitHub (Nov 5, 2026):

Thanks for taking the time to report this.

Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected.

To reopen it takes about two minutes:

  1. Re-test on 0.2.11. It may already be fixed. Write down what you see.
  2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other].
  3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system.
  4. Comment /reopen. A check runs and either reopens the issue or lists what is still missing.

The rules are in CONTRIBUTING.md.

<!-- gh-comment-id:6660077655 --> @Niko1221 commented on GitHub (Nov 5, 2026): Thanks for taking the time to report this. Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected. To reopen it takes about two minutes: 1. Re-test on 0.2.11. It may already be fixed. Write down what you see. 2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]. 3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system. 4. Comment `/reopen`. A check runs and either reopens the issue or lists what is still missing. The rules are in [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md).
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#1820
No description provided.