[GH-ISSUE #5162] [Engine] RX 9070: prompts slow down after the first request; DEBUG_HIP_DYNAMIC_QUEUES=0 fixes it #3073

Open
opened 2026-11-07 14:37:50 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @mhhayashi on GitHub (Nov 3, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/5162

Area

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

Desktop app, Terminal or source?

Source (START-HERE.bat, setup.sh or a build)

AI assistance: Claude Code (Claude Opus 5.5) ran the measurements and the trace and drafted this report under my direction; I reviewed it before posting. The numbers are from runs on my machine.

What happened

On a single RX 9070 (RDNA4, gfx1201), prompts after the first one of a server start usually read 10-25% slower, and stay slow. With DEBUG_HIP_DYNAMIC_QUEUES=0 in the engine's environment they stay fast and decode is unchanged (in rare cases the first prompt itself was slow, and every later one fast).

Measured on 0.2.10 (Swift 1.5 IQ4_XS, MTP, ~6,100-token prompts). Prompt speed in tok/s, one row per fresh server start; each start reads 3 prompts, decodes 100 tokens, then reads 2 more prompts. Slow prompts in bold:

Setting Start Prompt 1 Prompt 2 Prompt 3 Prompt 4 Prompt 5
runtime default 1 1,099 1,106 1,107 decode 868 865
2 1,098 862 858 decode 865 863
3 1,095 1,099 1,098 decode 866 863
DEBUG_HIP_DYNAMIC_QUEUES=0 1 1,092 1,099 1,101 decode 1,111 1,105
2 1,088 1,102 1,101 decode 1,111 1,105
3 1,093 1,100 1,100 decode 1,113 1,107

Slow prompts: 8 of 15 with the runtime default, 0 of 15 with DEBUG_HIP_DYNAMIC_QUEUES=0.

Same on 0.2.7.1 (20K prompts ~1,460 fast vs ~1,100 slow; with the setting, 25 of 25 ~6K prompts fast over 5 starts), and decode speed is unchanged with it. With a real prompt (16.5K tokens of C source, 0.2.10, 2 starts each) the drop is smaller: ~1,760 tok/s for the first prompt, then ~1,570 (one 1,423) without the setting; 1,756-1,795 throughout with it.

GPU trace (rocprofv3, a fast and a slow 20K prompt on one server, 0.2.7.1):

fast slow
wall 13.3 s 17.5 s
kernel busy time 7.37 s 7.31 s
expert copies (H2D) busy time 8.90 s 8.84 s
copies overlapping kernels 3.6 s 0.00 s

The host submits the copies tens of milliseconds early in both, so they are held on the GPU. In STRATA_PREFILL_TIMING=1 this idle time shows up as dequant (~1.4 -> ~5.5 s).

Did not fix it (tested on 0.2.7.1): GPU_MAX_HW_QUEUES=16, HSA_ENABLE_SDMA=0, ROC_CPU_WAIT_FOR_SIGNAL=0, ROC_SIGNAL_POOL_SIZE=4096, STRATA_PREFILL_ISSUER=0, STRATA_PREFILL_GROUP_GATHER=0, --adapt-swaps 0, --no-prefill-borrow, TheRock 7.14.0a20260612, and a high-priority prompt copy stream (local patch). STRATA_HIP_QUEUE_PRIME=nnnh avoids it (15 of 15 fast), but in one decode benchmark its first four requests after a start ran ~25% slower.

Related: #2305 (R9700: MTP draft fast or slow per start, streams sharing a hardware queue), #3480 (RX 9060 XT: prompt speed and the queue priming), #5001 (RX 9060 XT: prompt time turning into copy waits; possibly the same thing, not checked).

Not tested: other cards (including gfx1200), other models or quantizations, Windows, the desktop app, DFlash2, more than one card.

Suggestion. It would help if others with RDNA4 cards ran the repro below with and without DEBUG_HIP_DYNAMIC_QUEUES=0. If it holds there, set it for the engine on gfx12 by default, like the queue priming. Other repos set it too, mostly for hangs (ROCm's JAX image, Dockerfile.base-therock-ubu24) or stream overlap (vLLM's MiniMax-M3.1-Flash recipe, on its dual-batch-overlap configs); ROCm/rocm-systems#9249 fixed a deadlock in the runtime's dynamic queue selection, where a stream was put on a queue that was already blocked.

Smallest steps or command that reproduce it

  1. Start the server from source on an RX 9070 with Swift 1.5 IQ4_XS.
  2. Run the script below (standard library only): it sends three prompts of ~6,000 unique tokens (fresh random words, max_tokens: 1), one request that decodes 100 tokens, then two more prompts, and prints each prompt's speed. On most starts one or more of the later prompts are 10-25% slower than the first. --text FILE sends a file of your own instead.
  3. Restart with DEBUG_HIP_DYNAMIC_QUEUES=0 and run it again: all prompts run at about the first prompt's speed.
strata-issue-repro.py
#!/usr/bin/env python3
"""Prompt speed before and after a decode, against a running Strata server (standard library only).

Sends 3 prompts of ~6,000 unique tokens, one request that decodes 100 tokens, then 2 more prompts, and prints each
prompt's speed. Start a fresh server first; run it once with DEBUG_HIP_DYNAMIC_QUEUES=0 in the engine's environment
and once without.

    python3 strata-issue-repro.py [--url http://127.0.0.1:8080] [--words 2100] [--text FILE]
"""
import argparse
import json
import random
import time
import urllib.request

VOCAB = ["alpha", "beta", "gamma", "delta", "kernel", "tensor", "expert", "router", "cache", "memory"]


def ask(url, text, max_tokens):
    body = json.dumps({"model": "m", "messages": [{"role": "user", "content": text}],
                       "max_tokens": max_tokens, "temperature": 0, "stream": False}).encode()
    request = urllib.request.Request(url + "/v1/chat/completions", body, {"Content-Type": "application/json"})
    start = time.time()
    reply = json.load(urllib.request.urlopen(request, timeout=1800))
    return reply["usage"], time.time() - start


def prompt(n_words, text=None):
    if text is not None:   # the time stamp comes first, so the server reuses nothing from the previous request
        return f"[{time.time()}] Review this code and list its three biggest problems.\n\n{text}"
    rng = random.Random(time.time_ns())   # a fresh seed and a time stamp: no two prompts share a prefix
    words = " ".join(rng.choice(VOCAB) + str(i % 97) for i in range(n_words))
    return f"[{time.time()}] {words}\nSummarize the above in one word."


def main():
    parser = argparse.ArgumentParser(description=__doc__.split("\n")[0])
    parser.add_argument("--url", default="http://127.0.0.1:8080")
    parser.add_argument("--words", type=int, default=2100, help="words per prompt (2100 is ~6,100 tokens)")
    parser.add_argument("--text", metavar="FILE", help="send this file (e.g. source code) as each prompt instead of random words")
    args = parser.parse_args()
    text = open(args.text, encoding="utf-8").read() if args.text else None
    speeds = []
    for step in ("prompt", "prompt", "prompt", "decode", "prompt", "prompt"):
        if step == "decode":
            usage, seconds = ask(args.url, f"[{time.time()}] Explain how a CPU cache works.", 100)
            print(f"decode   {usage['completion_tokens']:>6} tokens in {seconds:5.1f} s")
            continue
        usage, seconds = ask(args.url, prompt(args.words, text), 1)
        speeds.append(usage["prompt_tokens"] / seconds)
        print(f"prompt {len(speeds)} {usage['prompt_tokens']:>6} tokens in {seconds:5.1f} s  {speeds[-1]:6.0f} tok/s")
    slow = [i + 1 for i, s in enumerate(speeds) if s < 0.9 * max(speeds)]
    print(f"slow prompts (more than 10% below the fastest): {slow if slow else 'none'}")


if __name__ == "__main__":
    main()

Reproduction status

Reproduced locally

Strata version

Strata 0.2.10 (tag v0.2.10, ffa80d73) · engine 0.1.56, built from source for gfx1201 (also reproduced on 0.2.7.1)

Graphics card, memory and system

RX 9070 16 GB (gfx1201) on PCIe 3.0 x16 · Xeon W-2140B · 256 GB RAM · Fedora 44 (kernel 7.2.5) · ROCm from TheRock wheels 7.13.0a20260422 (gfx120X)

Model, size and settings

Swift 1.5 (Qwen3.8-Flash-Next fine-tune) IQ4_XS, native pack · --max-context 262144 --kv int8 --kv-resident 32768 --expert-cache auto --prefill auto --vram-reserve-mib 448 · MTP (--spec 3 --spec-min-p 0.5) · STRATA_ROUTE_TAIL_SKIP=8 STRATA_ROUTE_PRIOR=0.5 STRATA_SH_STREAM=1 STRATA_PREFILL_EQUAL=1 · power cap 180 W · pictures off

Logs

STRATA_PREFILL_TIMING=1, 0.2.7.1, fast then slow 20K prompt on one server (trimmed):

strata prefill timing: 20305 tokens, GPU timeline 13256 ms, wall 13325 ms, ... wait copy 4276 (32.3%) dequant 1378 (10.4%) gemm gate/up 1312 (9.9%) gemm down 843 (6.4%) ...
strata serve: prompt 20310 tokens = 0 reused + 20310 read in 13809 ms (1470.8 tok/s), 1 generated in 60 ms
strata prefill timing: 20305 tokens, GPU timeline 17890 ms, wall 17954 ms, ... wait copy 3684 (20.6%) dequant 5495 (30.7%) gemm gate/up 1686 (9.4%) gemm down 1059 (5.9%) ...
strata serve: prompt 20310 tokens = 0 reused + 20310 read in 18635 ms (1089.9 tok/s), 1 generated in 27 ms

Note: this looks like the "R9700 / RX 9000 bimodal prompt speed" described above prime_hw_queues() in src/program/generate.cpp, but the queue priming doesn't prevent it here: the switch to slow happens mid-session.

Originally created by @mhhayashi on GitHub (Nov 3, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/5162 ### Area [Engine] (speed, kernels, models, the server and API) ### Desktop app, Terminal or source? Source (START-HERE.bat, setup.sh or a build) > AI assistance: Claude Code (Claude Opus 5.5) ran the measurements and the trace and drafted this report under my direction; I reviewed it before posting. The numbers are from runs on my machine. ### What happened On a single RX 9070 (RDNA4, gfx1201), prompts after the first one of a server start usually read 10-25% slower, and stay slow. With `DEBUG_HIP_DYNAMIC_QUEUES=0` in the engine's environment they stay fast and decode is unchanged (in rare cases the first prompt itself was slow, and every later one fast). Measured on 0.2.10 (Swift 1.5 IQ4_XS, MTP, ~6,100-token prompts). Prompt speed in tok/s, one row per fresh server start; each start reads 3 prompts, decodes 100 tokens, then reads 2 more prompts. Slow prompts in bold: | Setting | Start | Prompt 1 | Prompt 2 | Prompt 3 | | Prompt 4 | Prompt 5 | |---|---|---|---|---|---|---|---| | runtime default | 1 | 1,099 | 1,106 | 1,107 | *decode* | **868** | **865** | | | 2 | 1,098 | **862** | **858** | *decode* | **865** | **863** | | | 3 | 1,095 | 1,099 | 1,098 | *decode* | **866** | **863** | | `DEBUG_HIP_DYNAMIC_QUEUES=0` | 1 | 1,092 | 1,099 | 1,101 | *decode* | 1,111 | 1,105 | | | 2 | 1,088 | 1,102 | 1,101 | *decode* | 1,111 | 1,105 | | | 3 | 1,093 | 1,100 | 1,100 | *decode* | 1,113 | 1,107 | Slow prompts: 8 of 15 with the runtime default, 0 of 15 with `DEBUG_HIP_DYNAMIC_QUEUES=0`. Same on 0.2.7.1 (20K prompts ~1,460 fast vs ~1,100 slow; with the setting, 25 of 25 ~6K prompts fast over 5 starts), and decode speed is unchanged with it. With a real prompt (16.5K tokens of C source, 0.2.10, 2 starts each) the drop is smaller: ~1,760 tok/s for the first prompt, then ~1,570 (one 1,423) without the setting; 1,756-1,795 throughout with it. **GPU trace** (`rocprofv3`, a fast and a slow 20K prompt on one server, 0.2.7.1): | | fast | slow | |---|---|---| | wall | 13.3 s | 17.5 s | | kernel busy time | 7.37 s | 7.31 s | | expert copies (H2D) busy time | 8.90 s | 8.84 s | | copies overlapping kernels | 3.6 s | **0.00 s** | The host submits the copies tens of milliseconds early in both, so they are held on the GPU. In `STRATA_PREFILL_TIMING=1` this idle time shows up as `dequant` (~1.4 -> ~5.5 s). **Did not fix it** (tested on 0.2.7.1): `GPU_MAX_HW_QUEUES=16`, `HSA_ENABLE_SDMA=0`, `ROC_CPU_WAIT_FOR_SIGNAL=0`, `ROC_SIGNAL_POOL_SIZE=4096`, `STRATA_PREFILL_ISSUER=0`, `STRATA_PREFILL_GROUP_GATHER=0`, `--adapt-swaps 0`, `--no-prefill-borrow`, TheRock 7.14.0a20260612, and a high-priority prompt copy stream (local patch). `STRATA_HIP_QUEUE_PRIME=nnnh` avoids it (15 of 15 fast), but in one decode benchmark its first four requests after a start ran ~25% slower. **Related:** #2305 (R9700: MTP draft fast or slow per start, streams sharing a hardware queue), #3480 (RX 9060 XT: prompt speed and the queue priming), #5001 (RX 9060 XT: prompt time turning into copy waits; possibly the same thing, not checked). **Not tested:** other cards (including gfx1200), other models or quantizations, Windows, the desktop app, DFlash2, more than one card. **Suggestion.** It would help if others with RDNA4 cards ran the repro below with and without `DEBUG_HIP_DYNAMIC_QUEUES=0`. If it holds there, set it for the engine on gfx12 by default, like the queue priming. Other repos set it too, mostly for hangs (ROCm's JAX image, [`Dockerfile.base-therock-ubu24`](https://github.com/ROCm/rocm-jax/blob/rocm-jax-infra/docker/Dockerfile.base-therock-ubu24)) or stream overlap (vLLM's [MiniMax-M3.1-Flash recipe](https://github.com/vllm-project/vllm/blob/main/recipes/models/MiniMaxAI/MiniMax-M3.1-Flash.yaml), on its dual-batch-overlap configs); [ROCm/rocm-systems#9249](https://github.com/ROCm/rocm-systems/pull/9249) fixed a deadlock in the runtime's dynamic queue selection, where a stream was put on a queue that was already blocked. ### Smallest steps or command that reproduce it 1. Start the server from source on an RX 9070 with Swift 1.5 IQ4_XS. 2. Run the script below (standard library only): it sends three prompts of ~6,000 unique tokens (fresh random words, `max_tokens: 1`), one request that decodes 100 tokens, then two more prompts, and prints each prompt's speed. On most starts one or more of the later prompts are 10-25% slower than the first. `--text FILE` sends a file of your own instead. 3. Restart with `DEBUG_HIP_DYNAMIC_QUEUES=0` and run it again: all prompts run at about the first prompt's speed. <details><summary>strata-issue-repro.py</summary> ```python #!/usr/bin/env python3 """Prompt speed before and after a decode, against a running Strata server (standard library only). Sends 3 prompts of ~6,000 unique tokens, one request that decodes 100 tokens, then 2 more prompts, and prints each prompt's speed. Start a fresh server first; run it once with DEBUG_HIP_DYNAMIC_QUEUES=0 in the engine's environment and once without. python3 strata-issue-repro.py [--url http://127.0.0.1:8080] [--words 2100] [--text FILE] """ import argparse import json import random import time import urllib.request VOCAB = ["alpha", "beta", "gamma", "delta", "kernel", "tensor", "expert", "router", "cache", "memory"] def ask(url, text, max_tokens): body = json.dumps({"model": "m", "messages": [{"role": "user", "content": text}], "max_tokens": max_tokens, "temperature": 0, "stream": False}).encode() request = urllib.request.Request(url + "/v1/chat/completions", body, {"Content-Type": "application/json"}) start = time.time() reply = json.load(urllib.request.urlopen(request, timeout=1800)) return reply["usage"], time.time() - start def prompt(n_words, text=None): if text is not None: # the time stamp comes first, so the server reuses nothing from the previous request return f"[{time.time()}] Review this code and list its three biggest problems.\n\n{text}" rng = random.Random(time.time_ns()) # a fresh seed and a time stamp: no two prompts share a prefix words = " ".join(rng.choice(VOCAB) + str(i % 97) for i in range(n_words)) return f"[{time.time()}] {words}\nSummarize the above in one word." def main(): parser = argparse.ArgumentParser(description=__doc__.split("\n")[0]) parser.add_argument("--url", default="http://127.0.0.1:8080") parser.add_argument("--words", type=int, default=2100, help="words per prompt (2100 is ~6,100 tokens)") parser.add_argument("--text", metavar="FILE", help="send this file (e.g. source code) as each prompt instead of random words") args = parser.parse_args() text = open(args.text, encoding="utf-8").read() if args.text else None speeds = [] for step in ("prompt", "prompt", "prompt", "decode", "prompt", "prompt"): if step == "decode": usage, seconds = ask(args.url, f"[{time.time()}] Explain how a CPU cache works.", 100) print(f"decode {usage['completion_tokens']:>6} tokens in {seconds:5.1f} s") continue usage, seconds = ask(args.url, prompt(args.words, text), 1) speeds.append(usage["prompt_tokens"] / seconds) print(f"prompt {len(speeds)} {usage['prompt_tokens']:>6} tokens in {seconds:5.1f} s {speeds[-1]:6.0f} tok/s") slow = [i + 1 for i, s in enumerate(speeds) if s < 0.9 * max(speeds)] print(f"slow prompts (more than 10% below the fastest): {slow if slow else 'none'}") if __name__ == "__main__": main() ``` </details> ### Reproduction status Reproduced locally ### Strata version Strata 0.2.10 (tag `v0.2.10`, `ffa80d73`) · engine 0.1.56, built from source for gfx1201 (also reproduced on 0.2.7.1) ### Graphics card, memory and system RX 9070 16 GB (gfx1201) on PCIe 3.0 x16 · Xeon W-2140B · 256 GB RAM · Fedora 44 (kernel 7.2.5) · ROCm from TheRock wheels 7.13.0a20260422 (gfx120X) ### Model, size and settings Swift 1.5 (Qwen3.8-Flash-Next fine-tune) IQ4_XS, native pack · `--max-context 262144 --kv int8 --kv-resident 32768 --expert-cache auto --prefill auto --vram-reserve-mib 448` · MTP (`--spec 3 --spec-min-p 0.5`) · `STRATA_ROUTE_TAIL_SKIP=8 STRATA_ROUTE_PRIOR=0.5 STRATA_SH_STREAM=1 STRATA_PREFILL_EQUAL=1` · power cap 180 W · pictures off ### Logs `STRATA_PREFILL_TIMING=1`, 0.2.7.1, fast then slow 20K prompt on one server (trimmed): ``` strata prefill timing: 20305 tokens, GPU timeline 13256 ms, wall 13325 ms, ... wait copy 4276 (32.3%) dequant 1378 (10.4%) gemm gate/up 1312 (9.9%) gemm down 843 (6.4%) ... strata serve: prompt 20310 tokens = 0 reused + 20310 read in 13809 ms (1470.8 tok/s), 1 generated in 60 ms strata prefill timing: 20305 tokens, GPU timeline 17890 ms, wall 17954 ms, ... wait copy 3684 (20.6%) dequant 5495 (30.7%) gemm gate/up 1686 (9.4%) gemm down 1059 (5.9%) ... strata serve: prompt 20310 tokens = 0 reused + 20310 read in 18635 ms (1089.9 tok/s), 1 generated in 27 ms ``` Note: this looks like the "R9700 / RX 9000 bimodal prompt speed" described above `prime_hw_queues()` in `src/program/generate.cpp`, but the queue priming doesn't prevent it here: the switch to slow happens mid-session.
Author
Owner

@github-actions[bot] commented on GitHub (Nov 3, 2026):

Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:

  • Fill in "Area".
  • Fill in "Desktop app, Terminal or source?".

Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment /reopen.

Details: CONTRIBUTING.md

<!-- gh-comment-id:6617728411 --> @github-actions[bot] commented on GitHub (Nov 3, 2026): Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing: - [ ] Fill in "Area". - [ ] Fill in "Desktop app, Terminal or source?". Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment `/reopen`. Details: [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md)
Author
Owner

@github-actions[bot] commented on GitHub (Nov 3, 2026):

Thanks, this follows the format now.

<!-- gh-comment-id:6617751869 --> @github-actions[bot] commented on GitHub (Nov 3, 2026): Thanks, this follows the format now.
Author
Owner

@mhhayashi commented on GitHub (Nov 4, 2026):

This was measured on TheRock 7.13 (and reproduced on 7.14). On 10.1.0a20260822 the behavior is different, and not necessarily better.

<!-- gh-comment-id:6619687768 --> @mhhayashi commented on GitHub (Nov 4, 2026): This was measured on TheRock 7.13 (and reproduced on 7.14). On 10.1.0a20260822 the behavior is different, and not necessarily better.
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#3073
No description provided.