[GH-ISSUE #3926] [Engine] qwen35moe on gfx1030: turn STRATA_DENSE_MMQ on in setup's config (prompts +47-67% on an RX 6900 XT, KL 0.0033) #1679

Open
opened 2026-11-04 01:53:08 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @schmittcn on GitHub (Oct 24, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/3926

Area

[Engine] (speed, kernels, models, the server and API)

What do you want to do?

On an RX 6800 / 6900 the Qwen3.6 path (GGUF architecture qwen35moe) runs the prompt's dense GGUF projections as
dequantize + rocBLAS. The opt-in STRATA_DENSE_MMQ=1 (#820) runs them through the int8 MMQ kernels instead. On the
Qwen3.6 path this reads prompts 47-67% faster on an RX 6900 XT, so an agent turn waits about a third less. Only users
who read docs/AMD_HIP.md turn it on today.

Measured

Hardware and software:

  • RX 6900 XT 16 GB (gfx1030), PCIe 4.0 x16, Ryzen 9 5950X, 64 GB, Arch Linux, ROCm 7.2.4.
  • Engine 0.1.48.1, a HIP build of 7ddc17a3. Its local changes are in src/qwen35 and only add options this run
    does not use.

Qwen3.6-35B-A3B UD-Q4_K_XL (the family's default file). Setup's arguments: --native ... --max-context 131072 --prefill auto --mtp 2, f32 KV. Env STRATA_HIP_PROMPT_F16=1. (That switch turned out to have no effect on this path: re-measured without it on stock 9f7d977d, the dumps with and without it are byte-identical and the MMQ gain is the same, see this comment.) tools/strata_bench.py (the community suite), one
server per arm, median over its runs:

default STRATA_DENSE_MMQ=1 change
4K prompt tok/s 1379 (1359-1380) 2301 (2244-2305) +67%
16K prompt tok/s 1091 (1086-1092) 1599 (1597-1599) +47%
agent turn first token, s 7.50 (3.04-13.78) 4.96 (1.90-9.53) -34%
chat decode tok/s 42.2 42.0 none
agent decode tok/s 40.1 40.3 none

Quality. The prompt was 30,050 tokens plus 200 tokens the default generates greedily, teacher-forced in both arms
(strata-q36 --tokens/--force, --dump-full-logits, STRATA_HIP_PROMPT_F16=1 in both). Against the default the
switch gives:

  • mean KL 0.0033;
  • p99 0.029, max 0.050;
  • the same top-1 token in 98.0% of the 201 steps.

As #820 says, greedy text diverges after a while (the q8_1 activation rounding).

A second model. An Ornith-1.5-35B-A3B i1-IQ4_XS (a qwen35moe fine-tune) gave 4K 1375 -> 2419 and 16K 1088 -> 1651
tok/s (the speed run used a modified variant of that model, the KL check the original file), and mean KL 0.0134 / top-1 97.5% on the same
kind of check.

Proposed behavior

install_own_path writes "env": {"STRATA_DENSE_MMQ": "1"} into the config when the card is gfx1030. Nothing else
changes:

  • other cards and the Flash-Next families are not affected;
  • the engine default is not touched;
  • a user can delete the entry.

The branch is https://github.com/schmittcn/Strata/tree/pr/hip-dense-mmq-qwen36: 6 lines in setup.py, a setup test
(gfx1030 gets the entry; gfx1031, gfx1100 and non-HIP do not), and the AMD_HIP.md paragraph. I would open it as a PR
once the scope is agreed.

Tradeoffs and open points

  • Output changes: the output is not bit-identical to today's default. Is a KL of 0.003-0.013 acceptable for a
    +47-67% prompt speed on this card?
  • gfx1031: only gfx1030 is proposed, because gfx1031 (RX 6700 XT) is not measured.
  • The #884 hang: that gfx1030 hang workaround was seen with the MMQ prompt path and adaptive swaps on Flash-Next. I
    did not check whether the q36 path's expert swaps carry the same risk. I saw no hang in a day of use with the switch
    on, plus the benchmark runs.

What do you do today instead?

Set "STRATA_DENSE_MMQ": "1" in the config's "env" by hand.

Originally created by @schmittcn on GitHub (Oct 24, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/3926 ### Area [Engine] (speed, kernels, models, the server and API) ### What do you want to do? On an RX 6800 / 6900 the Qwen3.6 path (GGUF architecture qwen35moe) runs the prompt's dense GGUF projections as dequantize + rocBLAS. The opt-in `STRATA_DENSE_MMQ=1` (#820) runs them through the int8 MMQ kernels instead. On the Qwen3.6 path this reads prompts 47-67% faster on an RX 6900 XT, so an agent turn waits about a third less. Only users who read docs/AMD_HIP.md turn it on today. #### Measured Hardware and software: - RX 6900 XT 16 GB (gfx1030), PCIe 4.0 x16, Ryzen 9 5950X, 64 GB, Arch Linux, ROCm 7.2.4. - Engine 0.1.48.1, a HIP build of `7ddc17a3`. Its local changes are in `src/qwen35` and only add options this run does not use. **Qwen3.6-35B-A3B UD-Q4_K_XL (the family's default file).** Setup's arguments: `--native ... --max-context 131072 --prefill auto --mtp 2`, f32 KV. Env `STRATA_HIP_PROMPT_F16=1`. (That switch turned out to have no effect on this path: re-measured without it on stock `9f7d977d`, the dumps with and without it are byte-identical and the MMQ gain is the same, see [this comment](https://github.com/Niko1221/Strata/issues/3926#issuecomment-6680982339).) `tools/strata_bench.py` (the community suite), one server per arm, median over its runs: | | default | `STRATA_DENSE_MMQ=1` | change | | --- | ---: | ---: | ---: | | 4K prompt tok/s | 1379 (1359-1380) | 2301 (2244-2305) | +67% | | 16K prompt tok/s | 1091 (1086-1092) | 1599 (1597-1599) | +47% | | agent turn first token, s | 7.50 (3.04-13.78) | 4.96 (1.90-9.53) | -34% | | chat decode tok/s | 42.2 | 42.0 | none | | agent decode tok/s | 40.1 | 40.3 | none | **Quality.** The prompt was 30,050 tokens plus 200 tokens the default generates greedily, teacher-forced in both arms (`strata-q36 --tokens/--force`, `--dump-full-logits`, `STRATA_HIP_PROMPT_F16=1` in both). Against the default the switch gives: - mean KL 0.0033; - p99 0.029, max 0.050; - the same top-1 token in 98.0% of the 201 steps. As #820 says, greedy text diverges after a while (the q8_1 activation rounding). **A second model.** An Ornith-1.5-35B-A3B i1-IQ4_XS (a qwen35moe fine-tune) gave 4K 1375 -> 2419 and 16K 1088 -> 1651 tok/s (the speed run used a modified variant of that model, the KL check the original file), and mean KL 0.0134 / top-1 97.5% on the same kind of check. #### Proposed behavior `install_own_path` writes `"env": {"STRATA_DENSE_MMQ": "1"}` into the config when the card is gfx1030. Nothing else changes: - other cards and the Flash-Next families are not affected; - the engine default is not touched; - a user can delete the entry. The branch is https://github.com/schmittcn/Strata/tree/pr/hip-dense-mmq-qwen36: 6 lines in `setup.py`, a setup test (gfx1030 gets the entry; gfx1031, gfx1100 and non-HIP do not), and the AMD_HIP.md paragraph. I would open it as a PR once the scope is agreed. #### Tradeoffs and open points - **Output changes:** the output is not bit-identical to today's default. Is a KL of 0.003-0.013 acceptable for a +47-67% prompt speed on this card? - **gfx1031:** only gfx1030 is proposed, because gfx1031 (RX 6700 XT) is not measured. - **The #884 hang:** that gfx1030 hang workaround was seen with the MMQ prompt path and adaptive swaps on Flash-Next. I did not check whether the q36 path's expert swaps carry the same risk. I saw no hang in a day of use with the switch on, plus the benchmark runs. ### What do you do today instead? Set `"STRATA_DENSE_MMQ": "1"` in the config's `"env"` by hand.
Author
Owner

@mkw432 commented on GitHub (Nov 3, 2026):

Confirmation on a different RDNA2 card (RX 6700 XT 12 GB, gfx1031), engine 0.1.56, built from source.

MMQ alone was not enough. With STRATA_DENSE_MMQ=1 and --prefill 512: 4K prompt 710.4 → 713.8 tok/s (+0.5%), 16K 606.6 → 696.2 (+14.8%).

The combination reproduces the claim. Same model and context with STRATA_HIP_PROMPT_F16=1 and --prefill auto:

default MMQ + F16 + auto
4K prompt tok/s 710.4 1473.5 (+107%)
16K prompt tok/s 606.6 1086.5 (+79%)
4K first token 5.66 s 2.73 s
16K first token 26.48 s 14.79 s
agent turn first token 15.21 s 7.43 s
decode tok/s 41.3 41.3
agent decode tok/s 36.2 35.8

So the gain is in the combination, not in MMQ at a fixed prefill chunk.

Configuration: Qwen3.6-35B-A3B UD-Q4_K_XL, --max-context 24576 --mtp 0, FP32 KV, --pool-workers 5 --expert-vram 3.25, RX 6700 XT 12 GB / Ryzen 5 5600X / 31 GiB RAM, in-kernel amdgpu, one engine at a time.

Quality: as you noted, the switch changes outputs (q8_1 activation rounding). On four held-out coding tasks (single-shot generation, hidden checks executed in a bwrap sandbox) this configuration passed 4/4, including 8/8 checks on the hard one. Small sample, so I would keep it opt-in, but there were no failures.

Suggestion: this is a large enough prompt gain on gfx103x that setup or strata launch could offer it with a one-line quality note, rather than leaving it to docs-only discovery.

<!-- gh-comment-id:6618106695 --> @mkw432 commented on GitHub (Nov 3, 2026): Confirmation on a different RDNA2 card (RX 6700 XT 12 GB, gfx1031), engine 0.1.56, built from source. **MMQ alone was not enough.** With `STRATA_DENSE_MMQ=1` and `--prefill 512`: 4K prompt 710.4 → 713.8 tok/s (+0.5%), 16K 606.6 → 696.2 (+14.8%). **The combination reproduces the claim.** Same model and context with `STRATA_HIP_PROMPT_F16=1` and `--prefill auto`: | | default | MMQ + F16 + auto | |---|---:|---:| | 4K prompt tok/s | 710.4 | **1473.5 (+107%)** | | 16K prompt tok/s | 606.6 | **1086.5 (+79%)** | | 4K first token | 5.66 s | 2.73 s | | 16K first token | 26.48 s | 14.79 s | | agent turn first token | 15.21 s | 7.43 s | | decode tok/s | 41.3 | 41.3 | | agent decode tok/s | 36.2 | 35.8 | So the gain is in the combination, not in MMQ at a fixed prefill chunk. **Configuration:** Qwen3.6-35B-A3B UD-Q4_K_XL, `--max-context 24576 --mtp 0`, FP32 KV, `--pool-workers 5 --expert-vram 3.25`, RX 6700 XT 12 GB / Ryzen 5 5600X / 31 GiB RAM, in-kernel amdgpu, one engine at a time. **Quality:** as you noted, the switch changes outputs (q8_1 activation rounding). On four held-out coding tasks (single-shot generation, hidden checks executed in a bwrap sandbox) this configuration passed **4/4**, including 8/8 checks on the hard one. Small sample, so I would keep it opt-in, but there were no failures. Suggestion: this is a large enough prompt gain on gfx103x that setup or `strata launch` could offer it with a one-line quality note, rather than leaving it to docs-only discovery.
Author
Owner

@schmittcn commented on GitHub (Nov 6, 2026):

Thanks for the gfx1031 numbers. They made me check whether my measurement depended on STRATA_HIP_PROMPT_F16=1, which I had set in both arms. It doesn't: that switch has no effect on the Qwen3.6 path.

Why. AMD_HIP.md, RDNA2 explains the gfx1030 problem: rocBLAS has tuned kernels only for FP16-in / FP16-out, and FP16-in / FP32-out runs generic kernels about 6.6x slower. STRATA_HIP_PROMPT_F16=1 moves the generic prefill path onto the tuned route (f16_io_, set in src/prefill/prefill.cpp). The q36 path never sets it: its dense projections go Gemm::native → dequantize to FP16 → Gemm::f16, FP32 out, i.e. the slow kernels. So on qwen35moe neither the F16 switch nor the rocBLAS table helps, and the engine log shows no F16 line (not even the gfx103x tip). STRATA_DENSE_MMQ=1 skips rocBLAS for these products, which is why it is the lever here. #820 measured the same shapes about 7x faster through MMQ on RDNA2.

Re-measured on stock upstream/main (9f7d977d), RX 6900 XT, same file and setup args (131072, --prefill auto, --mtp 2, f32 KV), four arms:

default MMQ F16 MMQ + F16
4K prompt tok/s 1383 2313 (+67%) 1375 2304
16K prompt tok/s 1093 1603 (+47%) 1087 1601
agent turn first token, s 7.33 4.92 (−33%) 7.35 4.92
decode tok/s 41.9 42.0 41.6 41.7

Teacher-forced full-logit dumps (29,750-token prompt + 200 tokens): F16 vs default and MMQ+F16 vs MMQ are byte-identical. MMQ vs default: mean KL 0.0029, p99 0.029, max 0.055, top-1 99.0%.

So the gain is MMQ alone, and the proposal (only STRATA_DENSE_MMQ=1) is the measured configuration. On your card I'd expect the gap between your two runs to come from --prefill 512 vs auto: with 512-token chunks the dense GEMMs are small, so MMQ has little to win. Setup already writes --prefill auto. gfx1031 should have the same rocBLAS limitation as gfx1030. If you have the time, MMQ on/off with --prefill auto (F16 doesn't matter) would show whether to include it.

Other cards stay out of the proposal on purpose: RDNA3 and RDNA4 have hipBLASLt tables and WMMA, so their dequantize + BLAS route isn't the slow path, and I have no measurement there.

Developed with an AI coding assistant.

<!-- gh-comment-id:6680982339 --> @schmittcn commented on GitHub (Nov 6, 2026): Thanks for the gfx1031 numbers. They made me check whether my measurement depended on `STRATA_HIP_PROMPT_F16=1`, which I had set in both arms. It doesn't: that switch has no effect on the Qwen3.6 path. **Why.** [AMD_HIP.md, RDNA2](https://github.com/Niko1221/Strata/blob/9f7d977d/docs/AMD_HIP.md#rdna2-gfx1030) explains the gfx1030 problem: rocBLAS has tuned kernels only for FP16-in / FP16-out, and FP16-in / FP32-out runs generic kernels about 6.6x slower. `STRATA_HIP_PROMPT_F16=1` moves the generic prefill path onto the tuned route (`f16_io_`, set in `src/prefill/prefill.cpp`). The q36 path never sets it: its dense projections go `Gemm::native` → dequantize to FP16 → `Gemm::f16`, FP32 out, i.e. the slow kernels. So on qwen35moe neither the F16 switch nor the rocBLAS table helps, and the engine log shows no F16 line (not even the gfx103x tip). `STRATA_DENSE_MMQ=1` skips rocBLAS for these products, which is why it is the lever here. #820 measured the same shapes about 7x faster through MMQ on RDNA2. **Re-measured** on stock `upstream/main` (`9f7d977d`), RX 6900 XT, same file and setup args (131072, `--prefill auto`, `--mtp 2`, f32 KV), four arms: | | default | MMQ | F16 | MMQ + F16 | |---|---:|---:|---:|---:| | 4K prompt tok/s | 1383 | 2313 (+67%) | 1375 | 2304 | | 16K prompt tok/s | 1093 | 1603 (+47%) | 1087 | 1601 | | agent turn first token, s | 7.33 | 4.92 (−33%) | 7.35 | 4.92 | | decode tok/s | 41.9 | 42.0 | 41.6 | 41.7 | Teacher-forced full-logit dumps (29,750-token prompt + 200 tokens): F16 vs default and MMQ+F16 vs MMQ are **byte-identical**. MMQ vs default: mean KL 0.0029, p99 0.029, max 0.055, top-1 99.0%. So the gain is MMQ alone, and the proposal (only `STRATA_DENSE_MMQ=1`) is the measured configuration. On your card I'd expect the gap between your two runs to come from `--prefill 512` vs `auto`: with 512-token chunks the dense GEMMs are small, so MMQ has little to win. Setup already writes `--prefill auto`. gfx1031 should have the same rocBLAS limitation as gfx1030. If you have the time, MMQ on/off with `--prefill auto` (F16 doesn't matter) would show whether to include it. Other cards stay out of the proposal on purpose: RDNA3 and RDNA4 have hipBLASLt tables and WMMA, so their dequantize + BLAS route isn't the slow path, and I have no measurement there. *Developed with an AI coding assistant.*
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#1679
No description provided.