ggml : add HRX backend (experimental, TinyStories-15M) (#32700)
* ggml : add HRX backend (experimental, TinyStories-15M)
New ggml backend for AMD GPUs using the HRX runtime. Kernels are
written in Loom and JIT-compiled at first use. Ops are dispatched
one node at a time; shapes and strides are passed as launch scalars.
This version has only the kernels that TinyStories-15M
(stories15M-q4_0.gguf) needs, so the whole graph runs on the GPU
except the token embedding lookup. Off by default (GGML_HRX=OFF).
Ops: MUL_MAT (Q4_0, Q8_0, F16), FLASH_ATTN_EXT, SOFT_MAX, ROPE,
RMS_NORM, ADD, MUL, SWIGLU, GET_ROWS, SET_ROWS, CPY, DUP, CONT,
SCALE.
Architectures:
- static arch table (ggml-hrx-arch.h): one row per gfx target with
capabilities and per-op tune values, indexed by the weight type;
tuned on gfx1151 and gfx1201
- kernel target comes from the device; RDNA3, RDNA3.5 and RDNA4 rows
- kernels are built from Loom motifs (template families with gfx11
and gfx12 matrix-op providers and a portable provider), one kernel
source per op.
Dispatch:
- the decode matmul kernel accepts a partial last superblock for
32-value block types, so K = 288 does not fall back to the tiled
kernel
- launch configs are kept per workload, so the host does not
evaluate them again for each node
- on gfx1201 (arch table), get_tensor_async copies into mapped host
memory on the device stream; synchronize copies it out
TinyStories-15M Q4_0, -fa on:
Radeon 8060S (gfx1151): pp128 115700 t/s, tg128 3140 t/s.
* reduction of LoC by reducing to minimal required to work
* adjusting source to add aborts.
* CODEOWNERS : add HRX owners
* update HRX owners
* added IMbackK
* Update ggml-hrx.cpp
* docs : add HRX ops support
* trigger PR sync
* added additional logging for when a device id is out of range.
* fixed conflict, no further changes needed
---------
Co-authored-by: Aaron St George <aaronstgeorge@gmail.com>
Co-authored-by: Stella Laurenzo <stellaraccident@gmail.com>
Co-authored-by: Rob Suderman <rob.suderman@gmail.com>
Co-authored-by: Aaryaman Vasishta <aaryaman.vasishta@amd.com>
Co-authored-by: Aaron Teo <taronaeo@gmail.com>