garlic-llm-ps4: Garlic LLM Wrote the Driver the PS4 Never Shipped

A homebrew app runs a nine-billion-parameter model on a 2013 console by skipping the system software entirely, hand-building the GPU command packets a driver would normally generate.

~10 min read • View on GitHub • More from spinzar

An editorial ink illustration of an opened 2013-era game console on a workbench, top shell removed to expose the mainboard. A human hand holds a fine tool and reaches past a set of severed, frayed cables to touch one small exposed chip. From the chip rises a neat stream of small rectangular command packets, each a tiny grid of squares, while the severed cables hang slack and useless.
The severed cables are the driver that was never handed over. The clean, taut wire is the hand-built command stream that replaces it. This is the thesis of the entire project in one image.
Key Takeaways

The Driver Is the Program

The PlayStation 4 hands homebrew developers nothing for general-purpose compute. There is no CUDA, no ROCm, no OpenCL runtime, no ML library. The console's GPU is reachable through the system software that ships with it, and that path is closed to unsigned code. So Garlic LLM does not call a driver. It is the driver.

The engine writes PM4 command packets by hand, the GPU's native instruction stream. The header of engine.c spells out the vocabulary: shader-register offsets like SH_START_X and SH_NUM_THREAD_X, event codes like EV_CS_PARTIAL_FLUSH. For every token the engine builds a command buffer, and inside that buffer sit roughly 400 compute dispatches. Each one is followed by a partial flush and an acquire, and the whole run ends with an end-of-pipe event that writes a label the CPU polls in a loop until it flips.

A driver, mechanically, is a program that assembles a packet stream and polls for completion. This project does that by hand, per token, hundreds of times over.

That polling loop is the heartbeat of the design. The CPU submits work, then waits on a label the GPU writes when the pipe drains. There is no interrupt, no async runtime, no scheduler. Just a tight loop and a shared flag. The cost of all those per-dispatch fences is real, and it is a measurable share of the time budget. The speed figures the project reports, 31 to 39 tokens per second for chat and up to 43 for code, are the author's own measurements and have not been independently verified.

Onion and Garlic

The PS4 splits its memory into two buses with two very different personalities. "Onion" is CPU-cached and coherent with the GPU. It is comfortable for the CPU to write and read, and it is where the application draws its UI. "Garlic" is write-combined and GPU-favored. It is fast for the GPU to read and awkward for the CPU to touch, because writes do not behave like ordinary cached memory. The project is named after the bus it lives in.

That split shapes everything downstream. The UI draws into cached memory and then copies the finished frame into the write-combined framebuffer, which is the classic fast-write pattern applied to a console with no graphics library. The engine's weights, KV cache, scratch space, and command buffers all live on the Garlic side, because that is the memory the GPU reads fastest. The name is not a mascot. It is a location.

An editorial ink illustration of a close-up workbench still life: a garlic bulb and an onion sitting side by side, with a single glass jar wedged and straining between them, packed to the brim with small labeled weights. A thin measuring line runs across the top of the jar showing only a sliver of headroom before the lid.
The garlic and the onion are the console's two memory buses. The packed jar is the nine-billion-parameter footprint, and the sliver of headroom at the top is the margin the engine reserves for system dialogs.

One Block of Memory, Negotiated at Runtime

Everything the GPU touches lives in a single contiguous Garlic block, handed out by a bump allocator called gpu_alloc. Because it is one arena, GPU addresses are plain offsets, and nothing has to be tracked across separate allocations. But the interesting part is how the arena gets its size.

static uint64_t gpu_alloc(Engine* e, uint64_t size) {
    uint64_t off = (e->next + 255) & ~255ull;
    if (off + size > e->mem_size) return 0;
    e->next = off + size;
    ...
}

// reserve_garlic() probes the console for the largest block it can get:
for (uint64_t m = (sceKernelGetDirectMemorySize() >> 20) & ~31ull; m >= 1024; m -= 32) {
    // try allocate, map, unmap, release; keep the first size that works
}

That probe walks the memory down in 32 MiB steps until it finds the largest block that fits, then re-allocates with a 64 MiB margin reserved for system dialogs. A comment in the source explains the coupling: the margin shrinks to 32 when main.c has already taken 32 MiB for its screen copies. This is a nine-billion-parameter model's footprint being negotiated with the operating system at launch, on a console with a fixed pool and no swap. There is no config file that states the budget. There is a loop that discovers it.

Borrowed Memory

The cleverest coordination pattern in the repository is a piece of memory sharing that forces a real tradeoff. Speculative decoding needs a draft head, the MTP model that Qwen3.5 ships with. Voice mode needs the Chatterbox TTS weights. On a console this tight, they cannot both hold memory at once. So the draft head borrows the TTS model's weight memory. spec_load lends it the space, and when voice mode starts, T3's weights are read back in. The two features are mutually exclusive in memory by design.

That is why the README is honest about voice mode being slower. Spoken chat drops from roughly 39 tokens per second to around 22, because the voice model is occupying the memory that speculative decoding would otherwise use to draft tokens ahead. The project could have hidden this. It states it plainly instead.

The draft head also carries a sliding position base, a field called pbase, so it can resume correctly after voice mode interrupts a conversation. RoPE attention depends only on the distance between positions, so a head that starts mid-conversation behaves the same as one that began there. It is a small insight about rotary embeddings that saves a full recompute. Runtime tuning lives in a plain text file, /data/garlic_spec.txt, holding a draft count and a probability threshold, both clamped to safe ranges. If any of the expected kernels or magic bytes are missing at load time, speculation simply switches off and the engine falls back to ordinary decoding.

The Comparison

The useful comparison is not which system is fastest. It is how each one reaches the silicon. Garlic LLM hand-builds packets against GCN. PS5LM runs llama.cpp through PS5_Vulkan, a port of the RADV driver. llama.cpp runs on a general-purpose backend on hardware that has a full operating system underneath it. As before, the speed figures here are project-reported and unverified.

Garlic LLMPS5LMllama.cpp
Target hardwarePS4 GCN GPU (2013)PS5 GPUAny Vulkan / CUDA / Metal GPU
How it reaches the GPUHand-built PM4 command packets. No driver.llama.cpp through PS5_Vulkan (a RADV port)Mature backend abstraction
ModelQwen3.5-9B, custom Q4/Q3, 4-bit KV cachellama.cpp-supported modelsAny supported GGUF
Runs offlineYesYesYes
Needs a PCNoNoYes
What it depends onGoldHEN, OpenOrbis toolchainPS5 homebrew stackA general-purpose OS

The original PlayStation 4 is running a 9-billion-parameter AI model, the 2013 console. Developer Leonardo Alegría created Garlic LLM, running Qwen3.5-9B directly on the PS4, completely offline and without Linux or an external PC. It reaches up to 39 tokens per second using htt

Pirat_Nation, Post on X · @Pirat_Nation on X

One Author, Two Commits, a 147-Page Guide

Step back from the hardware and look at the human scale. The repository is young, has one visible contributor, and almost no social footprint, while the engineering is deep enough to warrant a paid guide, Nine Billion Parameters on a PS4, that the README presents as the write-up of the techniques, the measurements, and the dead ends. The gap between the ambition and the footprint is the story here, not the biography.

A note on attribution. Coverage of this project names developer Leonardo Alegría and a repository under leonardo-alegria. The supplied sources do not confirm that this is the same repository as spinzar/garlic-llm-ps4, a fork of it, or a separate project. Treat the connection between those names as unverified until it is checked directly.

I made this, so a quick note: it’s my open-source project. Qwen3.5-9B runs on a stock PS4 at 31–39 tok/s. The MTP head that ships with Qwen3.5 made the biggest difference: it drafts up to two tokens and the full model checks them in one pass, which took it from 22 to 31–39 tok/s on this old GPU.

Leonardo Alegría, Project creator, as identified by the source · leonardo-alegria/garlic-llm — Shadowgraph

What remains is a single sentence a driver would have been doing all along: assemble the packets, submit them, wait for the pipe to drain, read the result. Garlic LLM does that by hand, every token, on a console that shipped without a translator. That is what it costs to speak to hardware in its own language when nobody handed you the words.