Run a 125B MoE on 16GB VRAM! Lean-QwenFlash Guide: Direct NVMe SSD Offload at 20 tok/s across 262K Context

Democratizing massive MoE models! The open-source Lean-QwenFlash framework eliminates the requirement of keeping tens of gigabytes of experts resident in system RAM. By offloading 24K sparse experts directly to a high-speed NVMe SSD, developers can execute Qwen 3.8 Flash Next 125B on a single 16GB GPU (like RTX 4090 or RTX 3080 Laptop) with just 8GB system RAM, achieving 20 tok/s over a full 262K context window.

Run a 125B MoE on 16GB VRAM! Lean-QwenFlash Guide: Direct NVMe SSD Offload at 20 tok/s across 262K Context

In the open-source LLM arena, Qwen 3.8 Flash Next 125B has emerged as a premier model thanks to its architecture of 24,000 fine-grained sparse experts, delivering frontier-level coding and analytical reasoning.

Historically, running this 125B giant locally came with prohibitive hardware barriers:

This effectively excluded developers possessing single 16GB GPUs—such as desktop RTX 4080s, mobile RTX 4090s, or 16GB RTX 3080 laptops—whose host machines often feature modest 16GB to 32GB RAM capacities.

The open-source Lean-QwenFlash project fundamentally alters this landscape. Built atop ExLlamaV3, it streams unpinned experts directly from a high-speed NVMe SSD, enabling unprecedented resource efficiency:

With just 16GB VRAM and 8GB system RAM, you can achieve a consistent 20.0 tok/s decoding speed across an entire 262K context window—even on a gaming laptop.

Below is an in-depth breakdown of the direct NVMe storage mechanism, empirical dual-device benchmarks, and step-by-step setup instructions.


1. System Architecture: Why NVMe Direct Offload Outperforms RAM Pinning

The Bottleneck of Conventional RAM Pinning

In typical Mixture-of-Experts (MoE) generation, only a tiny subset of “active experts” are triggered per token. Traditional offload frameworks maintain the entire pool of 24,000 experts resident in host RAM (occupying 48GB to 64GB) to avoid perceived disk I/O latency. On cache misses, the CPU copies layers over the PCIe bus, demanding excessive system memory that consumer hardware cannot accommodate.

The Lean-QwenFlash Paradigm: Zero-RAM Footprint + NVMe Streaming

Lean-QwenFlash adapts virtual memory streaming techniques to execute the model within strict hardware envelopes:

  1. GPU VRAM Houses Attention Backbone & Active Slices: The 16GB VRAM budget strictly accommodates the base attention layers, the momentarily active expert compute kernels, and the quantized Q4 KV Cache;
  2. NVMe SSD Serves as the Latent Expert Repository: Inactive expert weights reside on the NVMe drive in custom packed formats. Utilizing memory-mapped I/O (mmap) and asynchronous kernel prefetching, active experts are streamed directly into GPU memory on demand;
  3. Host RAM Footprint Restricted to 8GB: Because weights do not permanently occupy host memory, your workstation only requires 8GB of free system RAM to maintain operational stability.

💡 Crucial Technical Clarification: Does this degrade SSD lifespan?

Not at all. Solid-state drive wear (TBW) is driven strictly by write cycles. During inference, expert weight access is 100% read-only. Not a single byte is written back to the disk during model generation, resulting in zero impact on SSD endurance.


2. Empirical Benchmark Matrix: Desktop RTX 4090 vs. Mobile RTX 3080

The following benchmarks were recorded using the recommended 3.05bpw_h5_ng5 quantization profile paired with Q4 KV Cache:

Target HardwareContext WindowDecode SpeedPrefill ThroughputPeak VRAMSystem RAM Allocated
RTX 4090 (Desktop)8K Short Context28.0–33.0 tok/s (Prose)
19.0–22.0 tok/s (Code)
~1080 tok/s16.0 GB8.0 GB
RTX 4090 (Desktop)100K Long Context20.8 tok/s~1536 tok/s16.0 GB8.0 GB
RTX 4090 (Desktop)262K Full Window20.0 tok/s~1627 tok/s16.0 GB8.0 GB
RTX 3080 Mobile (Laptop)100K Long Context18.0–21.0 tok/s~650–700 tok/s15.5 GB8.0 GB

Key Takeaway: Even at an extreme 262K sequence length, decoding speeds remain rock-solid at or above 20 tok/s (well exceeding typical human reading speeds of 5–8 tok/s). This delivers a genuinely viable, single-card solution for comprehensive code repository analysis and massive document synthesis.


3. Hardware Requirements & Environment Setup

1. Hardware Specifications

2. Software Stack


4. Step-by-Step Installation & Execution

Step 1: Clone Repository and Prepare Virtual Environment

# Clone the repository
git clone https://github.com/MaxDevv/lean-qwenflash.git
cd lean-qwenflash

# Create and activate Python virtual environment
python3 -m venv venv
source venv/bin/activate

# Install PyTorch with CUDA 12.1 and ExLlamaV3
pip install --upgrade pip
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121
pip install exllamav3 huggingface_hub

Step 2: Download the 3.05bpw Quantized Weights

Use the bundled download script to retrieve the optimized weight pack:

python download_model.py --output-dir ./models/Qwen-3.8-Flash-Next-125B-3.05bpw

Ensure the directory contains model tensors, tokenizer.json, and ExLlamaV3 metadata files.


Step 3: Launch Direct NVMe Streaming Inference

Execute the runner script configuring VRAM boundaries and NVMe storage paths:

python run_inference.py \
  --model_dir ./models/Qwen-3.8-Flash-Next-125B-3.05bpw \
  --max_seq_len 262144 \
  --gpu_split 16.0 \
  --cache_mode q4 \
  --mmap_expert_dir ./models/Qwen-3.8-Flash-Next-125B-3.05bpw \
  --temperature 0.2 \
  --top_p 0.95

Parameter Rationale:


5. Architectural Tradeoffs & Practical Gotchas

1. KV Cache Selection (Q4 vs. Q8)

At 262K tokens, uncompressed FP16 KV Cache alone requires more than 30GB of VRAM.

2. Avoid Secondary SATA SSDs

Because expert retrieval latency directly dictates token generation rates, always keep the weights on a PCIe NVMe drive. Running on SATA drives (capped at ~500 MB/s) degrades throughput drastically to 3–5 tok/s.

3. Multi-GPU Scalability

If your system hosts dual 16GB cards (e.g., dual RTX 4080s or dual RTX 4060 Ti 16GB), configure:

--gpu_split 14.5,14.5

This distributes expert cache tiers across both cards, drastically lowering NVMe access frequency and boosting throughput up to 45+ tok/s.


By leveraging high-speed NVMe storage bandwidth in place of expensive system RAM, Lean-QwenFlash proves that 16GB consumer hardware can comfortably host 125B MoE giants. This represents a major leap forward for developers deploying production-grade local agents.

💬 Discussion

GitHub Powered