LUNAR PARADOX ← LABS OBSERVATORY
SPEC-02 // VIRTUAL MEMORY PAGING FOR TRANSFORMERS

PagedAttention in WebGPU / WGSL

Hardware Virtual Memory Paging and Block-Level KV-Cache Management in Browser Shaders

LAB: Lunar Paradox Labs CATEGORY: GPU Compute & Memory STATUS: WGSL Kernel · v2.1

Research Abstract & Formulation

Serving large transformer models on consumer client hardware causes up to 85% VRAM fragmentation when allocating contiguous Key-Value cache buffers. We port vLLM PagedAttention concepts to pure WebGPU/WGSL compute pipelines, slicing sequence attention across fixed 16-token virtual pages mapped via physical GPU buffer block indirection tables, reducing allocation fragmentation to < 3.8%.

Empirical Hardware Benchmarks

Evaluation Metric Baseline / Standard Lunar Paradox Implementation Delta Improvement
VRAM Allocation Fragmentation 68% – 85% Unusable Headroom 3.8% Controlled Waste 22× Less Waste
Concurrent Sequence Capacity 1 Sequence (OOM on prompt spike) 6 Concurrent Attention Streams 6× Throughput
KV-Cache Allocation Overhead 18.2 ms GPU Reallocation Stall 0.02 ms Virtual Page Table Swap Near-Zero Host Stall
Attention Kernel Efficiency 64% Compute Peak (Memory Bound) 91% Peak WebGPU Flops Optimized Workgroup Tiling
Host-to-Device Memory Transfers Per-Token Host Sync 0 Host Roundtrips During Generation Pure GPU Autoregressive
LAUNCH 3D OBSERVATORY ↗ GITHUB ORGANISATION ↗