Skip to content

[Engine] gfx1010 (RX 5700 XT) build fails: __builtin_amdgcn_sdot4 needs dot1-insts in rdna_mmvq.cu and rdna_gr.cu #308

Backlog

Description

@myway880

Building on Windows with HIP for gfx1010 (Navi 10, RX 5700 XT) fails at commit 36e654b (engine 0.1.66) with:

engine/src/kernels/cuda/rdna_mmvq.cu:72:12: error: '__builtin_amdgcn_sdot4' needs target feature dot1-insts
engine/src/kernels/cuda/rdna_gr.cu:92: error: '__builtin_amdgcn_sdot4' needs target feature dot1-insts

Both files call __builtin_amdgcn_sdot4 directly for every pre-RDNA3 card, but gfx1010 has no dot1 instructions. The repo already has strata::hip_compat::dp4a, which handles this for gfx1010. Switching those two calls to strata::hip_compat::dp4a makes them compile for gfx1010. This affects every model family, since they all build the same engine.

Diagnosed by Grok Bot

Activity

  1. added
    needs-format
    on Nov 24, 2026
  2. github-actions commented on Nov 24, 2026

    @github-actions

    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:

    • Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other], then a short description. Example: "[Engine] decode stops after 2 minutes".

    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

  3. changed the title [-]gfx1010 (RX 5700 XT) build fails: __builtin_amdgcn_sdot4 needs dot1-insts in rdna_mmvq.cu and rdna_gr.cu[/-] [+][Engine] gfx1010 (RX 5700 XT) build fails: __builtin_amdgcn_sdot4 needs dot1-insts in rdna_mmvq.cu and rdna_gr.cu[/+] on Nov 24, 2026
  4. removed
    needs-format
    on Nov 24, 2026
  5. github-actions commented on Nov 24, 2026

    @github-actions

    Thanks, this follows the format now.

  6. myway880 commented on Nov 24, 2026

    @myway880
    Author

    note once i fixed these locally the build finished successfully , and it is seems to be running inkling correctly , thanks for your work
    decode 15.7
    prefill 58
    on 128k context
    prefill reaches ~130 with prompt patch 2048

  7. okada-shogo commented on Nov 24, 2026

    @okada-shogo
    Contributor

    Ah thank you for the report. I don't have access to a AMD 5700xt and it's difficult to rent one online. This bugs probably related to some change I made so I'll look into it.

  8. okada-shogo commented on Nov 24, 2026

    @okada-shogo
    Contributor

    @myway880 I put a fixed branch up port/gfx1010-dot on my fork https://github.com/okada-shogo/PolyStrata, PR to follow.

    Also 15.7 tok/s decode and 58 tok/s prompts look low for an RX 5700 XT, and we have no gfx1010 card to test on. Could you run our bench report on your machine? It measures the card (bandwidth, launch and sync cost, PCIe) and the engine (time per kernel class, where each token's time goes), and says what limits it. It is in PR #285 and uploads nothing.

    Branch gfx1010-bench has the bench report with your fix already in it:

    git clone -b gfx1010-bench https://github.com/okada-shogo/PolyStrata.git

    Build strata-poly as you did before, then:

    strata-poly --model --bench-report report.md

    Please attach report.md here, plus the run command you normally use (flags, context size). With the report we can tell whether the 5700 XT is limited by memory bandwidth, by kernel launches, or by the experts that don't fit in VRAM.

  9. myway880 commented on Nov 25, 2026

    @myway880
    Author

    Note: included are all the patches i have made one are only for my use case , since i live in a hot area and my card has bad thermal so it crashes or restart the PC if I did not throttle it.
    The failed patches are attached in case the implementation is the problem (by Grok Bot)
    Note2: I can not program to save my life. so I'm sorry if I could not answer your questions, and my weekly tokens have run out, so next week is probably the nearest I can assist further.

    gfx1010 (RX 5700 XT) experiment report

    For the PR #285 gfx1010-bench request.

    Hardware and model

    • GPU: RX 5700 XT, gfx1010 (RDNA1, 20 CUs, 8 GB). Core clock capped at −12% for thermals.
    • Host: Ryzen 7 3700X, 32 GB RAM, Windows, HIP 7.x (TheRock), PCIe 4.
    • Model: Inkling-2-Mini UD-Q3_K_XL. In the short bench the expert cache held 957 of 3,072 experts (about 3.5 GiB).

    All speeds below are --bench-report figures (random tokens, greedy). Quality was not re-measured.

    Baseline: quick tier

    8,192-token prompt:

    Part Time Notes
    Total prefill 55.7 s
    Experts on the GPU 30 s about 1% of the probed read bandwidth
    Dense products 8.6 s
    Attention 6.9 s
    Host round trips 432

    Decode (one token a call) was about 37 ms/token against an 8.9 ms read-bandwidth roofline (roughly 27 tok/s):

    Family ms / token Share of probed bandwidth
    Attention 8.5 7%
    Experts on the GPU 9.9 36%
    Dense products 8.4 56%
    Norms, mixes 6
    Routing 6.5 48 host round trips a token

    About 1,293 kernel launches a token.

    Baseline: long tier

    The same settings with --max-context 131072 --long. Decode fell to 5.7 tok/s, against about 26 tok/s in the short run.

    Family Long Short
    Dense products 124 ms/token (16 GB/s, 4% of bandwidth) 8.4 ms/token
    Norms 20 ms/token 6 ms/token
    Other families only 10–25% slower

    The expert cache held 1,052 experts (3.9 GiB) against 957 (3.5 GiB) in the quick run. Dense products at 16 GB/s are being read at roughly PCIe speed, not VRAM speed.

    Why the prompt path is slow

    On gfx1010 the fast prompt tiles are not used:

    • In engine/src/poly/mmq_own.cu, grouped() is true only when card().shared is set. On HIP that happens only for gfx11 / gfx12 WMMA (hip_grouped()). gfx1010 has no WMMA.
    • gemm_iq_i8_* is a stub on HIP (engine/src/kernels/cuda/iq_kernels.cu), so int8_rows() is never taken.
    • Each expert is therefore dequantized whole to fp16 and multiplied by its own rocBLAS gemm_ex (fp16 → fp32) in a host loop over host_bounds (mmq_own.cu). Dense projections take the same path (engine/src/poly/engine.cpp).
    • gfx1010 has no dot instructions. The portable int8 dp4a path is a SDWA sequence of about 1.5 instructions per MAC, against 1 for fp32 / v_fma_mix_f32 and 0.5 for packed fp16. An int8 MMQ-style kernel is not the right answer on this card.
    • HIP rejects wave64 on gfx10.

    Prefill attention (ink_attend_batch) uses WMMA only on gfx12 and otherwise falls to rocBLAS. Decode attention is four launches (score → softmax → value → join) with scores going through global memory.

    Why the long run collapsed: WDDM spill

    This matches a failure the engine already documents.

    • Engine::fill_expert_cache() in engine/src/poly/engine.cpp sizes the cache from cudaMemGetInfo. On Windows HIP that is hipMemGetInfo minus the larger of the DXGI budget shortfall and other processes’ dedicated VRAM plus STRATA_WDDM_MARGIN_MIB (default 1,024 MiB); see engine/src/core/device.cu. A reserve (--vram-reserve-mib, default a 32nd of the card: 256 MiB on 8 GB, and only half of that after the first request unless the flag is set) is left for later allocations (KV growth, prompt buffers, recorded launches, library workspace).
    • The weights are allocated in device memory, not host or managed memory. A kernel that suddenly runs at PCIe speed means Windows demoted that memory to the shared / system pool.
    • The comment on Engine::vpool_claim_to_budget() already records an 8 GB card that went 150 MiB over the WDDM budget: “2.4 GB moved, decode at 6 tokens/s.” That matches this 5.7 tok/s run.
    • A possible further contributor, not proven on this machine: between prompts the engine unmaps the prompt buffers and lends that VRAM to the expert cache (lend_prompt() / take_prompt()). Linux ROCm only returns a released piece’s VRAM when its addresses are freed (STRATA_VMM_RELEASE_WITH_ADDRESSES in engine/include/strata/hip_compat/cuda.h, Linux only). The header notes that Windows still uses the plain release, unmeasured. If Windows holds released pieces the same way, each prompt or KV-growth round can add VRAM the engine no longer counts, until the process is over budget. That would also fit a larger cache in the long run (1,052 vs 957).
    • Ruled out as the main cause: a different dense kernel at M=1 (decode uses the same MMVQ path), and rocBLAS workspace (prompt only, and it comes out of the reserve).

    --vram-pool claims VRAM once up to the budget and never gives it back to the card, so that release/remap churn does not occur. It requires growing attention caches (pool_on_ = vram_pool && vmm_ && kv_grow in engine.cpp). --kv-whole turns kv_grow off, and the engine then prints “--vram-pool needs VMM and growing attention caches: off.” poly_kv_whole() in terminal/setup.py already skips --kv-whole when --vram-pool is in the args.

    Measured A/B

    On the same machine, after the long-tier collapse, we ran the official --bench-report again under one change at a time (and, for the memory cases, with --long out to a 24K conversation). During each run, Windows GPU process counters were sampled for that process’s dedicated and shared memory.

    Change Prompt (tok/s) Long decode (tok/s) Peak shared GPU memory Notes
    Baseline (no extra flags) about 60–100 short decode stayed in the usual ~20–26 range; a long run fell to 5.34 tok/s, dense products 37.8 ms/token 1.5–3 GB Reproduced the spill
    --vram-pool about 155 about 20 about 536 MiB Clear win: faster prompt, much less shared memory, long decode held
    Disable prompt-buffer lending on HIP/Windows (opt-in; see below) 166 17.9 1.5 GB Helps prompt and long decode; shared memory still high
    STRATA_EXP_MODE=8 — +1–2 vs base — Within the run-to-run noise
    STRATA_Q6K_RDNA1=1 possibly lower +1 — Small; prompt may be a little worse
    --prompt-batch 4096 — — — Not useful on this 8 GB card with this file: only 537 experts cached

    --vram-pool was the decisive fix for the long-run spill.

    Two other small HIP/Windows experiments (now settled):

    • Prompt-buffer lending (STRATA_PROMPT_LEND=0). Disabling lending so the prompt buffers stay mapped (as they already do on Linux HIP) improved the spilled long run and, in the later sweep, gave a prompt of about 165 tok/s with a stable greedy output. Keep it for Inkling on Windows HIP. --vram-pool remains the stronger spill fix.
    • DPP reductions. On gfx1010, HIP compiles __shfl_xor_sync to ds_bpermute. Replacing the constant-mask cases with DPP row_xmask / v_permlanex16 compiled cleanly and showed no measurable speed gain. Dead end; do not spend more time on it.

    Follow-up A/B (grouped GEMM, batched rocBLAS, throttle)

    Same machine and model, official --bench-report. Prompt rates are tok/s at 2K / 8K.

    Change Prompt 2K / 8K (tok/s) Notes Verdict
    Baseline (no extra flags) 78.3 / 86.2
    STRATA_RDNA1_GROUPED=1 (non-WMMA grouped fp16 expert GEMM) 150.8 / 175.9 About 2× prompt; decode unchanged. A rocBLAS CHECK run logged no MISMATCH. Successful — worth upstreaming as a gfx1010 / non-WMMA grouped path (env-gated; falls back for unsupported quants).
    STRATA_ROCBLAS_BATCHED=1 (batched / strided gemm_ex) 69.4 / 109.3 Slower than the per-expert rocBLAS loop. Dead end on gfx1010. rocBLAS is not tuned for this card; do not revise and retest as a speed patch.
    STRATA_THROTTLE_TPS=12 (decode cap) Measured 10.6 tok/s (a little under the cap). Usability only (thermal / duty-cycle). Not a speed patch; keep opt-in, off by default.
    STRATA_THROTTLE_PREFILL=70 60.9 / 111.1 Works as designed (prompt duty cycle). Same: keep available, off by default.
    STRATA_PROMPT_LEND=0 about 165 Deterministic vs its own baseline. Helpful on Inkling / Windows HIP.
    STRATA_EXP_MODE=8, STRATA_Q6K_RDNA1=1 marginal No evidence of harm. Keep for Inkling only.
    --vram-pool (see earlier table) Spill fix. Keep on for every model.

    Output-match harness caveat. The greedy match test is not reliable on this setup as written: the no-flag baseline did not reproduce itself (D0 FAIL; a second baseline run diverged at token 14), and nearly every variant diverged at that same token 14. Those UNSAFE verdicts are noise, not real failures. STRATA_PROMPT_LEND=0 matched 64/64 tokens and --vram-pool matched 58/64. A later harness should run several baseline trials and treat a divergence also seen between baseline runs as noise. That fix is not in this drop.

    Recommendations

    1. On an 8 GB RDNA1 card under Windows, run with --vram-pool and without --kv-whole. That is the change that stopped the WDDM spill here.
    2. Upstream the non-WMMA grouped fp16 expert GEMM (STRATA_RDNA1_GROUPED=1) as a gfx1010 / non-WMMA path. It about doubled prompt throughput here (150.8 / 175.9 vs 78.3 / 86.2 tok/s) with unchanged decode.
    3. Do not pursue batched rocBLAS on gfx1010 (slower; the library is not tuned here) or the DPP __shfl_xor replacement (no gain).
    4. An engine-side throttle (prompt duty cycle / decode tok/s cap) is a useful thermal control, not a speed win; leave it off unless the user wants it.
    5. Do not use --prompt-batch 4096 for this model on 8 GB (too few experts stay in VRAM).
    6. STRATA_EXP_MODE=8, STRATA_Q6K_RDNA1=1 and STRATA_PROMPT_LEND=0 are reasonable Inkling defaults; the first two are small, the third helped prompt and was stable.
    7. Consider making the VMM pool the default on Windows WDDM upstream, or otherwise treating “free VRAM” more conservatively before filling the expert cache. The default reserve (256 MiB, then 128 after the first request on 8 GB) is tight once a long context and prompt buffers land.

    Speculative ideas (not measured, or already settled)

    1. A non-WMMA grouped fp16 GEMM for RDNA1. Done and successful — see the follow-up table. Worth upstreaming.
    2. Batch the existing rocBLAS path. Measured; dead end on gfx1010 (slower than the per-expert loop). Not worth revising for this card.
    3. Fuse dequant into the decode GEMV for gfx1010, with fp16 activations rather than int8, if the MMVQ/slots kernels stay compute-bound (36% of bandwidth today).
    4. Budget-aware cache sizing even without the pool: treat free VRAM as min(hipMemGetInfo, budget − usage) minus a larger reserve before filling experts, and account for first-request recordings and workspace if those are predictable.
    5. Fewer host routing trips. 48 round trips and ~1,293 launches a token still dominate decode. Recorded graphs help; the HIP doorbell path was not effective here (bell_on is false on HIP in this tree).
    6. The Linux “release with addresses” VMM path on Windows only after measuring it. The engine aborts if the addresses cannot be reserved again; that is not a small change.

    Microbenchmarks of the card (instruction rates, launch cost, small-N GEMM vs rocBLAS) and the A/B harness we used, plus the patches in successful-patches.txt.

    2026-11-25-1050-inkling-2-mini-ud-q3-k-xl.json
    2026-11-25-1050-inkling-2-mini-ud-q3-k-xl.md
    2026-11-25-1056-inkling-2-mini-ud-q3-k-xl-long.json
    2026-11-25-1056-inkling-2-mini-ud-q3-k-xl-long.md
    2026-11-25-1534-inkling-2-mini-ud-q3-k-xl.json
    2026-11-25-1534-inkling-2-mini-ud-q3-k-xl.md

    10-gfx1010-sdot4.patch
    20-inkling-loop-kv-last.patch
    30-inkling-kv-q4-hadamard.patch
    50-pr313-inkling-tool-start.patch
    51-pr293-hip-decode-no-bf16.patch
    52-pr294-hip-attn-projections.patch
    53-pr299-expert-cache-follow.patch
    54-pr306-hip-doorbell.patch
    55-pr298-pinned-prompt-checkpoints.patch
    56-pr290-full-expert-mirror.patch
    60-navi10-dpp-xor.patch
    61-hip-no-prompt-lend.patch
    62-rdna1-grouped-gemm.patch
    63-rocblas-batched.patch
    64-engine-throttle.patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions