Edge0 README

The project's README from github.com/Edge0-AI/Edge0. As one markdown file: README.md.

edge0

edge0

An open-source streaming MoE inference framework — SSD expert offload + Recover-LoRA + prerouter routing prediction.

Hugging Face Hugging Face GitHub License

English | 中文

edge0 is an open-source streaming MoE inference framework. It generalizes the production-proven recipe — SSD expert offload + Recover-LoRA + prerouter routing prediction — into an extensible framework. The backend is isolated by design: the current MLX backend runs on Apple Silicon, and additional platforms (CUDA, …) plug into the same core abstractions.

Two model tiers ship with the framework. Each tier is an end-to-end release: the released checkpoint, the trained LoRA adapters, and the trained prerouter heads work together as one unit.

Tier Released checkpoint Inference profile
edge0-35b Edge0/Edge0-35B-A3B-preview 4-bit, 40 layers, 256 experts, prerouter K=4
edge0-8b Edge0/Edge0-8B-A1B-preview 4-bit, 24 layers, 128 experts, prerouter K=8

Both checkpoints are built on open sparse-MoE base models (Qwen3.5-MoE 35B-A3B and the Ling 3.0 bailing hybrid respectively) and ship with the LoRA and prerouter training done for this framework — the adapter files are co-located with each checkpoint and load automatically, so edge0 serve <tier> runs the trained pipeline out of the box.

Requirements

Design

Core mechanisms

Quick start

1) Install

# Python >= 3.10; the MLX backend requires macOS with Apple Silicon
python3.12 -m venv .venv && .venv/bin/pip install -e '.[dev,fetch]'

2) Download a model

The two tiers are published on Hugging Face — each repo bundles the base checkpoint and the trained LoRA + prerouter adapters in one directory, so a single download is a ready-to-run model:

# with the repo's helper (defaults to the two repos above):
.venv/bin/python scripts/fetch_models.py --tier edge0-35b --target-dir models
.venv/bin/python scripts/fetch_models.py --tier edge0-8b --target-dir models

# or directly with the CLI:
.venv/bin/huggingface-cli download Edge0/Edge0-35B-A3B-preview     --local-dir models/edge0-35b
.venv/bin/huggingface-cli download Edge0/Edge0-8B-A1B-preview     --local-dir models/edge0-8b

Either way you end up with a directory like:

models/edge0-35b/
├── config.json, model-*.safetensors, tokenizer files   # base checkpoint
├── lora_edge0_35b.safetensors          # trained LoRA adapters
└── prerouter_edge0_35b.safetensors     # trained prerouter heads

3) Point edge0 at it

Tier names resolve to local directories via environment variables (where you put the download is up to you):

export EDGE0_35B_MODEL=$PWD/models/edge0-35b
export EDGE0_8B_MODEL=$PWD/models/edge0-8b

Or skip the env vars entirely and pass the directory directly — the tier is auto-detected from the checkpoint's config.json:

edge0 demo models/edge0-35b
edge0 serve models/edge0-8b

4) Run

# quick demo
edge0 demo edge0-35b

# serve (OpenAI-compatible /v1/chat/completions)
edge0 serve edge0-35b
curl http://127.0.0.1:8000/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{"messages":[{"role":"user","content":"Hello!"}],"max_tokens":32}'

# 5) One-shot chat (pass --max-new to cap length; add --show-thinking to
#    print the model's reasoning block too)
edge0 chat edge0-35b --prompt "Explain streaming inference in one sentence."

python -m edge0 ... is equivalent to edge0 ....

Python API

from edge0 import AutoEngine
from edge0.server.chat import ChatMessage, ChatRequest, ChatSession

engine = AutoEngine.from_pretrained("/path/to/model")  # tier auto-detected
req = ChatRequest(
    model=engine.name,
    messages=[ChatMessage(role="user", content="Hello!")],
    max_tokens=64,
)
tokens, meta = ChatSession(engine, req).run()
print(engine._tok.decode(tokens))
engine.close()   # release mmaps / expert cache

examples/demo.py is the same minimal walkthrough (edge0 demo runs this exact path).

Models and adapters

Quality

All benchmarks were run by us with OpenCompass under identical settings and parameters for both the edge0 models (int4 + trained adapters + prerouter routing) and the original fp16 base models. The loss of the edge0 pipeline is small: 3.9 points on average for edge0-35b, 2.8 for edge0-8b (MMLU-Pro is even above the base). Max 100:

Benchmark edge0-35b (int4) Qwen3.5-MoE 35B-A3B (fp16) edge0-8b (int4) Ling 3.0 tiny (fp16)
AIME 2026 86.6 92.7 63.3 73.3
HumanEval 90.9 95.1 91.5 92.7
GPQA-Diamond 79.8 81.8 70.7 71.2
MMLU-Pro 81.0 84.6 70.1 65.8
IFBench 57.9 61.7 53.9 60.6
Average 79.2 83.2 69.9 72.7

Benchmark

Measured with examples/bench.py (3.3k-token prompt prefill → 10 sampled warmup steps → 200 timed sampled decode tokens, 2 runs per tier):

Tier Decode speed Prefill throughput (cold / warm)* Peak active memory** Test machine
edge0-35b 14.9–17.7 tok/s 113 / 140 tok/s 2.9 GiB Mac mini M4 Pro, 24 GB
edge0-8b 23.9–25.3 tok/s 500 / 1428 tok/s 1.0 GiB Mac mini M4 Pro, 24 GB

Cold = first request after process start (expert weights fault in from SSD); warm = subsequent requests (page cache resident). Prefill numbers are throughput over a ~3.3k-token prompt (BENCH_LONG=1).

*Peak active memory at short contexts (MLX allocator peak; expert weights stream from SSD via mmap and are not resident). Long contexts add KV cache: ~3.3 GiB on edge0-8b at 3.3k tokens.

Reproduce:

python examples/bench.py edge0-35b    # via $EDGE0_35B_MODEL
python examples/bench.py edge0-8b    # via $EDGE0_8B_MODEL

Tests

pytest                 # unit tests (no real weights)
EDGE0_8B_MODEL=/path/to/edge0-8b pytest -m slow -q
                        # real-weight generation; missing tiers are skipped
.venv/bin/python scripts/e2e_smoke.py \
  --qwen-dir /path/to/edge0-35b --ling-dir /path/to/edge0-8b
                        # staged vs exact consistency + generation smoke
scripts/generate_example.py   # full-pipeline API example
examples/demo.py       # minimal API walkthrough

Documentation

License

Apache-2.0, including vendored third-party code (see NOTICE).

Edge0 (Edge0-AI/Edge0)

Searching Database…

5.5K ·GitHub
这是什么?Edge0 是一个开源的流式 MoE(混合专家)推理框架,通过从 SSD 流式读取专家权重并提前一步预测路由,让你只用约 2.5-2.9 GB 的实际内存就能运行大型 MoE 模型,例如 35B 参数的模型。
我是把它当 Python 库用,还是作为服务器运行?两者都可以:它提供 transformers 风格的 Python API(AutoModel / AutoConfig / AutoEngine),也提供 CLI/服务器(edge0 serve 或 python -m edge0),开箱即可运行训练好的流水线。
我怎样才能让它跑起来?安装 edge0,从 Hugging Face 下载已发布的两个档位之一(Edge0/Edge0-35B-A3B-preview 或 Edge0/Edge0-8B-A1B-preview),通过环境变量或直接路径让 edge0 指向下载的目录(档位会从 config.json 自动检测),然后运行 edge0 serve。
我需要什么样的硬件和 Python 版本?需要 Python 3.10+(推荐 3.12),并且目前需要一台搭载 Apple Silicon(M1/M2/M3/M4)的 Mac——这是目前 MLX 后端唯一支持的平台。
它真的像描述所说的那样能在 iPhone、Android 和 Windows 上运行吗?根据 README,目前还不行——现在实际支持的只有 Apple Silicon Mac 上的 MLX 后端;CUDA 支持已在路线图中,但其他平台尚未实现。
采用 4-bit 量化后我会损失多少准确率?非常少——OpenCompass 基准测试显示,与 fp16 基础模型相比,edge0-35b 平均下降 3.9 分,edge0-8b 平均下降 2.8 分,而 MMLU-Pro 的得分甚至高于基础模型。
这些模型实际需要多少磁盘空间?4-bit checkpoint 方面,edge0-35b 约为 23 GB,edge0-8b 约为 4.2 GB;专家权重采用内存映射、按需读取的方式,而不是全部加载进内存。
什么是 Recover-LoRA?它是一个 LoRA 适配器,在冻结的 int4 基础模型之上,通过从全精度教师模型蒸馏训练而来,能挽回 4-bit 量化损失的绝大部分准确率,同时保持基础模型不被合并且为只读。
prerouter 到底是做什么的?一个经过训练的预测头会提前一步预测接下来需要哪些专家,从而在当前前向传播运行的同时,从 SSD 流式读入下一批专家的权重,解码吞吐量最高可提升 59%。
实际解码速度有多快?在 Mac mini M4 Pro 上,用自带的基准测试脚本实测,edge0-35b 的解码速度为 14.9-17.7 tok/s,edge0-8b 为 23.9-25.3 tok/s。
我可以接入自己的基础模型吗?该框架通过统一的门面(facade)把后端与核心逻辑分离,因此可以添加新的后端,但目前只有两个已发布的档位(基于 Qwen3.5-MoE 35B-A3B 和 Ling 3.0)附带训练好的适配器。
What are similar projects?airllm, decider, needle, laya-coreml, MiniCPM, warp, backburner, openTPU
Creator
Edge0-AI
Size
4.2 MB
Stars
5.5K
Updated
CommitOct 16
Age
1mo
Commits · 90 Days