Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a266046
hip: ROCm backend for the same kernels, brought up on Qwen3.6-35B-A3B
Nov 16, 2026
4a670a1
hip: prefill on the card's matrix cores (gfx11/gfx12 WMMA)
Nov 16, 2026
92b28e2
hip: graph capture on by default, and parity checks across the local …
Nov 16, 2026
08c6297
hip: pinned staging ring, stream-ordered copies, graph cap, calibration
Nov 16, 2026
f3f29c8
hip: why the prefill GEMM keeps the f16 matrix cores (int8 measured, …
Nov 16, 2026
5f8d168
hip: serve verified on the ROCm backend
Nov 16, 2026
6feb823
hip: long-prompt numbers, and where the depth-dependent cost goes
Nov 16, 2026
5aa1436
hip: the prefill attention's V fragment read every other key
Nov 16, 2026
3d5cdf7
hip: prefill attention scores on the matrix cores
Nov 16, 2026
223a737
hip: prefill attention P*V on the matrix cores, and the depth cost is…
Nov 16, 2026
7d7a0eb
hip: deltanet_seq measured, and left alone
Nov 17, 2026
3bf8079
docs: the two matrix-core ports, against what Strata already had
Nov 17, 2026
2c34788
Merge remote-tracking branch 'origin/main' into hip-backend
Nov 24, 2026
9a504a6
hip: follow main's kernel arguments (weight scale, rope pairs, tq_lut…
Nov 24, 2026
98b1898
hip: the kv_q8 comment names KV_MODE
Nov 24, 2026
272bb2c
hip: say which libhiprtc paths were tried and why each failed
Nov 24, 2026
1fcca1c
hip: gfx11 WMMA results go to the rows RDNA3 puts them in
Nov 24, 2026
10a5fcb
hip: read the device properties into a buffer with room to spare, and…
Nov 24, 2026
8ca7e9a
hip: comments and HIP.md match the code (staging tile size, small-til…
Nov 24, 2026
b84a1a6
Merge remote-tracking branch 'origin/main' into hip-backend
Nov 24, 2026
76142a0
hip: a batch step's GEMM ignores main's BATCHED flag
Nov 24, 2026
d294547
hip: the BATCHED test comment says the flag is masked, not added
Nov 24, 2026
57299c0
hip: argmax_rows sizes its partials in bytes, so 9 to 64 rows fit
Nov 24, 2026
6b58bac
hip: --device with several indices is refused, and --backend lists hip
Nov 24, 2026
48e35b1
hip: the argmax test gives each row one maximum
Nov 24, 2026
e4baa03
backend: open_all checks a device list once for every caller
Nov 24, 2026
aed841f
backend: calibrate checks its --device list before it reads the GGUF
Nov 24, 2026
af3a8fc
hip: an argmax test with ties checks the first index
Nov 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ A GPU run needs one of:
under `%CUDA_PATH%\bin`); `STRATA_NVRTC` names another file. Without it the run falls back to Vulkan.
- a Vulkan 1.3 driver with shaderFloat64, int8/16/64 and subgroup size 32 or a fixed 64 (tested on RTX 3060, Radeon VII
and V100; Intel Arc lacks shaderFloat64).
- for `--backend hip`: a ROCm runtime with hiprtc (`libamdhip64.so`, `libhiprtc.so`), also loaded at run time; the
kernels are compiled for the card's `gfx` target on first use. Experimental — status, numbers and limits are in
[docs/HIP.md](docs/HIP.md).

`--gpu` picks CUDA when it loads, else Vulkan; `--backend` chooses. The first CUDA run compiles the kernels (~15 s) and
`--gpu` picks CUDA when it loads, else Vulkan; `--backend` chooses (`cuda`, `vulkan` or `hip`). The first CUDA run compiles the kernels (~15 s) and
caches them. Every GPU tried so far is in [docs/SUPPORTED_GPUS.md](docs/SUPPORTED_GPUS.md).

## Quick start
Expand Down
5 changes: 5 additions & 0 deletions THANKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ If you helped and your name is missing here, that is our mistake. Open an issue
- [luckydevil13](https://github.com/luckydevil13): AMD benchmarks and a lot of talk about which models to support.
- [ike287](https://github.com/ike287): feedback and feature requests.

## Code

- [Niko1221](https://github.com/Niko1221/Strata): the HIP backend's device-side compatibility layer (`src/hip/compat.h`)
follows the structure and several implementations of Strata's `include/strata/hip_compat/intrinsics.hpp` (MIT).

## Ideas

- [FredWalter](https://github.com/FredWalter): asked for multi-GPU and Qwen3.8-Flash-Next (issue #1), and later
Expand Down
207 changes: 207 additions & 0 deletions docs/HIP.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ other MCP clients use, and pass it with `--mcp <file>` (or `STRATA_MCP`; the def

## Flags

- `--backend NAME` GPU backend: `cuda`, `vulkan` or `hip` (AMD cards through ROCm, one device per run, see [HIP.md](HIP.md)). Without it CUDA is used when it loads, else Vulkan.
- `--ctx` KV cache size in tokens (default 4096). For Inkling 2, Hy4, GLM, DeepSeek and Gemma 4 it is the prompt plus reply limit instead, and the default is the context the model was trained on; their caches grow with the text.
- `--mtp [N]` speculative decoding with the model's draft head. Greedy tokens stay the same; sampling keeps its
distribution. Needs a GGUF with an MTP head (for example the Qwen3.6-35B-A3B MTP files).
Expand Down Expand Up @@ -225,7 +226,7 @@ OpenCode and other agents use the OpenAI address.

`--device 0,1` splits the layers over the cards in proportion to their free VRAM, so more experts stay resident. The
cards run one after the other, so one request gets more memory, not twice the speed of one card. MTP drafting is off on
a split model.
a split model. The HIP backend runs one device, so `--device 0,1` is refused with `--backend hip`.

An index is the same card on both backends. NVIDIA cards are counted as CUDA counts them (by default the fastest card
first, which is not the order of `nvidia-smi`), on Vulkan too; the other Vulkan devices follow, dedicated cards before
Expand Down
32 changes: 28 additions & 4 deletions src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,28 @@ unsafe impl Plain for u64 {}

/// Device memory, recorded graphs and kernel ops. Host copies are synchronous; device work runs in queue order.
/// Pointer arguments are device addresses; strides are in floats unless named otherwise.
/// The backend `kind` ("cuda" or "vulkan") on GPU `device`; with no kind, CUDA if it loads, else Vulkan.
/// The backend `kind` ("cuda", "vulkan" or "hip") on GPU `device`; with no kind, CUDA if it loads, else Vulkan.
/// Refuses a `--device` list with several indices on the HIP backend: `hip::Gpu` opens one device per process
/// (hipSetDevice runs once, in `Gpu::new`), so a split over two cards would run both layers on the first one.
pub fn check_devices(kind: Option<&str>, devices: &[usize]) -> anyhow::Result<()> {
if kind == Some("hip") && devices.len() > 1 {
anyhow::bail!("the hip backend runs one device: --device {} needs cuda or vulkan", devices.iter().map(|d| d.to_string()).collect::<Vec<_>>().join(","));
}
Ok(())
}

/// Opens every device of a `--device` list, after the check above. Callers open a list through this, not one device at a time.
pub fn open_all(kind: Option<&str>, devices: &[usize]) -> anyhow::Result<Vec<Box<dyn Backend>>> {
check_devices(kind, devices)?;
devices.iter().map(|&d| open(kind, d)).collect()
}

pub fn open(kind: Option<&str>, device: usize) -> anyhow::Result<Box<dyn Backend>> {
match kind {
Some("cuda") => Ok(Box::new(crate::cuda::Gpu::new(device)?)),
Some("vulkan") => Ok(Box::new(crate::vulkan::Vk::new(device)?)),
Some(k) => anyhow::bail!("unknown backend {k:?} (cuda or vulkan)"),
Some("hip") => Ok(Box::new(crate::hip::Gpu::new(device)?)),
Some(k) => anyhow::bail!("unknown backend {k:?} (cuda, vulkan or hip)"),
None => match crate::cuda::Gpu::new(device) {
Ok(g) => Ok(Box::new(g)),
Err(c) if format!("{c}") == "CUDA init" => {
Expand Down Expand Up @@ -101,7 +117,7 @@ pub const BATCHED: i32 = 8;
pub fn upload_type(ty: GgmlType) -> GgmlType { if ty == GgmlType::F16 { GgmlType::F32 } else { ty } }

pub trait Backend: Send {
/// "cuda" or "vulkan".
/// "cuda", "vulkan" or "hip".
fn name(&self) -> &'static str;
/// The GPU's name as the driver reports it.
fn device(&self) -> String;
Expand Down Expand Up @@ -533,7 +549,15 @@ impl<'a> dyn Backend + 'a {

#[cfg(test)]
mod tests {
use super::device_order;
use super::{check_devices, device_order};

#[test]
fn hip_refuses_a_device_split_and_nothing_else() {
assert!(check_devices(Some("hip"), &[0, 1]).is_err());
assert!(check_devices(Some("hip"), &[0]).is_ok());
assert!(check_devices(Some("cuda"), &[0, 1]).is_ok());
assert!(check_devices(None, &[0, 1]).is_ok());
}

/// Identifiers are letters here. Two cards of one model have one name and two identifiers, so names play no part.
#[test]
Expand Down
Loading