๐ก High-throughput, low-latency Mixture-of-Experts (MoE) LLM inference on consumer GPUs and edge hardware. Run massive MoE models (DeepSeek, Mixtral, Qwen-MoE) on single RTX 3090, 4090, and 50-series cards with dynamic CPU-GPU hybrid offloading and zero pipeline bubbles.
Implementation of the research paper arXiv:2608.16157: FreeToken: Efficient Edge-Native MoE Serving with Bandwidth-Adaptive Execution (FlashML-org).
Mixture-of-Experts (MoE) architectures allow Large Language Models (LLMs) to scale parameter counts into hundreds of billions while keeping active compute per token manageable. However, deploying MoE models at the edge or on consumer GPUs presents a critical bottleneck: limited VRAM.
Traditional offloading approaches either:
FreeToken eliminates these bottlenecks by turning bandwidth constraints into a balanced execution problem, dynamically partitioning computation across GPU and Host CPU via mathematically optimal $q^\star$ scheduling.
/v1/chat/completions) for seamless use with Open-WebUI, LangChain, LlamaIndex, and agent frameworks. โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ FreeToken Engine โ
โโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โผ โผ
โโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ
โ GPU VRAM Resident โ โ Host CPU / RAM โ
โ - Base Model Layers โ โ - All Expert Pools โ
โ - Global LRU Cache โ โ - FTW Mmap Weights โ
โ - Dynamic KV Cache โ โ - Overlapped GEMM โ
โโโโโโโโโโโโฌโโโโโโโโโโโโ โโโโโโโโโโโโฌโโโโโโโโโโโโ
โ โ
โ Cache Hit โ Cache Miss
โผ โผ
[ Direct GPU GEMM ] [ q* Bandwidth-Adaptive Split ]
โโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโ
โผ โผ
Overlap PCIe Transfer Host CPU Execution
(GPU Weight Streaming) (Zero Bubble GEMM)
uv (Recommended)# Clone the repository
git clone https://github.com/ishandutta2007/FreeToken.git
cd FreeToken
# Install with development & acceleration dependencies
uv pip install -e ".[test,accel]"
pippip install -e ".[test,accel]"
import torch
from freetoken import FreeTokenEngine, EngineConfig, MoEModelConfig
# 1. Define MoE model architecture
model_config = MoEModelConfig(
vocab_size=32000,
hidden_dim=2048,
intermediate_dim=5632,
num_layers=12,
num_experts=16,
top_k=2
)
# 2. Configure edge VRAM budget (e.g., 8 GB VRAM budget on consumer GPU)
engine_config = EngineConfig(
total_vram_gb=8.0,
base_model_vram_gb=2.5,
reserved_vram_gb=0.5,
initial_expert_capacity=8
)
# 3. Initialize FreeToken Engine
engine = FreeTokenEngine(model_config, engine_config)
# 4. Generate tokens with autoregressive streaming
prompt = [101, 2054, 2003, 1037, 3231, 102]
for token in engine.generate(prompt, max_new_tokens=20):
print(f"Token: {token}")
# 5. Review runtime telemetry (hit rate, PCIe bandwidth, q* stats)
print(engine.get_metrics())
The .ftw format ensures memory-mapped, 64-byte aligned tensors for maximum DMA throughput:
import torch
from freetoken.format import FTWFormat
# Create sample expert weights
tensors = {
"expert_0_gate": torch.randn(1024, 2048, dtype=torch.float16),
"expert_0_up": torch.randn(1024, 2048, dtype=torch.float16),
}
# Save into zero-copy, aligned binary format
FTWFormat.save("weights.ftw", tensors, metadata={"model": "deepseek-flash"})
# Fast zero-copy memory load
loaded = FTWFormat.load("weights.ftw", device="cpu")
Deploy an OpenAI-compatible REST server with streaming endpoints:
freetoken serve --host 0.0.0.0 --port 8000 --vram 8.0
Query the /v1/chat/completions endpoint with curl:
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "freetoken-moe",
"messages": [{"role": "user", "content": "Explain bandwidth-adaptive MoE serving."}],
"stream": true
}'
Profile your system's Host-to-Device PCIe bandwidth and host CPU throughput to evaluate edge serving performance:
freetoken benchmark
FreeToken achieves up to 3.2x higher throughput and reduces cold-miss penalties compared to naive layer-by-layer offloading:
| Offloading Strategy | PCIe Utilization | Pipeline Bubble | Relative Throughput |
|---|---|---|---|
| Naive Demand Fetch | Low (stalled) | High (~45%) | 1.0x |
| Static Layer Cache | Moderate | Moderate (~25%) | 1.4x |
| FreeToken ($q^\star$) | Optimal (~92%) | Near-Zero (<3%) | 3.2x |
.ftw) zero-copy binary formatIf you use FreeToken in your research or edge deployments, please cite the paper:
@article{freetoken2026,
title={FreeToken: Efficient Edge-Native MoE Serving with Bandwidth-Adaptive Execution},
author={Yang, Shuo and Fan, Xiaoze and Pan, Melissa and Xi, Haocheng and Wang, Zhe and Sun, Shanlin and Keutzer, Kurt and Han, Song and Zaharia, Matei and Xu, Chenfeng and Stoica, Ion},
journal={arXiv preprint arXiv:2608.16157},
year={2026}
}
This project is licensed under the Apache-2.0 License.
8 commits
Python
100.0%
๐ก High-throughput, low-latency Mixture-of-Experts (MoE) LLM inference on consumer GPUs and edge hardware. Run massive MoE models (DeepSeek, Mixtral, Qwen-MoE) on single RTX 3090, 4090, and 50-series cards with dynamic CPU-GPU hybrid offloading and zero pipeline bubbles.
Implementation of the research paper arXiv:2608.16157: FreeToken: Efficient Edge-Native MoE Serving with Bandwidth-Adaptive Execution (FlashML-org).
Mixture-of-Experts (MoE) architectures allow Large Language Models (LLMs) to scale parameter counts into hundreds of billions while keeping active compute per token manageable. However, deploying MoE models at the edge or on consumer GPUs presents a critical bottleneck: limited VRAM.
Traditional offloading approaches either:
FreeToken eliminates these bottlenecks by turning bandwidth constraints into a balanced execution problem, dynamically partitioning computation across GPU and Host CPU via mathematically optimal $q^\star$ scheduling.
/v1/chat/completions) for seamless use with Open-WebUI, LangChain, LlamaIndex, and agent frameworks. โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ FreeToken Engine โ
โโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โผ โผ
โโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ
โ GPU VRAM Resident โ โ Host CPU / RAM โ
โ - Base Model Layers โ โ - All Expert Pools โ
โ - Global LRU Cache โ โ - FTW Mmap Weights โ
โ - Dynamic KV Cache โ โ - Overlapped GEMM โ
โโโโโโโโโโโโฌโโโโโโโโโโโโ โโโโโโโโโโโโฌโโโโโโโโโโโโ
โ โ
โ Cache Hit โ Cache Miss
โผ โผ
[ Direct GPU GEMM ] [ q* Bandwidth-Adaptive Split ]
โโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโ
โผ โผ
Overlap PCIe Transfer Host CPU Execution
(GPU Weight Streaming) (Zero Bubble GEMM)
uv (Recommended)# Clone the repository
git clone https://github.com/ishandutta2007/FreeToken.git
cd FreeToken
# Install with development & acceleration dependencies
uv pip install -e ".[test,accel]"
pippip install -e ".[test,accel]"
import torch
from freetoken import FreeTokenEngine, EngineConfig, MoEModelConfig
# 1. Define MoE model architecture
model_config = MoEModelConfig(
vocab_size=32000,
hidden_dim=2048,
intermediate_dim=5632,
num_layers=12,
num_experts=16,
top_k=2
)
# 2. Configure edge VRAM budget (e.g., 8 GB VRAM budget on consumer GPU)
engine_config = EngineConfig(
total_vram_gb=8.0,
base_model_vram_gb=2.5,
reserved_vram_gb=0.5,
initial_expert_capacity=8
)
# 3. Initialize FreeToken Engine
engine = FreeTokenEngine(model_config, engine_config)
# 4. Generate tokens with autoregressive streaming
prompt = [101, 2054, 2003, 1037, 3231, 102]
for token in engine.generate(prompt, max_new_tokens=20):
print(f"Token: {token}")
# 5. Review runtime telemetry (hit rate, PCIe bandwidth, q* stats)
print(engine.get_metrics())
The .ftw format ensures memory-mapped, 64-byte aligned tensors for maximum DMA throughput:
import torch
from freetoken.format import FTWFormat
# Create sample expert weights
tensors = {
"expert_0_gate": torch.randn(1024, 2048, dtype=torch.float16),
"expert_0_up": torch.randn(1024, 2048, dtype=torch.float16),
}
# Save into zero-copy, aligned binary format
FTWFormat.save("weights.ftw", tensors, metadata={"model": "deepseek-flash"})
# Fast zero-copy memory load
loaded = FTWFormat.load("weights.ftw", device="cpu")
Deploy an OpenAI-compatible REST server with streaming endpoints:
freetoken serve --host 0.0.0.0 --port 8000 --vram 8.0
Query the /v1/chat/completions endpoint with curl:
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "freetoken-moe",
"messages": [{"role": "user", "content": "Explain bandwidth-adaptive MoE serving."}],
"stream": true
}'
Profile your system's Host-to-Device PCIe bandwidth and host CPU throughput to evaluate edge serving performance:
freetoken benchmark
FreeToken achieves up to 3.2x higher throughput and reduces cold-miss penalties compared to naive layer-by-layer offloading:
| Offloading Strategy | PCIe Utilization | Pipeline Bubble | Relative Throughput |
|---|---|---|---|
| Naive Demand Fetch | Low (stalled) | High (~45%) | 1.0x |
| Static Layer Cache | Moderate | Moderate (~25%) | 1.4x |
| FreeToken ($q^\star$) | Optimal (~92%) | Near-Zero (<3%) | 3.2x |
.ftw) zero-copy binary formatIf you use FreeToken in your research or edge deployments, please cite the paper:
@article{freetoken2026,
title={FreeToken: Efficient Edge-Native MoE Serving with Bandwidth-Adaptive Execution},
author={Yang, Shuo and Fan, Xiaoze and Pan, Melissa and Xi, Haocheng and Wang, Zhe and Sun, Shanlin and Keutzer, Kurt and Han, Song and Zaharia, Matei and Xu, Chenfeng and Stoica, Ion},
journal={arXiv preprint arXiv:2608.16157},
year={2026}
}
This project is licensed under the Apache-2.0 License.
8 commits
Python
100.0%