Skip to content
Mayur ReddySenior Software Engineer, AI & Data
Menu

Murmur

2026

From-scratch C++/CUDA LLM inference engine with a paged KV cache, continuous batching and FP8/INT4 weights, driving 32 talking NPCs at 60 fps.

View on GitHub ↗

The Murmur night market at night, with neon storefronts, NPCs and their speech bubbles.

Murmur is a rainy cyberpunk night market where every NPC thinks on an LLM inference engine I wrote from scratch in C++ and CUDA. You walk up to anyone and type. They answer token by token, remember you, and act on what they say. The X-ray view lays the engine over the town: KV-cache pages filling and evicting, NPCs joining and leaving the batch, and the GPU time each frame spends rendering versus thinking.

It serves Qwen2.5-1.5B-Instruct on one RTX 4080 SUPER while the game holds 60 fps.

What I built

  • Hand-written CUDA kernels: RMSNorm, RoPE, matrix-vector, a mixed-input tensor-core GEMM, FlashAttention-2-style prompt attention and split-K decode attention, and sampling on the GPU.
  • A paged KV cache with prefix caching: the city lore every NPC shares is computed once.
  • Continuous batching with chunked prefill and priorities, so the player’s reply comes before the market’s chatter.
  • FP8 and INT4 weights and a BF16 or FP8 KV cache, switchable live while everyone keeps talking.
  • Grammar-constrained decoding: every NPC action is one the game can run (walk, call, hack, give, sell).
  • Speculative decoding with a 0.5B draft model.
  • A correctness harness that checks every intermediate tensor against the Hugging Face reference.

Results

Correctness within 1e-3 of Hugging Face at all 170 checkpoints; identical greedy tokens
One conversation (BF16) 188 tokens/s, 80% of the memory-bandwidth limit
64 conversations (BF16) 6,317 tokens/s, each still 99 tokens/s
FP8 / INT4 weights 1.7× / 2.2× faster decode, perplexity +2% / +9%
NPC actions 256 of 256 valid under the grammar (84% as free text)

Against vLLM 0.28, same model, GPU and 64-request workload, FP8 weights on both: first token 9.9 vs 18.0 ms, one conversation 329 vs 166 tokens/s, 64 at once 7,373 vs 6,294 tokens/s. The profile that got it there: Nsight showed decode and prompt attention dominating, so both kernels were rewritten (64-request GPU time 3.77 s → 2.75 s).

Limits

  • One consumer GPU and a 1.5B model. No multi-GPU or tensor parallelism.
  • With BF16 weights Murmur trails vLLM from 32 requests on (82% of it at 64).
  • Speculative decoding is exact but measured 0.88×–1.01× on this model pair, so it is off by default.

Figures

The X-ray view over the market, showing model memory, KV-cache pages, the batch and NPC actions.
The X-ray view over the market, showing model memory, KV-cache pages, the batch and NPC actions.

← All projects