A few days ago I posted this project in the wrong section (AMD AI instead of AMD Projects Showcase), reposting here with proper context, since quite a bit has changed since the first version.
What do you do when you want to run an LLM on a consumer AMD card, but you don’t want to rely on heavy frameworks? You build the entire stack yourself.
VTE (Vector Tensor Engine) is an inference engine built directly on top of the AMD HIP runtime. There is no llama.cpp, no ONNX Runtime, no vLLM, and no PyTorch underneath it. VTE parses the GGUF file, generates the HIP C++ kernels on the fly, compiles them with hipcc at runtime, and drives amdhip64.dll through a hand-written Python ctypes bridge.
The entire project has been developed, tuned, and verified on a single consumer desktop card: an AMD Radeon RX 7600 (RDNA3, gfx1102, 8GB VRAM).
Why build from scratch?
The goal wasn’t to compete with enterprise data-center runtimes, but to gain complete, granular control over every byte moving between VRAM and the ALUs, and to make every optimization decision from an actual measurement on this specific hardware, not from what works on an MI300X or an RTX 4090. On a consumer card with tighter memory bandwidth and a limited CU count, enterprise defaults don’t always transfer.
What’s new: a second, genuinely different architecture
The original version only ran Qwen2.5-1.5B. Since then I added IBM’s Granite 4.1 3B (Q8_0) as a real stress test of whether the hand-rolled engine actually generalizes, or just happens to work for one model. Granite is roughly 2x the parameters and uses a different RoPE rotation convention, different scale factors, and a different quantization format, not just a bigger version of the same thing. Getting it running correctly surfaced a genuinely interesting bug: llama.cpp’s source confirms Qwen2.5 uses the “NEOX” RoPE convention (split-half pairing) while Granite uses “NORM” (interleaved pairing), two different math conventions, not a parameterization of the same one. Running Granite through NEOX-only kernels produced fluent-looking but garbled, mixed-language output, the kind of bug that looks like a model problem instead of an engine bug. Both models now run correctly and are switchable at runtime from the same engine.
Benchmark: VTE vs. Ollama (llama.cpp)
This is the number I’m most proud of. Same GGUF files on disk for both engines, same prompt, temperature=0, decode-only timing:
| Model | VTE | Ollama (llama.cpp) | VTE / Ollama |
|---|---|---|---|
| Qwen2.5 1.5B (Q4_K_M) | 101.68 tok/s | 114.67 tok/s | 88.7% |
| Granite 4.1 3B (Q8_0) | 45.66 tok/s | 51.46 tok/s | 88.7% |
The identical ratio across two very different architectures is the interesting part — it suggests the remaining gap is systemic kernel/dispatch overhead across the whole engine, not an architecture-specific bug hiding in one model. And worth stating plainly: the code doing the dispatching here is Python, driving every HIP launch through ctypes — not C++. Landing at ~89% of a mature, years-tuned C++ engine’s throughput with that much interpreter overhead in the loop is the actual evidence that CPU-side dispatch overhead is a solvable engineering problem, not an inherent language tax.
Single-Sequence Decode journey (Batch = 1)
| Stage | Throughput | What changed |
|---|---|---|
| Naive per-thread GEMV | ~18.8 tok/s | Baseline: one thread per output element, no coalescing |
| Coalesced GEMV | ~31.5 tok/s | Threads in a block cooperate on one output neuron, coalesced weight reads |
| In-kernel dequantization | ~37.9 tok/s | FFN weights dequantized inline during the GEMV, instead of a separate pass |
| QKV Two-Pass Split-K fusion | ~41.0 tok/s | Fills all 32 CUs instead of leaving most idle |
| Vectorized sampler + LM Head in graph + Split-KV attention | ~78–79 tok/s | Removed CPU-side sampler overhead, eager LM Head launch, and low attention occupancy |
| Keep-alive pulse removed | ~100 tok/s | A safety pulse against WDDM downclocking had quietly become the largest artificial cost once everything above got fast enough |
None of the last few rows touched a GEMV kernel’s core math, all of it came from profiling the real per-token wall-clock budget and finding non-algorithmic costs, one at a time.
Batched Decode
Batch 1: 110.7 tok/s · Batch 2: 165.3 tok/s (75% linear efficiency) · Batch 4: 204.2 tok/s (peak) · Batch 8: 193.5 tok/s (regresses, Infinity Cache thrashing at that batch size, FFN weights no longer fit alongside the rest of the working set).
How it fits together
vte/bridge: the driver interface — a ctypes wrapper foramdhip64.dll, a slab allocator to bypass repeatedhipMallocoverhead, a Kernel Watchdog against Windows TDR hangs, and a userspace duty-cycle limiter keeping the desktop responsive under sustained load.vte/compiler: GGUF parsing, byte-exact Q4_K/Q6_K/Q8_0 dequantization, an IR graph builder that reasons about RDNA3 VGPR/LDS limits for safe kernel fusion, and from-scratch tokenizers for both architectures.vte/core: captures the entire per-token decode path into a HIP Graph and replays it, eliminating almost all Python-side dispatch overhead.vte/ui: new since the last post — a Flet desktop app with a live GPU telemetry dashboard (tok/s, VRAM, temperature via AMD’s ADL), runtime model switching between the two architectures without restarting the process, and a pt/en interface toggle.
Hunting silent data corruption
The hardest bugs here never crashed, they produced fluent, plausible-looking garbage. A few favorites: a kernel argument mismatch that silently processed 1 of 8,960 FFN elements per pass; logits read back at the wrong bit-width, producing magnitudes of ~1e7 instead of ±40 from a perfectly healthy hidden state; a KV cache layout bug where every layer’s V-cache silently overwrote the previous layer’s K-cache. And, more recently, the RoPE convention mismatch mentioned above. The full bug history, symptom, root cause, fix, and the actual measurement behind each one, is documented in the repo for anyone curious how these get found in practice.