GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - mr-gl00m/ram-experiment: NVMe at 7 GB/s + predictive prefetching + 8GB DRAM buffer = "256GB of RAM" for any workload with predictable access patterns.

BranchesTags
Open more actions menu

Latest commit

 

History

2 Commits
2 Commits

Folders and files

NameName
Last commit message
Last commit date
benchmarks
benchmarks
 
 
docs
docs
 
 
examples
examples
 
 
gaming
gaming
 
 
phantomram
phantomram
 
 
tests
tests
 
 
v0-userfaultfd
v0-userfaultfd
 
 
v1-kernel-module
v1-kernel-module
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
Dockerfile
Dockerfile
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
pyproject.toml
pyproject.toml
 
 

Repository files navigation

PhantomRAM

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 Problem

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.

The Thesis

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.

Architecture (v0 — userfaultfd Prototype)

┌─────────────────────────────────────────────────────┐
│              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                     │
└─────────────────────────────────────────────────────┘

Phases

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.

Quick Start (v0)

# 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

Key Metrics (Target)

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

Why "PhantomRAM"?

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.

License

Apache 2.0 — Open source, open hardware, open weights (for the prefetch model).

Contributing

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.


The Pitch

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.

About

NVMe at 7 GB/s + predictive prefetching + 8GB DRAM buffer = "256GB of RAM" for any workload with predictable access patterns.

Resources

Readme
Apache-2.0 license

Contributing

Contributing
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.