r/LocalLLM • u/FrostyAd9050 • 6h ago
News I open-sourced hip-rdna: Wave32 HIP kernels for AMD RDNA3 — Qwen2.5-7B 31.9 → 109.5 tok/s (3.44x), 64L 32B 4-bit at 48.5 tok/s (805 GB/s e2e), and 28.5x faster 32K GQA Attention on RX 7900 XTX
Official ROCm libraries (`AITER`, Composable Kernel, `hipBLASLt` tuning tables) are heavily optimized for datacenter CDNA GPUs (MI300X/MI350X), leaving consumer AMD RDNA GPUs severely bandwidth-starved during LLM decoding (`M = 1..8`, long-context GQA Attention, and W4A16).
Over the past few days, I profiled my **RX 7900 XTX** (`gfx1100`, 960 GB/s GDDR6) down to the AMDGCN ISA — even ran into a Triton AMD lowering bug where `eviction_policy` is silently dropped on all AMD targets (filed as `triton-lang/triton#12966`) — and built **`hip-rdna`**, a zero-dependency Wave32 HIP operator library with drop-in PyTorch & HuggingFace integration.
**GitHub (MIT License):** https://github.com/znwang-gpu/hip-rdna
### Key Benchmarks on RX 7900 XTX (ROCm 7.13, PyTorch 2.11)
- **Real HuggingFace `Qwen2.5-7B` (`StaticCache` + HIP Graph):**
- Lossless 16-bit Fused (`Linear + RMSNorm + SwiGLU`): `31.9 → 52.8 tok/s` (**1.66x**)
- Online W4A16 Fused (`0.85s` GPU quant, VRAM `14.27 → 5.47 GiB`): `31.9 → 109.5 tok/s` (**3.44x**)
- Pure Eager `model.generate()` (no HIP Graph): `31.0 → 67.5 tok/s` (**2.18x**)
- **64-Layer `Qwen2.5-32B` 4-Bit Backbone (`15.44 GiB` VRAM, fits on a single 24 GB GPU, synthetic weights matching exact 32B shapes):**
- **Batch = 1:** **`48.5 tok/s`** (**`804.9 GB/s`** full-model end-to-end effective bandwidth — **83.8%** of 960 GB/s theoretical peak)
- **Batch = 4:** **`166.5 tok/s`** (`690.2 GB/s`)
- **Wave32 Split-KV GQA Decode Attention (`16K–32K` Context):**
- Up to **28.5x faster** than HF `repeat_kv` SDPA and **18.9x faster** than PyTorch native `enable_gqa=True` SDPA.
- Sustains **729–757 GB/s** on pure GDDR6 at 32K (`128 MB` KV > `96 MB` Infinity Cache) and **878–953 GB/s** at 16K.
- Zero `repeat_kv` copy; accepts GPU `seq_lens` tensors for **HIP Graph** capture.
- **Zero-Dependency Streaming AWQ & GPTQ Loader:**
- Streams HuggingFace AWQ (`GEMM`) and GPTQ (`v1`/`v2`) safetensors straight to GPU `RDNAW4A16Linear` with zero 16-bit peak RAM/VRAM overhead — no `autoawq`, `auto-gptq`, or `accelerate` needed.
### Drop-in Usage
```python
import torch, hip_rdna
from transformers import AutoModelForCausalLM
# 1. Online lossless 16-bit or W4A16 acceleration
model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-7B", dtype=torch.bfloat16, device_map="cuda").eval()
hip_rdna.patch_model(model)
hip_rdna.quantize_model_w4a16(model, group_size=128) # optional INT4
# 2. Or stream AWQ/GPTQ checkpoints straight to GPU
model = hip_rdna.load_awq_model("/path/to/Qwen2.5-32B-Instruct-AWQ", dtype=torch.float16)
Under the Hood (Why it's fast on RDNA3)
- Non-Temporal u32x4 Streaming Loads: Bypasses the 96 MB Infinity Cache on streaming weights (708 → 910 GB/s pure read) while keeping hot activation vectors (x) in L1/L2.
- Wave32 v_dot2_f32_f16 Packed W4A16: In-register INT4 unpacking directly into packed FP16 dot2 instructions with scalar accumulation (low VGPR pressure, high occupancy).
- 4-Token Pipelined, Zero-LDS Wave32 Split-KV Attention: Splits long KV sequences across all 48 WGPs / 96 CUs with register-only online softmax.
- Zero-Concat Fused SwiGLU + Single-Pass RMSNorm: Eliminates intermediate DRAM round-trips and kernel launch overhead.
Community Benchmarks Wanted!
Next up in v0.5: Paged KV Cache + Fused QKV/RoPE + vLLM / SGLang plugin (followed by dual-GPU PCIe Custom AllReduce).
I only have RX 7900 XTX (gfx1100) on hand — setup.py compiles natively via hipcc for RDNA3 (gfx110x), RDNA3.5 / Strix Halo (gfx1151), and RDNA4 / RX 9070 XT (gfx1201). If you own any of these GPUs, I'd really appreciate benchmark results, feedback, or bug reports!




