# A Mojo fp16 GEMM that beats hipBLASLt on a consumer RDNA3 card (RX 7900 XTX), with the receipts

**URL:** <https://forum.modular.com/t/a-mojo-fp16-gemm-that-beats-hipblaslt-on-a-consumer-rdna3-card-rx-7900-xtx-with-the-receipts/3471>\
**Category:** Community Showcase\
**Tags:** gpu\
**Created:** [September 6, 2026, 4:59pm UTC](https://forum.modular.com/t/a-mojo-fp16-gemm-that-beats-hipblaslt-on-a-consumer-rdna3-card-rx-7900-xtx-with-the-receipts/3471 "2026-09-06T16:59:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![amarbaro](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@amarbaro](https://forum.modular.com/u/amarbaro)\
**Post date:** [September 6, 2026, 4:59pm UTC](https://forum.modular.com/t/a-mojo-fp16-gemm-that-beats-hipblaslt-on-a-consumer-rdna3-card-rx-7900-xtx-with-the-receipts/3471/1 "2026-09-06T16:59:44Z")

</div>

I spent the last few weeks writing inference kernels in Mojo for the one AMD GPU  
most people actually own: the RX 7900 XTX, gfx1100. Repo is here, Apache-2:

> **[GitHub - amarbaro/mojo-baro: Own inference stack on AMD gfx1100: Mojo GPU...](https://github.com/amarbaro/mojo-baro)**
>
> Own inference stack on AMD gfx1100: Mojo GPU kernels, self-describing GGUF engine

The short version: on square fp16 GEMM the Mojo WMMA kernel is ahead of  
hipBLASLt at all ten sizes I tested, 1.01x at 256 up to 1.35x at 1536, 1.10x at  
4096. Same shim, same warm-up, same box.

| size | 256 | 512 | 1024 | 1536 | 2048 | 3072 | 4096 |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Mojo | 6372 | 30642 | 74824 | 93632 | 91300 | 99307 | 90705 |
| hipBLASLt | 6288 | 26324 | 63623 | 69332 | 80203 | 97224 | 82437 |

(GFLOP/s. Full ten-column table and the exact command in the README.)

I want to be upfront that I did not believe this at first, and you shouldn’t  
either until you run it. My first “2x faster than hipBLASLt” number was a bug in  
my own shim: per-call workspace allocation, trusting the heuristic’s ordering,  
never setting splitK. Fixing those took the vendor from 2497 to 5201 GFLOP/s and  
wiped the lead out completely. That’s the moment I started preregistering every  
bench: question, instrument, predicted range and the falsifier get committed  
before the run, and the misses stay in the file. There are more misses than  
hits in `bench/`. Three of the four rounds on the decode-shape kernel  
falsified their own prediction.

Why I think it holds now: hipBLASLt’s tuning effort is on CDNA. RDNA3 has WMMA  
but nobody at AMD is grinding tile shapes for a gaming card. A 4x2 warp layout  
over a 128x128 block, two LDS buffers, one barrier per K-step, two-deep global  
prefetch, XOR-swizzled A, transposed B. 188 VGPR, zero spills. Nothing exotic.  
The thing that actually moved the needle was boring: dispatching on block  
count so small sizes get a 64x64 tile instead of starving the GPU, and warming  
the clocks for 10 s instead of 1 s. That warm-up alone was the difference  
between 66k and 91k at 4096³ on the identical binary. If your AMD numbers look  
noisy, check that before touching the kernel.

There’s also a working end-to-end decode engine on top of this, bf16 and q8  
Qwen GGUF, 64 tokens bit-identical to llama.cpp on the same file. Trunk decode  
is 0.94x llama.cpp without speculation. With MTP speculative decode it’s 1.33x  
on the race prompt and 0.78x on real text, so llama.cpp still wins where it  
counts there, and I say so in the README rather than picking the flattering  
number. Persistent megakernel (one launch per decode token, 32 layers plus  
head) is the current line of work and is what’s in `main` today.

Things I’d genuinely like from this forum:

- Someone with a 7900 XTX or XT running `bench/fp16-templates.sh` and posting  
what they get. One box is one box.
- Anyone who knows whether `rocdl.flat_work_group_size` via StaticTuple is the  
intended way to lift the 256-thread cap from Mojo, or whether I’m holding it  
wrong. It works, but it feels like I found a side door.
- fp32 WMMA does not exist on gfx1100. I verified it against llvm-mc and the  
builtin table, but if Modular has a cleaner story for fp32 on RDNA3 I’d  
rather use it than my workaround.

Happy to answer anything about the protocol. The whole point of the repo is that  
the numbers are checkable, so please check them.

---

<div class="post-metadata">

**Author:** ![amarbaro](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@amarbaro](https://forum.modular.com/u/amarbaro)\
**Post date:** [November 9, 2026, 1:30am UTC](https://forum.modular.com/t/a-mojo-fp16-gemm-that-beats-hipblaslt-on-a-consumer-rdna3-card-rx-7900-xtx-with-the-receipts/3471/2 "2026-11-09T01:30:24Z")

</div>

The repo moved, so the link above is dead. It now lives at [GitHub - amarbarosys/mojo-baro: LLM inference on AMD RDNA3, every GPU kernel in Mojo · GitHub](https://github.com/amarbarosys/mojo-baro) (`bench/fp16-templates.sh` is still there).

What changed since September:

- Decode is now 1.34x llama.cpp on Qwythos-9B Q4\_0: 148.89 against 111.34 tok/s, 20-prompt median, both measured in the same stint. q8 is still behind (0.94x).
- 15 models across 6 architectures run, each checked against llama.cpp on the same GGUF. A 35B MoE is level with llama.cpp.
- There is an OpenAI-compatible server now, with MTP speculative decode on by default (output identical to greedy) and sampling on the device.
- A cold-cache M=1 decode kernel beats hipBLASLt by about 1%.

Three stranger ones:

- **Latent reasoning trained in seconds.** A small model learns an 8-hop task with continuous thoughts (Coconut-style, no recompute) to over 99.5% on 4,096 untouched cases, in under 9 seconds of training on the one card. Forward, backward and AdamW are all Mojo kernels. The bar was preregistered, and it failed once (shared card) before it passed on fresh seeds (`miniagi/README.md`).
- **Huge models on a 24 GB card.** Qwen3.8-Flash-Next, a 512-expert MoE, runs in two builds: the 74.5 GB UD-IQ1\_M at 50 to 59 tok/s, and a 63 GB GSQ Q2\_0 at about 48 tok/s (20.7 ms/token with a warm expert cache). Hot experts stay in VRAM and the rest come from system memory. The IQ1\_M build agrees with llama.cpp on 97.66% of tokens, against 97.34% for llama.cpp’s own CPU run.
- **Model files that describe themselves.** A bake writes the exact kernel sources, the run recipe, a reference prompt and its tokens into the GGUF. `tools/gguf-closure.sh` rebuilds the engine from that file alone and checks it reproduces the tokens, so a number in the README can be traced back to the code that made it.

One correction: I no longer quote 4096³ for the GEMM. Its buffers are larger than the 96 MB Infinity Cache, and the same binary ranged from 91k to 99k GFLOP/s, so the 1.10x there was noise. The other sizes hold.

The ask is the same, a bit easier now: if you have an AMD GPU that is not a 7900 XTX, `docs/amd-family.md` takes fifteen minutes and needs no model weights.

---

<div class="post-metadata">

**Author:** ![maxchisto](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/maxchisto/32/948_2.png) [@maxchisto](https://forum.modular.com/u/maxchisto)\
**Post date:** [November 10, 2026, 7:06pm UTC](https://forum.modular.com/t/a-mojo-fp16-gemm-that-beats-hipblaslt-on-a-consumer-rdna3-card-rx-7900-xtx-with-the-receipts/3471/3 "2026-11-10T19:06:08Z")

</div>

I’m on RDNA4 and can’t help you with replicating your results, but you’ve given me ideas to try out.  
I’ve encountered this bug: [[BUG]: MAX stock fp32 matmul is order of magnitude slower than rocBLAS on AMD RDNA4 · Issue #7331 · modular/modular · GitHub](https://github.com/modular/modular/issues/7331) and rolled my own fp16 and fp32 matmul. Def didn’t grind tile sizes very hard.

Happy to contribute to `docs/amd-family.md`, but I do believe fp16/fp32 matmul is broken on RDNA4 atm

---

<div class="post-metadata">

**Author:** ![amarbaro](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@amarbaro](https://forum.modular.com/u/amarbaro)\
**Post date:** [November 14, 2026, 6:22pm UTC](https://forum.modular.com/t/a-mojo-fp16-gemm-that-beats-hipblaslt-on-a-consumer-rdna3-card-rx-7900-xtx-with-the-receipts/3471/4 "2026-11-14T18:22:47Z")

</div>

@maxchisto thanks for #7331, and for offering docs/amd-family.md.

What I found on the issue ([[BUG]: MAX stock fp32 matmul is order of magnitude slower than rocBLAS on AMD RDNA4 · Issue #7331 · modular/modular · GitHub](https://github.com/modular/modular/issues/7331)): it is open, labelled bug, max and bug\_feature\_triaged, with no comments, no assignee and no linked PR as of today. It measures fp32 `ops.matmul` on a gfx1201 card at 452.7 GF/s for 1024^3 against 5840.4 GF/s for rocBLAS (12.9x), and 473.2 against 10270.2 at 2048^3 (21.7x). So what is documented there is a throughput gap, not wrong results, and fp16 does not appear in it. I cannot confirm or refute your reading that fp16 is broken on RDNA4: nothing in the issue says so, and I have no RDNA4 card. If your fp32 matmul is 10x faster than stock and 5% behind rocBLAS, that is worth the PR you offered on the issue.

What mojo-baro has for RDNA4, and what it does not:

- It builds. Every intrinsic and the engine compile for gfx1200 and gfx1201 (the probe table is in `docs/rdna4/`). On gfx12 the 8-wide WMMA fragments lower and the gfx11 16-wide ones do not, as expected.
- gfx12 hands back the accumulator rows in a different order (`i + 8*half` instead of `2*i + half`). I ported every epilogue site and emulate the gfx12 order on my 7900 XTX: parity 7 of 7 in both modes, 13 of 13 planted defects caught, engine output equal on 20 of 20 prompts.
- It has never run on a gfx12 card. Speed, fp16 correctness, clocks and driver behaviour there are all unverified, and `docs/rdna4/README.md` says so. The emulation does not model one stdlib detail in the attention repack, and two other files are not ported yet.

You can check the part I could not, without any model weights:

```auto
git clone https://github.com/amarbarosys/mojo-baro && cd mojo-baro
uv sync
bench/rdna4-selftest.sh

```

It prints your card (gfx, compute units, ROCm, Mojo), which of our intrinsics compile for your gfx, a 16x16x16 f16 WMMA test run on the card (pass bar 2^-19 of the sum of |a\*b|), and the amdgpu kernel log lines. It writes one local file and sends nothing. On my 7900 XTX the WMMA line is `PASS wmma-gfx: 256/256 within 2^-19 sum|ab|, K=64`. A failing section is the useful part of the report. The full fp16 GEMM benchmark, `bench/report.sh`, is the fifteen-minute one in `docs/amd-family.md`.

If you post the output as a hardware report issue, or send a PR to `docs/amd-family.md` with what you find on your card, I will use it to fix the first thing that fails.

What else mojo-baro does now, besides the points in my last post (all in the public repo, with the checks beside them):

- **Many sessions on one engine.** `baro-serve --parallel N` shares one weight copy and the prompt prefix between N sessions and decodes them in batched steps. On a 9B Q4\_K\_M model with a fresh game state per request, 32 sessions give 112.5 tok/s in total, against 65.9 for our serial server and 42.5 for `llama-server --parallel 32` (`docs/design/multi-session-serve.md`). Past the KV pool it answers HTTP 429, not a failure mid-decode: a burst of 100 requests at `--parallel 32` gave 36 of those and no 5xx. One session alone is slower than llama-server, 61.3 against 70.6 tok/s, and against llama-server’s tokens our agreement missed its bar (86.3% against its own 92.7%, cause not found).
- **Q4\_K\_M files run as they are.** The engine reads Q4\_K and Q6\_K rows directly: prefill of 1,024 tokens takes 0.259 s against llama.cpp’s 0.298 s, and 16,384 tokens 4.54 s against 5.66 s (Mojo 1.1). On Mojo 1.2 the K-quant megakernel is slower than the launch path, 87.9 against 98.3 tok/s, and I do not know why yet.
- **More of the API.** OpenAI `tool_calls` with `tool_choice`, JSON-schema output enforced by a token mask on the device (the model cannot emit a token that breaks the schema), sampling on the GPU, Ollama routes on the same port, and a non-zero engine fail word returns HTTP 502 instead of bad text. `tool_choice: auto` does not restrict which tool names the model may call.
- **Model state you can hand off.** A live KV cache moves between two engine processes over HIP IPC: 40 MiB in 0.42 ms, 15.2x faster than our memfd path, with every float of K and V equal (`bench/kv-ipc-protocol.md`). The recurrent SSM and conv state (52.69 MB) forks into a sealed memfd in 5.05 ms and resumes in 3.95 ms, against 266.92 ms for a cold prefill. State files are compressed 1.97x (67.17 to 34.10 MB) and load 1.92x faster, and the checkpoint API forks, exports and imports them over HTTP (`docs/releases/v0.3.0.md`). A one-to-one state handoff between engines answers exactly as the text handoff does (79 of 120 both). What failed: injecting a raw hidden state into another model (it ends up nearly text), and whether a crew of handoffs beats one model is not tested, so I do not claim it.
- **A certificate that the math was right.** A per-token Freivalds check verifies the GPU matrix products with a random vector: 336 of 336 honest checks pass, 7 of 7 planted kernel bugs are caught, and a planted GEMV bug fails all 64 tokens. In the engine it checks one layer and leaves the output unchanged on 20 of 20 prompts. It costs 0.23 ms per token (2.3% slower), so it is off by default (`BARO_CERT=SEED`).
- **Long context in 24 GB.** int8 KV takes 33,280 bytes per token instead of 131,072. A dense 27B loads to 163,840 tokens on one card (about 131,072 usable next to a desktop), the RULER needle test (`niah_single`) scores 100.0 at 64k and 128k, and a 32k state file loads in 0.061 s. Off by default (`BARO_KVQ=int8`); agreement with f32 KV is 99.1% on average, 96.9% at worst, over 20 prompts.
- **Several GPUs and machines.** `tools/baro multi-serve MODEL.gguf --devices 0,1` starts one pinned server per GPU behind `baro-router`, which finds nodes over mDNS and places requests by model, load and where a request’s state already lives. I checked the wiring with the 7900 XTX and the iGPU each pinned to one engine; there is no throughput number for it yet.
- **The same bits on CPU and GPU.** Shared exp, log, rsqrt, sin and cos give bit-identical results on both sides for 40,017 of 40,017 float inputs, within 1 ulp of the standard functions. It costs 3.6x a plain exp in an exp-bound kernel, so it is off by default (`-D BARO_SHARED_EXP=1`).
- **Embeddings without a GPU.** `baro-serve --embed-only` serves `/v1/embeddings` with bge-small-en-v1.5 on the CPU, and a gate compares 30 texts with the ONNX model (cosine at least 0.9999).
- **A window.** `tools/baro gui` opens chat with an engine panel (queue, tok/s, VRAM, fail word), every setting as a control, eight presets, and an Apply step that says which changes need a restart before it restarts the server. Its checks read rendered frames back with OCR. The frame cap defaults to 30 fps because at 60 a resident 9B engine lost about 13% on some prompts. The public README says an Apply restart on a real engine is not verified yet.
- **Small models.** Llama 3.2 1B decodes at 558 to 563 tok/s against 412.9 for llama.cpp in the same job (21 prompts, median); MiniCPM5-2B at 233.3, and a Mistral-family 7B at about 95. The Llama agreement row has not been re-run since a RoPE fix.
- **A CPU engine.** `cpu/engine_cpu.mojo` decodes dense qwen35 on the CPU: 1,280 of 1,280 ids agree with the GPU build, at 6 to 7 tok/s on 8 threads. It is correct and slow, and has run on one machine.

Expect bugs in all of this, and reports are welcome.
