[PR #2230] [Engine] Fix mixed-gfx HIP prefill GEMM precision selection #3936

Open
opened 2026-11-07 15:31:48 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2230
Author: @PJGV333
Created: 10/13/2026
Status: 🔄 Open

Base: main ← Head: fix/hip-mixed-gpu-prefill-issue-690-703-pr


📝 Commits (1)

  • 835e105 fix(hip): select prompt FP16 per gfx103x device

📊 Changes

8 files changed (+732 additions, -15 deletions)

View changed files

📝 CMakeLists.txt (+38 -0)
📝 docs/AMD_HIP.md (+7 -1)
📝 include/strata/prefill/gemm.hpp (+4 -3)
📝 src/prefill/gemm.cu (+15 -8)
📝 src/prefill/kernels.cu (+2 -2)
📝 src/prefill/prefill.cpp (+1 -1)
➕ tests/hip/multigpu_prefill_dispatch.cpp (+163 -0)
➕ tests/hip/multigpu_prefill_gemm_dispatch.cpp (+502 -0)

📄 Description

Problem and result

Issues #690 and #703 report no kernel image is available for execution on the device during long-history / multi-chunk prefill on heterogeneous AMD layer splits. The reports include gfx1100 + gfx1030 and gfx1201 + gfx1031; they do not identify a root cause. In #690, setting STRATA_HIP_PROMPT_F16=1 unblocked the reporter's tested case, but the setting changes prompt GEMM precision on both GPUs.

This opt-in change preserves the historical global STRATA_HIP_PROMPT_F16=1 behavior and adds STRATA_HIP_PROMPT_F16=all as an explicit alias plus STRATA_HIP_PROMPT_F16=gfx103x, which selects FP16 prompt GEMMs only on gfx103x devices. Other architectures retain the default BF16 path. This is a per-device precision-selection option; it does not claim to diagnose or fix the reported long-prefill kernel-image failure.

Approach

  • Keep the historical STRATA_HIP_PROMPT_F16=1 selection global; keep its historical first-character behavior. =all is a new explicit alias, not a historical alias.
  • Add opt-in =gfx103x: FP16 only for HIP devices whose architecture name begins with gfx103; other devices continue to use BF16.
  • Keep the default unset path and CUDA arithmetic unchanged. The existing RDNA2 GEMM and SGEMM kernels remain available; this change does not replace them.
  • Add HIP tests for both device orders, returning to the first device, CPU-reference GEMMs, activation output, legacy option/prefix behavior and the new all alias.

Validation

Prepared local PR head: 835e1053073c0c0ddbb8d31c65c65974b3341776, based on upstream main 9de04cd44e927a9a3df6bbc0e94fc1be8b844ba4 (v0.2.1.4; engine 0.1.46.3). GitHub still reports upstream main at 9de04cd; no new upstream commit affects the patch paths. The tested candidate was 1ab2ca2bf4ba551a030416a2c19de537fc7ab48e; the prepared head has the identical source tree (e898c5ed…) and only corrects the stale “unverified” commit message.

Passed:

  • HIP Release builds for control and candidate with ROCm 7.2.4 / HIP Clang 22.0.0, gfx1201;gfx1031, STRATA_PREFILL_MMQ=ON. Reproduction configuration:
    cmake -S . -B build-hip-mixed \
      -DCMAKE_BUILD_TYPE=Release \
      -DSTRATA_ENABLE_HIP=ON -DSTRATA_ENABLE_CUDA=OFF \
      -DSTRATA_BUILD_TESTS=ON -DSTRATA_PREFILL_MMQ=ON \
      -DCMAKE_HIP_ARCHITECTURES='gfx1201;gfx1031' \
      -DCMAKE_HIP_COMPILER=/opt/rocm/lib/llvm/bin/clang++
    cmake --build build-hip-mixed --parallel
    ctest --test-dir build-hip-mixed --output-on-failure \
      -R '^(hip_prefill_gemm|hip_gemm_f16_io_parity|hip_multigpu_prefill_dispatch|hip_multigpu_prefill_gemm_dispatch.*|hip_prefill_hipblaslt_gemm|hip_prefill_rocblas_gemm|hip_device_selftest)$'
    
  • Focused CTest on the candidate: 10 passed, 2 skipped, 0 failed. Control: 3 passed, 2 skipped, 0 failed. The skips were hip_prefill_hipblaslt_gemm and hip_prefill_rocblas_gemm, because tuning tables were unavailable.
  • On RX 9070 XT (gfx1201) + RX 6750 XT (gfx1031), dual-GPU IQ3_S inference with MTP active showed BF16 on gfx1201 and FP16 on gfx1031 for =gfx103x. The control/candidate matrix covered default, =1, =all, =gfx103x and STRATA_RDNA2_SGEMM=1; default and =1 were also checked on one gfx1201 GPU.
  • Of the earlier 45-request numeric matrix at 30, 898 and 2,262 prompt tokens, 44 returned 323; that matrix was not repeated. In a separate, focused dual-GPU run on the RX 9070 XT (gfx1201) + RX 6750 XT (gfx1031), one 9,035-token API prompt (same 0.2.x base 9de04cd, model, hardware and environment; --prefill 8192, --max-context 16384, temperature 0, max 64 generated tokens, reasoning disabled) completed on the candidate: HTTP 200, finish_reason=stop, 24 output tokens, answer included 323. The prompt is reproducible as 290 repetitions of Dato de prueba: la Luna orbita la Tierra y la Tierra orbita el Sol. Esta frase repetida sirve únicamente para aumentar el prefill. followed by Calcula 17 por 19. Responde en español con una frase breve de exactamente veinte palabras que empiece con el resultado 323.; the raw text was 9,023 tokens and the API prompt, including template, was 9,035. The logs confirm BF16 on gfx1201 and FP16 on gfx1031, MTP active with 8/20 drafts accepted, and no HIP/BLAS errors.
  • Runtime for the focused run: CachyOS kernel 7.2.10-1-cachyos, ROCm 7.2.4, HIP 7.2.53211, AMD Clang 22.0.0git, driver 7.2.10-1-cachyos. Candidate timing for that single request: prefill 9,035 tokens in 7,488 ms (1,206.6 tok/s); decode 24 tokens in 701 ms (34.2 tok/s). These are descriptive measurements, not a benchmark or a speedup claim.
  • git diff --check passed. No performance claim is made from these smoke tests.

Failed:

  • In the same 9,035-token focused A/B, the unpatched upstream control (9de04cd) was given STRATA_HIP_PROMPT_F16=gfx103x but its old parser treats that value as off, leaving both devices on BF16. It returned HTTP 503 after the engine logged prefill gr_mix_r: no kernel image is available for execution on the device, followed by rocBLAS error: Could not initialize Tensile host: unordered_map::at and engine exit -6. The server adds generic advice that such exits can indicate OOM; the kernel journal had no OOM/reset entry in this interval, so I cannot assign that cause. No prefill/decode throughput was reported. This is an observed upstream failure in one attempt; its cause and repeatability remain unknown. The candidate completed the identical request.
  • A separate earlier candidate dual-GPU request with global STRATA_HIP_PROMPT_F16=1 and a 2,262-token prompt returned HTTP 503 after non-finite logits and prefill gr_silu: no kernel image is available for execution on the device. That same case passed on a later fresh run. Its cause remains unknown and it is not classified as fixed.
  • An initial reasoning-enabled preflight with a 24-token generation limit produced no answer in 6/6 requests (finish_reason=length). It was not counted in the numeric A/B matrix, which was rerun with reasoning_effort=none to obtain comparable numeric replies.

Not run:

  • The focused candidate run crossed an explicit 8,192-token prefill chunk with a 9,035-token API prompt. The original reports also include much longer ~44K and ~75K-token prompts/histories; those exact lengths were not tested on this candidate.
  • CUDA and SYCL builds: NOT RUN (nvcc unavailable; icpx/dpcpp unavailable). Applicability of SYCL to the touched shared source should be confirmed by maintainers.
  • Full CTest suite and performance benchmark.

Limits

This validates the per-device option and focused HIP dispatch on one gfx1201 + gfx1031 system. CMake warns that gfx1031 is not validated by maintainers; each HIP build log also contains 3,701 compiler warnings despite completing successfully. It does not establish the root cause or fix for #690/#703, and the intermittent failure remains unexplained. The project asks that a PR stay draft while required backend builds are unavailable. Existing upstream CI workflows do not provide an engine CUDA/HIP/SYCL build, so targeted maintainer/CI help is requested. Sanitized logs and an A/B runner can be supplied; local raw logs/scripts are not attached because they contain machine-specific paths.


🔄 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/2230 **Author:** [@PJGV333](https://github.com/PJGV333) **Created:** 10/13/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/hip-mixed-gpu-prefill-issue-690-703-pr` --- ### 📝 Commits (1) - [`835e105`](https://github.com/Niko1221/Strata/commit/835e1053073c0c0ddbb8d31c65c65974b3341776) fix(hip): select prompt FP16 per gfx103x device ### 📊 Changes **8 files changed** (+732 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+38 -0) 📝 `docs/AMD_HIP.md` (+7 -1) 📝 `include/strata/prefill/gemm.hpp` (+4 -3) 📝 `src/prefill/gemm.cu` (+15 -8) 📝 `src/prefill/kernels.cu` (+2 -2) 📝 `src/prefill/prefill.cpp` (+1 -1) ➕ `tests/hip/multigpu_prefill_dispatch.cpp` (+163 -0) ➕ `tests/hip/multigpu_prefill_gemm_dispatch.cpp` (+502 -0) </details> ### 📄 Description ### Problem and result Issues [#690](https://github.com/Niko1221/Strata/issues/690) and [#703](https://github.com/Niko1221/Strata/issues/703) report `no kernel image is available for execution on the device` during long-history / multi-chunk prefill on heterogeneous AMD layer splits. The reports include `gfx1100 + gfx1030` and `gfx1201 + gfx1031`; they do not identify a root cause. In #690, setting `STRATA_HIP_PROMPT_F16=1` unblocked the reporter's tested case, but the setting changes prompt GEMM precision on both GPUs. This opt-in change preserves the historical global `STRATA_HIP_PROMPT_F16=1` behavior and adds `STRATA_HIP_PROMPT_F16=all` as an explicit alias plus `STRATA_HIP_PROMPT_F16=gfx103x`, which selects FP16 prompt GEMMs only on gfx103x devices. Other architectures retain the default BF16 path. This is a per-device precision-selection option; it does **not** claim to diagnose or fix the reported long-prefill kernel-image failure. ### Related discussion - [#690 — long prefill fails on a mixed AMD layer split](https://github.com/Niko1221/Strata/issues/690) - [#703 — gfx1201 + gfx1031 long-history prefill report](https://github.com/Niko1221/Strata/issues/703) - This PR is the updated, same-PR continuation of #2230; no new PR is intended. ### Approach - Keep the historical `STRATA_HIP_PROMPT_F16=1` selection global; keep its historical first-character behavior. `=all` is a new explicit alias, not a historical alias. - Add opt-in `=gfx103x`: FP16 only for HIP devices whose architecture name begins with `gfx103`; other devices continue to use BF16. - Keep the default unset path and CUDA arithmetic unchanged. The existing RDNA2 GEMM and SGEMM kernels remain available; this change does not replace them. - Add HIP tests for both device orders, returning to the first device, CPU-reference GEMMs, activation output, legacy option/prefix behavior and the new `all` alias. ### Validation Prepared local PR head: `835e1053073c0c0ddbb8d31c65c65974b3341776`, based on upstream `main` `9de04cd44e927a9a3df6bbc0e94fc1be8b844ba4` (`v0.2.1.4`; engine `0.1.46.3`). GitHub still reports upstream `main` at `9de04cd`; no new upstream commit affects the patch paths. The tested candidate was `1ab2ca2bf4ba551a030416a2c19de537fc7ab48e`; the prepared head has the identical source tree (`e898c5ed…`) and only corrects the stale “unverified” commit message. **Passed:** - HIP Release builds for control and candidate with ROCm 7.2.4 / HIP Clang 22.0.0, `gfx1201;gfx1031`, `STRATA_PREFILL_MMQ=ON`. Reproduction configuration: ```sh cmake -S . -B build-hip-mixed \ -DCMAKE_BUILD_TYPE=Release \ -DSTRATA_ENABLE_HIP=ON -DSTRATA_ENABLE_CUDA=OFF \ -DSTRATA_BUILD_TESTS=ON -DSTRATA_PREFILL_MMQ=ON \ -DCMAKE_HIP_ARCHITECTURES='gfx1201;gfx1031' \ -DCMAKE_HIP_COMPILER=/opt/rocm/lib/llvm/bin/clang++ cmake --build build-hip-mixed --parallel ctest --test-dir build-hip-mixed --output-on-failure \ -R '^(hip_prefill_gemm|hip_gemm_f16_io_parity|hip_multigpu_prefill_dispatch|hip_multigpu_prefill_gemm_dispatch.*|hip_prefill_hipblaslt_gemm|hip_prefill_rocblas_gemm|hip_device_selftest)$' ``` - Focused CTest on the candidate: 10 passed, 2 skipped, 0 failed. Control: 3 passed, 2 skipped, 0 failed. The skips were `hip_prefill_hipblaslt_gemm` and `hip_prefill_rocblas_gemm`, because tuning tables were unavailable. - On RX 9070 XT (`gfx1201`) + RX 6750 XT (`gfx1031`), dual-GPU IQ3_S inference with MTP active showed BF16 on `gfx1201` and FP16 on `gfx1031` for `=gfx103x`. The control/candidate matrix covered default, `=1`, `=all`, `=gfx103x` and `STRATA_RDNA2_SGEMM=1`; default and `=1` were also checked on one `gfx1201` GPU. - Of the earlier 45-request numeric matrix at 30, 898 and 2,262 prompt tokens, 44 returned `323`; that matrix was not repeated. In a separate, focused dual-GPU run on the RX 9070 XT (`gfx1201`) + RX 6750 XT (`gfx1031`), one 9,035-token API prompt (same 0.2.x base `9de04cd`, model, hardware and environment; `--prefill 8192`, `--max-context 16384`, temperature 0, max 64 generated tokens, reasoning disabled) completed on the candidate: HTTP 200, `finish_reason=stop`, 24 output tokens, answer included `323`. The prompt is reproducible as 290 repetitions of `Dato de prueba: la Luna orbita la Tierra y la Tierra orbita el Sol. Esta frase repetida sirve únicamente para aumentar el prefill.` followed by `Calcula 17 por 19. Responde en español con una frase breve de exactamente veinte palabras que empiece con el resultado 323.`; the raw text was 9,023 tokens and the API prompt, including template, was 9,035. The logs confirm BF16 on `gfx1201` and FP16 on `gfx1031`, MTP active with 8/20 drafts accepted, and no HIP/BLAS errors. - Runtime for the focused run: CachyOS kernel `7.2.10-1-cachyos`, ROCm `7.2.4`, HIP `7.2.53211`, AMD Clang `22.0.0git`, driver `7.2.10-1-cachyos`. Candidate timing for that single request: prefill 9,035 tokens in 7,488 ms (1,206.6 tok/s); decode 24 tokens in 701 ms (34.2 tok/s). These are descriptive measurements, not a benchmark or a speedup claim. - `git diff --check` passed. No performance claim is made from these smoke tests. **Failed:** - In the same 9,035-token focused A/B, the unpatched upstream control (`9de04cd`) was given `STRATA_HIP_PROMPT_F16=gfx103x` but its old parser treats that value as off, leaving both devices on BF16. It returned HTTP 503 after the engine logged `prefill gr_mix_r: no kernel image is available for execution on the device`, followed by `rocBLAS error: Could not initialize Tensile host: unordered_map::at` and engine exit `-6`. The server adds generic advice that such exits can indicate OOM; the kernel journal had no OOM/reset entry in this interval, so I cannot assign that cause. No prefill/decode throughput was reported. This is an observed upstream failure in one attempt; its cause and repeatability remain unknown. The candidate completed the identical request. - A separate earlier candidate dual-GPU request with global `STRATA_HIP_PROMPT_F16=1` and a 2,262-token prompt returned HTTP 503 after non-finite logits and `prefill gr_silu: no kernel image is available for execution on the device`. That same case passed on a later fresh run. Its cause remains unknown and it is not classified as fixed. - An initial reasoning-enabled preflight with a 24-token generation limit produced no answer in 6/6 requests (`finish_reason=length`). It was not counted in the numeric A/B matrix, which was rerun with `reasoning_effort=none` to obtain comparable numeric replies. **Not run:** - The focused candidate run crossed an explicit 8,192-token prefill chunk with a 9,035-token API prompt. The original reports also include much longer ~44K and ~75K-token prompts/histories; those exact lengths were not tested on this candidate. - CUDA and SYCL builds: **NOT RUN** (`nvcc` unavailable; `icpx`/`dpcpp` unavailable). Applicability of SYCL to the touched shared source should be confirmed by maintainers. - Full CTest suite and performance benchmark. ### Limits This validates the per-device option and focused HIP dispatch on one `gfx1201 + gfx1031` system. CMake warns that `gfx1031` is not validated by maintainers; each HIP build log also contains 3,701 compiler warnings despite completing successfully. It does not establish the root cause or fix for #690/#703, and the intermittent failure remains unexplained. The project asks that a PR stay draft while required backend builds are unavailable. Existing upstream CI workflows do not provide an engine CUDA/HIP/SYCL build, so targeted maintainer/CI help is requested. Sanitized logs and an A/B runner can be supplied; local raw logs/scripts are not attached because they contain machine-specific paths. --- <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#3936
No description provided.