Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
AMD HIP: RDNA2 gfx1030 (tested), gfx(1031, 1032) untested.
Rafael Grossi7d15ef727b78
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 29009ea80..69bd9fffa 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -33,7 +33,7 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)endif()option(STRATA_ENABLE_CUDA "Build the CUDA targets (Phase 2+)" OFF)-option(STRATA_ENABLE_HIP "Build the HIP targets for wave32 AMD GPUs (gfx1100, gfx1201)" OFF)+option(STRATA_ENABLE_HIP "Build the HIP targets for wave32 AMD GPUs (gfx1100, gfx1201; gfx1030 unvalidated)" OFF)option(STRATA_PREFILL_MMQ "Build the optional GGML MMQ prefill path for HIP" OFF)# CUDA: MMQ prompt kernels for Q4_K / Q5_K / Q5_1 (Unsloth's UD-Q4_K_XL experts). Off by default: the engine loads# every kernel when it starts (CUDA_MODULE_LOADING=EAGER), so these took ~5 MB of VRAM - 1-3 expert slots - from everydiff --git a/README.md b/README.mdindex 93bea0962..55bdbebbc 100644--- a/README.md+++ b/README.md@@ -94,7 +94,7 @@ times slower than the sizes above, and long prompts are slow. It needs 48 GB ofNVIDIA GPU (no images yet). Details and measurements: [UD-Q4_K_XL](docs/UNSLOTH_Q4.md).An **AMD Radeon RX 7900 XT / XTX, RX 9070 / 9070 XT or Radeon AI PRO R9700 on Linux** works too (experimental; the-RX 7800 XT / 7700 XT and RX 9060 XT were validated by their owners):+RX 7800 XT / 7700 XT and RX 9060 XT were validated by their owners; the RX 6800 / 6900 series, gfx1030, is community-reported):`./setup.sh --backend hip`, chosen by itself on a PC with no NVIDIA card Strata can use. It installs ROCm without sudoand compiles the engine (no images yet; several cards with `--gpus`). Details: [AMD HIP](docs/AMD_HIP.md).diff --git a/cmake/hip_backend.cmake b/cmake/hip_backend.cmakeindex 9cd0cfed1..558bb07cd 100644--- a/cmake/hip_backend.cmake+++ b/cmake/hip_backend.cmake@@ -1,15 +1,17 @@-# Opt-in HIP configuration. Strata's CUDA-shaped kernels target wave32 RDNA3 / RDNA4 (64 KiB LDS per workgroup,-# the signed dot4 instruction). CMake/compiler discovery stays machine-independent; pass CMAKE_HIP_COMPILER when it+# Opt-in HIP configuration. Strata's CUDA-shaped kernels target wave32 RDNA2 / RDNA3 / RDNA4 (64 KiB LDS per+# workgroup, a signed dot4 instruction). CMake/compiler discovery stays machine-independent; pass CMAKE_HIP_COMPILER when it# is not on PATH.if(NOT DEFINED CMAKE_HIP_ARCHITECTURES OR CMAKE_HIP_ARCHITECTURES STREQUAL "")set(CMAKE_HIP_ARCHITECTURES gfx1100 CACHE STRING "Strata HIP target architecture(s), e.g. gfx1100 or gfx1100;gfx1201")endif()# Validated on real cards: gfx1100 (RX 7900 XT / XTX) and gfx1201 (RX 9070 / 9070 XT, Radeon AI PRO R9700) by the# maintainers; gfx1101 (RX 7800 XT, #254) and gfx1200 (RX 9060 XT, #256) by their owners. gfx1102 (RX 7600) has the-# same LDS limit and dot4 instruction and passed ctest (#192), but no model run has been reported yet.+# same LDS limit and dot4 instruction and passed ctest (#192), but no model run has been reported yet. RDNA2 gfx1030 (RX 6800 / 6900) has the+# same LDS limit and wave32 but an older dot4 instruction (v_dot4_i32_i8, hip_compat/intrinsics.hpp); a community+# report ran it (#311), the maintainers have not.set(_strata_hip_validated gfx1100 gfx1201)set(_strata_hip_community gfx1101 gfx1200)-set(_strata_hip_unvalidated gfx1102)+set(_strata_hip_unvalidated gfx1102 gfx1030)set(STRATA_HIP_ARCH_LIST "")foreach(_arch IN LISTS CMAKE_HIP_ARCHITECTURES)string(REGEX REPLACE ":.*$" "" _base "${_arch}") # gfx1100:xnack- -> gfx1100diff --git a/docs/AMD_HIP.md b/docs/AMD_HIP.mdindex 0a34e797b..816608e05 100644--- a/docs/AMD_HIP.md+++ b/docs/AMD_HIP.md@@ -1,13 +1,13 @@-# Experimental AMD HIP backend (gfx1100, gfx1101, gfx1200, gfx1201)+# Experimental AMD HIP backend (gfx1100, gfx1101, gfx1200, gfx1201, gfx1030)This is a Linux source build for the RX 7900 XT / XTX (RDNA3, gfx1100) and theRX 9070 / 9070 XT / Radeon AI PRO R9700 (RDNA4, gfx1201; see [RDNA4](#rdna4-gfx1201)). The RX 7800 XT / 7700 XT(gfx1101) and the RX 9060 XT (gfx1200) were validated by their owners (see [Community-validated-cards](#community-validated-cards)). It is opt-in; the NVIDIA installer and CUDA build remain the default. Other AMD+cards](#community-validated-cards)); the RX 6800 / 6900 series (RDNA2, gfx1030) builds and runs too, reported by a community machine and not yet validated by the maintainers (see [RDNA2](#rdna2-gfx1030)). It is opt-in; the NVIDIA installer and CUDA build remain the default. Other AMDarchitectures, wave64, Windows HIP, and mixed AMD/NVIDIA execution are outside this contribution.The backend maps the CUDA-shaped runtime and BLAS calls to HIP/hipBLAS, uses-RDNA3/RDNA4's signed integer dot instruction for quantized kernels, and supplies+RDNA2/RDNA3/RDNA4's signed integer dot instruction for quantized kernels, and supplieswave32 shuffle/packed-byte operations. CUDA-only QSA matrix instructions havean ordered FP32 fallback. Prefill supports both dequantization plus hipBLAS GEMM and opt-in HIP ggml MMQ.An optional, calibrated hipBLASLt path accelerates dense projections (per-architecture tables in `tools/hip`).@@ -28,7 +28,9 @@ the kernel's amdgpu driver (no ROCm install needed):- **ROCm:** a system ROCm 7 in `/opt/rocm` (or `$ROCM_PATH`) with hipcc and hipBLAS is used when present. Otherwise(or when it is older than 7.0) ROCm is installed into `.venv` from AMD's TheRock wheels (~10 GB, no sudo), pinnedto the version this backend was tested with, from the card family's index: `gfx110X-dgpu` for gfx1100 / gfx1101,- `gfx120X-all` for gfx1200 / gfx1201 (`STRATA_ROCM_VERSION` / `STRATA_ROCM_INDEX` override them).+ `gfx120X-all` for gfx1200 / gfx1201, `gfx103X-all` for gfx1030 (`STRATA_ROCM_VERSION` /+ `STRATA_ROCM_INDEX` override them; the gfx1030 index is not checked to carry the pinned version: a system+ ROCm 7 is the tested path there).- **Engine:** compiled on your PC for the card's architecture (10-20 minutes, once; again after a `git pull` thatchanges it, or when you pick a card of another architecture). This needs a C++ compiler and git(`sudo apt install build-essential git`).@@ -63,7 +65,7 @@ cmake --build build-hip --target strata -j2`CMAKE_HIP_ARCHITECTURES` is `gfx1100`, `gfx1101`, `gfx1200`, `gfx1201`, or a list such as `"gfx1100;gfx1201"`(one binary for both). gfx1102 (the same wave32, 64 KiB LDS and dot4 instruction) builds with a warning: it passed-ctest (#192) but no model run has been reported. At startup the engine and `strata-device` compare each GPU they use+ctest (#192) but no model run has been reported; so does gfx1030 (RDNA2: the older `v_dot4_i32_i8`, a community run in #311). At startup the engine and `strata-device` compare each GPU they use(`gcnArchName` up to the `:` feature suffix) with the architectures the binary was compiled for, and requirewave32. A binary carried to another card stops with the card's name, its architecture and the build's list,instead of failing later with "invalid device function".@@ -218,6 +220,38 @@ is shipped for them (make one with [Tuning table](#tuning-table) and compare theGreedy output was the same across runs. For comparison, llama.cpp's HIP build measured 20 tok/s decode and450 tok/s prompt on that card.+## RDNA2 (gfx1030)++The RX 6800 / 6800 XT / 6900 XT / 6950 XT run the same kernels: wave32 and 64 KiB of LDS per workgroup. The one+difference is the dot instruction: RDNA2 has no `v_dot4_i32_iu8` (gfx11 and newer), so+`dp4a` uses the plain signed `v_dot4_i32_i8` through `__builtin_amdgcn_sdot4`, which compiles to a single+`v_dot4c_i32_i8` (same signed x signed byte products, modulo 2^32). There is no WMMA; the QSA scorer takes the+same ordered FP32 fallback as gfx1100. CMake lists gfx1030 as unvalidated (the build warns) until a maintainer has+run it; the report below is from a community machine: an RX 6900 XT 16 GB (gfx1030), an i7-13700KF (8 P-cores and+8 E-cores, AVX2, no AVX-512), 63 GB RAM, NixOS, ROCm 7.2.3 from nixpkgs (clang 22, hipBLAS 3.2).++- **Build and tests** (engine 0.1.26): a complete HIP build for gfx1030, made by hand with cmake and ROCm's own+ `clang++` (the nixpkgs ROCm is not an `/opt/rocm` tree, so setup's `build_engine_hip` was not exercised; the+ binary was placed in `engine/` for setup to use). All 28 registered ctest tests pass on the card, including+ `hip_device_selftest`. An engine 0.1.30 build of this branch configures, builds and runs clean on the same card;+ the speeds below are measured on it.+- **End to end** (Swift 1.5 IQ3_XXS, `--context 131072` with `--kv-resident 32768 --adapt-every 1+ --vram-reserve-mib 1024`, 200 greedy tokens): 38-42 tok/s decode with the default 15 CPU pool workers (one per+ physical core except the host thread; 8 workers: 36; 24 = every logical core: 27), consistent even with the+ 131,072-token context full.+- **Prefill** (the same 15-worker configuration): 246 tok/s on a 2,000-token prompt, 330-339 tok/s at the auto+ 8,192-token chunk (7,997 and 15,967 tokens; time to first token 8.9 and 48.3 s), 133 tok/s on a 522-token+ prompt - short prompts are fixed overhead (19-25 tok/s on 34 tokens). Decode after a 16K prefill holds at+ 45.5 tok/s.+- **16 GB card:** the expert cache holds 6,310 slots (10.2 GiB) at 16K context and 5,247 slots at 131,072, where+ setup keeps the KV cache in VRAM because IQ3_XXS needs about 60 GB of RAM plus the cache to stream it. The+ `--pcie-frac 0` and `--adapt-every 0` of the 7900 XTX configuration in+ [AMD_HIP_PERFORMANCE.md](AMD_HIP_PERFORMANCE.md) cost 8.6 and 13.6 tok/s here (30 with the defaults): keep the+ defaults on a 16 GB card.+- **hipBLASLt:** ROCm's hipBLASLt ships no gfx1030 kernels, so there is no table and the plain hipBLAS path runs.+- **Not validated:** gfx1031 / gfx1032 (the same `dp4a` path, no hardware report), setup's own build path and the+ `gfx103X-all` wheels on gfx1030, images, answer-quality benchmarks.+## Tuning tableA hipBLASLt table holds solution ids that are valid only for one GPU architecture and one hipBLASLt version, so itdiff --git a/include/strata/hip_compat/intrinsics.hpp b/include/strata/hip_compat/intrinsics.hppindex 9e6eda74b..a789e38c9 100644--- a/include/strata/hip_compat/intrinsics.hpp+++ b/include/strata/hip_compat/intrinsics.hpp@@ -1,6 +1,6 @@#pragma once-// CUDA device intrinsics used by Strata kernels that HIP does not provide on RDNA3 / RDNA4 (wave32).+// CUDA device intrinsics used by Strata kernels that HIP does not provide on RDNA2 / RDNA3 / RDNA4 (wave32).// This header is included only from the HIP cuda_runtime compatibility shim.#if defined(__HIPCC__)@@ -21,6 +21,10 @@ __device__ __forceinline__ int dp4a(int a, int b, int c) {// both packed operands signed to preserve CUDA __dp4a semantics; keep the// portable path for other HIP compilers/targets.return __builtin_amdgcn_sudot4(true, a, true, b, c, false);+#elif (defined(__gfx1030__) || defined(__gfx1031__) || defined(__gfx1032__)) && __has_builtin(__builtin_amdgcn_sdot4)+ // RDNA2 has no sudot4 (that is gfx11+), but it has the plain signed v_dot4_i32_i8 (dot1-insts): the same+ // signed x signed byte products accumulated modulo 2^32, no clamp.+ return __builtin_amdgcn_sdot4(a, b, c, false);#elseconst uint32_t ua = static_cast<uint32_t>(a);const uint32_t ub = static_cast<uint32_t>(b);diff --git a/setup.py b/setup.pyindex 7ea8b4f9d..9d09d17ba 100644--- a/setup.py+++ b/setup.py@@ -899,22 +899,24 @@ def cuda_lib_dirs():# ------------------------------------------------------------------------------------------------ AMD (experimental)# The RX 7900 XT / XTX (gfx1100) and the RX 9070 series / Radeon AI PRO R9700 (gfx1201) on Linux, through the HIP# backend (docs/AMD_HIP.md); the RX 7800 XT / 7700 XT (gfx1101, #254) and the RX 9060 XT (gfx1200, #256) were run by-# their owners. There is no ready-made AMD engine: ROCm comes from AMD's TheRock Python wheels into .venv (no sudo;+# their owners; the RX 6800 / 6900 series (gfx1030, #311) runs but is unvalidated. There is no ready-made AMD engine: ROCm comes from AMD's TheRock Python wheels into .venv (no sudo;# a system ROCm 7 in /opt/rocm is used when it has hipcc and hipBLAS) and the engine is compiled here for the cards.# No images yet.ROCM_INDEXES = {"gfx1100": "https://rocm.nightlies.amd.com/v2/gfx110X-dgpu/", # TheRock's wheels per GPU family"gfx1101": "https://rocm.nightlies.amd.com/v2/gfx110X-dgpu/","gfx1200": "https://rocm.nightlies.amd.com/v2/gfx120X-all/",- "gfx1201": "https://rocm.nightlies.amd.com/v2/gfx120X-all/"}+ "gfx1201": "https://rocm.nightlies.amd.com/v2/gfx120X-all/",+ "gfx1030": "https://rocm.nightlies.amd.com/v2/gfx103X-all/"}ROCM_VERSION = os.environ.get("STRATA_ROCM_VERSION", "7.10.0a20251120") # what Strata's HIP build was tested withROCM_SYSTEM_MIN = (7, 0) # an older system ROCm is passed over for the wheels (gfx1201 needs ROCm 6.4 or newer)-AMD_ARCHS = ("gfx1100", "gfx1101", "gfx1200", "gfx1201")+AMD_ARCHS = ("gfx1100", "gfx1101", "gfx1200", "gfx1201", "gfx1030")AMD_NAMES = {"gfx1100": "AMD Radeon RX 7900 series (gfx1100)", # when sysfs has no product name"gfx1101": "AMD Radeon RX 7800 XT / 7700 XT (gfx1101)","gfx1200": "AMD Radeon RX 9060 series (gfx1200)",- "gfx1201": "AMD Radeon RX 9070 series / AI PRO R9700 (gfx1201)"}+ "gfx1201": "AMD Radeon RX 9070 series / AI PRO R9700 (gfx1201)",+ "gfx1030": "AMD Radeon RX 6800 / 6900 series (gfx1030)"}AMD_CARDS = ("the RX 7900 XT / XTX (gfx1100), RX 7800 XT / 7700 XT (gfx1101), RX 9060 XT (gfx1200) and "- "RX 9070 / 9070 XT / Radeon AI PRO R9700 (gfx1201)")+ "RX 9070 / 9070 XT / Radeon AI PRO R9700 (gfx1201), and the RX 6800 / 6900 series (gfx1030, unvalidated)")def rocm_index(arch):diff --git a/src/kernels/cuda/verify_kernels.cu b/src/kernels/cuda/verify_kernels.cuindex 69550156f..7908ce404 100644--- a/src/kernels/cuda/verify_kernels.cu+++ b/src/kernels/cuda/verify_kernels.cu@@ -546,7 +546,7 @@ void copy_indexed(float* dst, const float* src, int64_t stride, const int32_t* inamespace { __global__ void gpu_stamp_kernel(unsigned long long* buf, int i) {unsigned long long t;#if defined(__HIPCC__)- t = wall_clock64() * 10ull; // gfx11 / gfx12: a constant 100 MHz counter, in ns+ t = wall_clock64() * 10ull; // gfx10.3 / gfx11 / gfx12: a constant 100 MHz counter, in ns#elseasm volatile("mov.u64 %0, %%globaltimer;" : "=l"(t));#endif