zram can save a small host, not accelerate model weights
zram will not make your local model faster. Install it expecting that and you'll be disappointed on schedule. What it actually does is keep a small Linux box, short on RAM and running a model next to a few other services, from thrashing to disk when memory gets tight, because pages headed for swap get compressed and held in RAM instead. A real fix, for a different problem than the one most people bring to it.
Why weights don't compress the way logs do
zram intercepts pages the kernel wants to evict, compresses them fast, and keeps the result in a RAM-backed swap device instead of writing it to disk. That's a bet on redundancy: text buffers, half-idle heaps, cached files, log tails, anything a compressor can find structure in. A quantized weight tensor is the opposite bet. INT4 and INT8 quantization exists to strip redundancy out of a matrix and pack it tight, so zram gets almost nothing to squeeze and you burn CPU cycles proving it. Weights in VRAM were never swap candidates anyway, since zram only touches system RAM. For CPU-side inference, decompressing gigabytes of a mapped weight file on every touched page under pressure costs more than leaving it alone. The mechanism was built for small, warm, redundant pages. Weights are none of those things.
The box where this actually earns its keep
Picture where zram is worth the trouble: a small Linux server with limited RAM, running a model next to a queue worker, a thin web layer, maybe a vector store. Every one of those crowds out headroom, and it's their memory that compresses well, not the model's. Standing up a modest device takes three lines:
zramctl -f -s 2G -a zstd
mkswap /dev/zram0
swapon /dev/zram0 -p 100
Before crediting that setup with anything, pin the variables: model artifact, tokenizer, prompt template, runtime build, launch command, sampling settings, all fixed, so next week's change doesn't get blamed on today's. Test against real inputs, awkward ones included. Run once cold, storage cold and model unloaded, if users hit that path, then warm runs after to expose cache effects and queueing. Log by phase: queue wait, model load, prefill, time to first token, decode rate, peak RAM and swap, whether the output passed a quality check. Raw tokens per second is diagnostic, not the result you're selling; for a batch job, count valid completed records per hour, and for anything interactive, watch p50 and p95 first-token latency.
Where the resilience starts lying to you
The costly mistake is assuming compressed swap opens room for a bigger quant than the RAM would otherwise allow. It doesn't, not usefully. Local runtimes are good at hiding that: they offload layers, page memory, eat cache misses, or quietly drop to a generic kernel, so a degraded setup can run for weeks unnoticed. Read the startup log, check where tensors landed, watch the OS counters, and confirm the optimization is active for the context length you're actually feeding it. Change one variable per test, and keep the outputs, not just the timings: quantization and context tricks can make an answer worse while making it faster. Weigh the operational side too: startup, upgrades, rollback, rebuilding after a disk dies. A win resting on an undocumented patch or manual warming is a bad trade. Boring wins. Treat zram as an operating-system buffer, never a sizing lever, note why you set it up and what should trigger a recheck, and leave headroom past the target: spare RAM and spare thermal margin keep the thing predictable rather than merely fast today.
One honest gap: I trust the compression tax is cheap on ordinary pages because that's how zstd behaves generally, not because I've isolated the CPU cost on a fully loaded mini server myself. If your hardware is already underpowered, measure that overhead before taking my word for it.