Memory that isn't physically there.
Status (July 2026): experiment concluded. This repo is preserved as the record.
PhantomRAM set out to make a $150 NVMe drive stand in for DRAM during LLM inference by prefetching along a known access order. Read this before the pitch below, because the headline numbers did not survive scrutiny:
- The 27x figure in the whitepaper and benchmark scripts compares readahead disabled (
MADV_RANDOM) against readahead enabled and boosted (MADV_WILLNEED+MADV_SEQUENTIAL). It measures kernel readahead, and a fair baseline was never run. Treat every 27x claim in this repo accordingly.- Steady-state token generation is bandwidth-bound. With a DRAM buffer smaller than the model, every token re-reads evicted layers, which caps a 70B Q4 model at roughly 0.2 tok/s on Gen4 NVMe (measured: 0.4 tok/s at a 36% hit rate, see
docs/docker-validation-report.md). No prefetch schedule crosses that wall, and Gen5 doesn't either.- What prefetch genuinely won: one-pass phases. On a real 70B run, model load was 1.91x faster and prompt eval 2.27x faster, with token generation unchanged. Those runs used a later v0.3 prefetcher whose code was lost before this snapshot; the numbers stand as recorded.
Everything below this line is the original pitch, kept as written.
The AI memory crisis is the single biggest bottleneck to democratizing intelligence. Running a 70B parameter model requires ~140GB of DRAM in fp16 — that's a $40,000 H100 or five-figure workstation. Even quantized to Q4, 70B needs ~40GB just for weights, plus KV cache, activations, and optimizer states.
DRAM prices are driven by an oligopoly (Samsung, SK Hynix, Micron). Capacity per DIMM slot is capped by motherboard manufacturers. The industry's answer — HBM — costs $2,000+ per chip and is supply-constrained until 2027+.
Meanwhile, a 4TB PCIe Gen4 NVMe drive costs $150 and reads at 7 GB/s.
Make a $150 NVMe drive behave like DDR5 for AI workloads.
Not by reinventing physics — by exploiting a critical insight: AI inference is deterministic. When running a 70B model, the execution follows a strict layer-by-layer order. Layer 1, then Layer 2, then Layer 3. If you know what memory will be needed 50ms from now, you can prefetch it from NVMe into a tiny DRAM buffer before the GPU asks for it.
The CPU never sees a cache miss. The GPU never stalls. The model runs — slower than pure DRAM, but it runs — on hardware that costs 1/10th as much.
┌─────────────────────────────────────────────────────┐
│ AI Application (PyTorch / llama.cpp) │
│ Unmodified — sees normal memory space │
├─────────────────────────────────────────────────────┤
│ phantom_ram.py (Python wrapper) │
│ - Hooks into model execution graph │
│ - Registers tensor memory regions │
│ - Drives the prefetch scheduler │
├─────────────────────────────────────────────────────┤
│ libphantom.so (C core library) │
│ ┌───────────────┬──────────────┬────────────────┐ │
│ │ userfaultfd │ prefetch │ nvme_streamer │ │
│ │ handler │ scheduler │ │ │
│ │ │ │ │ │
│ │ Intercepts │ Predicts │ Async DMA from │ │
│ │ page faults, │ next-N pages │ NVMe to DRAM │ │
│ │ serves from │ based on │ buffer, with │ │
│ │ DRAM cache │ exec graph │ io_uring for │ │
│ │ or triggers │ │ zero-copy │ │
│ │ recompute │ │ │ │
│ └───────────────┴──────────────┴────────────────┘ │
├─────────────────────────────────────────────────────┤
│ Linux Kernel │
│ userfaultfd + io_uring + direct I/O │
├─────────────────────────────────────────────────────┤
│ NVMe SSD (model storage) │
│ 4TB @ 7 GB/s = $150 │
└─────────────────────────────────────────────────────┘
| Phase | What | How |
|---|---|---|
| v0 | userfaultfd prototype | Pure userspace. Map model to virtual memory, intercept faults, stream from NVMe. Proves the concept. |
| v1 | Kernel module + recomputation | recompute_swap.ko — kernel-native fault handling, eBPF prefetcher, activation recomputation for ML workloads. |
| v2 | Open-source CXL memory board | PCIe Gen4 FPGA board with SODIMM slots. Attach 512GB of recycled DDR4 to any server for ~$200. |
| v3 | Distributed KV cache | Network-attached RAM pool for LLM KV cache offloading via RDMA/DPDK. |
# Requirements: Linux 5.7+, Python 3.10+ # A fast NVMe SSD (PCIe Gen4+ recommended) # ── Install ── pip install -e . # Install phantomram Python package make # Build libphantom.so (C core) make test # Run C test suite # ── Try it (no GPU, no model file needed) ── python examples/inference_70b.py --synthetic 70 --dram-budget 16 --simulate 20 python examples/flux_vram.py --benchmark # ── Or use Docker ── docker build -t phantomram . docker run --rm phantomram # Build + test + demo # ── With a real model ── phantomram /path/to/llama-70b-q4.gguf --dram-budget 8 --simulate 10 # ── Weekend PoC (pure Python, no build needed) ── sudo sysctl -w vm.unprivileged_userfaultfd=1 sudo python3 v0-userfaultfd/poc_weekend.py \ --file /mnt/nvme/phantom_test.bin --size-gb 8
| Metric | Baseline (all DRAM) | PhantomRAM v0 | Ratio |
|---|---|---|---|
| Hardware cost | $5,000+ (128GB DDR5) | $150 (4TB NVMe) | 0.03x |
| Throughput (tokens/sec) | 20 | 6-10 | 0.3-0.5x |
| Max model size | Limited by DIMM slots | Limited by SSD size | 10-100x |
| Latency per token | 50ms | 100-170ms | 2-3.4x |
Because the RAM isn't really there. The application thinks it has 256GB of memory. In reality, it has 8GB of DRAM and a fast SSD, with software creating the illusion. Like a phantom limb — the brain (CPU) feels something that doesn't physically exist.
Apache 2.0 — Open source, open hardware, open weights (for the prefetch model).
This project is in the "poke at it" phase. If you're a kernel hacker, FPGA designer, ML systems engineer, or just someone who's tired of paying $40k for enough RAM to run a large model — come build with us.
I got tired of waiting for $40,000 H100s or buying Mac Studios just to get enough RAM to run 70B models. So I wrote PhantomRAM — a software layer that makes a $150 NVMe drive behave like DDR5 for AI workloads.
The trick: AI inference is deterministic. Layer 1, then 2, then 3. If you know what memory is needed 50ms from now, you prefetch it from NVMe before the GPU asks. The CPU never sees a cache miss. The model runs.
What's here:
phantomram/— pip-installable Python package.pip install -e .and go.v0-userfaultfd/— C core library (libphantom.so). userfaultfd + io_uring + deterministic prefetcher.make && make test.examples/— Runnable demos.inference_70b.py(synthetic 70B analysis),flux_vram.py(24GB model on 8GB GPU benchmark).gaming/— Same trick for game textures. Camera prediction + Vulkan sparse resources = "Cyberpunk at 4K Ultra on 8GB VRAM."
The thesis: NVMe at 7 GB/s + predictive prefetching + 8GB DRAM buffer = "256GB of RAM" for any workload with predictable access patterns.