An open-source streaming MoE inference framework — SSD expert offload + Recover-LoRA + prerouter routing prediction.
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 sparse model tiers ship with the framework as end-to-end releases. Resident dense Qwen3.8, text-only Gemma 4 and Muse Glimmer, and exact-routing streaming Ornith adapters are also available for compatible MLX checkpoints.
| Tier | Released checkpoint | Inference profile |
|---|---|---|
edge0-35b |
Edge0/Edge0-35B-A3B-preview · ModelScope |
4-bit, 40 layers, 256 experts, prerouter K=4 |
edge0-8b |
Edge0/Edge0-8B-A1B-preview · ModelScope |
4-bit, 24 layers, 128 experts, prerouter K=8 |
gemma-4:31b-mlx |
mlx-community/gemma-4-31b-4bit |
4-bit dense, 60-layer resident text model |
muse-glimmer:30b-mlx |
mlx-community/Muse-Glimmer-30B-4bit |
4-bit dense, 52-layer text model, resident MLX inference |
ornith:35b-mlx |
mlx-community/Ornith-1.0-35B-4bit |
4-bit sparse, 40 layers, 256 experts, exact gate-routed K=8; text only |
qwen3.8:27b-mlx |
mlx-community/Qwen3.8-27B-4bit |
4-bit dense, 64 layers, resident MLX inference |
The Muse checkpoint is an MLX 4-bit conversion of
meta-models/Muse-Glimmer-30B. Edge0 currently loads its text architecture
only: vision tensors are discarded and image input is not yet wired through
Edge0 APIs.
The Gemma checkpoint is an MLX 4-bit conversion of google/gemma-4-31b.
Edge0's deterministic preparation strips its 355 vision_tower.* and three
embed_vision.* tensors, installs a local canonical text chat template, and
supports text generation only. Image, audio, and video inputs are not wired.
Model weights remain subject to the Gemma terms; the adapted mlx-vlm model
code is MIT-licensed.
Ornith is also published as a VLM checkpoint. Edge0's preparation step strips its 333 vision tensors and supports text generation only; image and video inputs are not wired, and mlx-vlm is not a runtime dependency.
The two Edge0 release checkpoints are built on open sparse-MoE base models (Qwen3.6-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.
- OS / hardware: the MLX backend runs on macOS with Apple Silicon (M1/M2/M3/M4). The CUDA backend is on the roadmap — no other platforms are supported yet.
- Python: 3.10+ (3.12 recommended).
- MLX:
mlx==0.30.6/mlx-metal==0.30.6withmlx-lm==0.31.0(seepyproject.toml). Garbled, mixed-language output on Apple A18 / A18 Pro means an oldermlx:pip install 'mlx==0.30.6' 'mlx-metal==0.30.6'(#8). - Memory: ~2.9 GB peak active memory for
edge0-35b, ~1.0 GB foredge0-8b, and ~14.7 GiB peak process footprint for the residentqwen3.8:27b-mlxadapter (short contexts; see Benchmark). Add headroom for the OS, tokenizer, and long-context KV growth. Gemma 4, Muse Glimmer, and Ornith memory have not yet been measured in Edge0. - Disk: the 4-bit checkpoints are ~23 GB (
edge0-35b) and ~4.2 GB (edge0-8b); the Qwen3.8 MLX checkpoint is ~15 GB, while Ornith's source tensors total ~20.4 GB before the vision strip. Sparse expert weights are mmapped and read on demand; the dense Qwen3.8 weights are resident.
- transformers-style usage:
AutoModel/AutoConfig/AutoEngineresolve the tier from the model name; - Backend isolation: all MLX code lives under
edge0/backends/mlx/; the core logic (model specs, prerouter, streaming expert pool, server) depends only on the backend facade (edge0/backends/base.py), so a new backend implements the same facade (backends/cuda/is a reserved slot) with zero changes to core code; - Adapters as safetensors: LoRA and prerouter weights are
.safetensorsfiles with provenance metadata (source, version, owner layers), resolved from the model directory orartifacts/; - Model + adapters in one directory: a model directory holds both
the base checkpoint (
config.json/model*.safetensors/ tokenizer) and that model's adapters; upgrading adapters swaps adapter files only — the base stays read-only and is never merged.
- SSD expert offload: expert weights are streamed from storage on demand; peak memory is bounded by the active set, not the parameter count.
- Prerouter: a trained head predicts expert routing one step ahead, so expert loads overlap the forward pass instead of stalling it — up to +59% decode throughput; the gain grows with storage latency, model size, and routed width K.
- Recover-LoRA: the int4 base is frozen and LoRA adapters are trained by distillation from the FP teacher, recovering most of the quantization loss at 4-bit (see Quality). Adapters stay unmerged: one read-only base serves multiple adapter sets.
# Python >= 3.10; the MLX backend requires macOS with Apple Silicon
python3.12 -m venv .venv && .venv/bin/pip install -e '.[dev,fetch]'All supported checkpoints are published on Hugging Face. The two Edge0 release repos bundle their trained LoRA and prerouter adapters in the same directory; Qwen3.8, Gemma 4, and Muse Glimmer are dense MLX checkpoints, while Ornith is a sparse VLM checkpoint prepared for text-only streaming:
Edge0/Edge0-35B-A3B-preview(~23 GB)Edge0/Edge0-8B-A1B-preview(~4.2 GB)
# with the repo's helper (defaults to the six 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
.venv/bin/python scripts/fetch_models.py --tier 'gemma-4:31b-mlx' --target-dir models
.venv/bin/python scripts/fetch_models.py --tier 'muse-glimmer:30b-mlx' --target-dir models
.venv/bin/python scripts/fetch_models.py --tier 'ornith:35b-mlx' --target-dir models
.venv/bin/python scripts/fetch_models.py --tier 'qwen3.8:27b-mlx' --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
.venv/bin/huggingface-cli download mlx-community/gemma-4-31b-4bit --local-dir models/gemma-4-31b-mlx
.venv/bin/python scripts/prepare_gemma4_checkpoint.py models/gemma-4-31b-mlx --no-backup
.venv/bin/huggingface-cli download mlx-community/Muse-Glimmer-30B-4bit --local-dir models/muse-glimmer-30b-mlx
.venv/bin/huggingface-cli download mlx-community/Ornith-1.0-35B-4bit --local-dir models/ornith-35b-mlx
.venv/bin/python scripts/prepare_ornith_checkpoint.py models/ornith-35b-mlx --no-backup
.venv/bin/huggingface-cli download mlx-community/Qwen3.8-27B-4bit --local-dir models/qwen3.8-27b-mlxEither 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
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
export GEMMA4_31B_MLX_MODEL=$PWD/models/gemma-4-31b-mlx
export MUSE_GLIMMER_30B_MODEL=$PWD/models/muse-glimmer-30b-mlx
export ORNITH_35B_MLX_MODEL=$PWD/models/ornith-35b-mlx
export QWEN38_27B_MLX_MODEL=$PWD/models/qwen3.8-27b-mlxOr 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
edge0 chat models/gemma-4-31b-mlx --prompt "Explain partial rotary attention briefly."
edge0 chat models/muse-glimmer-30b-mlx --prompt "Reply with one sentence."
edge0 chat models/ornith-35b-mlx --prompt "Explain reinforcement learning briefly."
edge0 chat models/qwen3.8-27b-mlx --prompt "Reply with only the word OK."# quick demo
edge0 demo edge0-35b
# serve (OpenAI-compatible /v1/chat/completions)
edge0 serve edge0-35bcurl 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."
# demo, chat, and serve can cap prompt + completion (up to 512K tokens)
edge0 chat edge0-35b --context-size 512k --prompt "Hello!"python -m edge0 ... is equivalent to edge0 ....
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 cacheexamples/demo.py is the same minimal walkthrough (edge0 demo runs
this exact path).
- Checkpoint: the original model directory (
config.json,model*.safetensors, tokenizer).edge0 serve <dir>/AutoEngine.from_pretrained(<dir>)detect the tier fromconfig.json. - Adapters (LoRA + prerouter, safetensors) are resolved from either
location automatically:
- the model directory (recommended): side by side with the base, e.g.
lora_edge0_35b.safetensors+prerouter_edge0_35b.safetensors; artifacts/(repo root, gitignored): convert once from training-side npz exports viaedge0 convert-adapters --npz-dir ....
- the model directory (recommended): side by side with the base, e.g.
- The published model repos bundle both the base checkpoint and the
current default adapter release, so
scripts/fetch_models.pyproduces a ready-to-run model directory. Check each model's doc page for its adapter provenance (training data, owner-layer layout). - Both adapters are required for the prerouter + LoRA pipeline; if a
file is missing,
edge0fails with a clear message (or pass--no-prerouter/--no-lorato run the plain base model).
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.6-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 |
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 |
gemma-4:31b-mlx |
not measured | not measured | not measured | — |
muse-glimmer:30b-mlx |
not measured | not measured | not measured | — |
ornith:35b-mlx |
not measured | not measured | not measured | — |
qwen3.8:27b-mlx |
6.0 tok/s† | — | 14.7 GiB process footprint | Mac Studio M4 Max, 36 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).
†Qwen3.8 is a 48-token generation smoke measurement including its short prompt prefill, not the long-prompt sparse-tier benchmark protocol.
Reproduce:
python examples/bench.py edge0-35b # via $EDGE0_35B_MODEL
python examples/bench.py edge0-8b # via $EDGE0_8B_MODEL
edge0 chat qwen3.8:27b-mlx --prompt "Explain hybrid attention briefly."pytest # unit tests (no real weights)
EDGE0_8B_MODEL=/path/to/edge0-8b pytest -m slow -q
# real-weight generation; missing tiers are skipped
QWEN38_27B_MLX_MODEL=/path/to/qwen3.8-27b-mlx \
pytest -m slow -q tests/test_e2e_slow.py::test_qwen38_27b_mlx_real_checkpoint
MUSE_GLIMMER_30B_MODEL=/path/to/muse-glimmer-30b-mlx \
pytest -m slow -q tests/test_e2e_slow.py::test_muse_glimmer_30b_mlx_real_checkpoint
ORNITH_35B_MLX_MODEL=/path/to/ornith-35b-mlx \
pytest -m slow -q tests/test_e2e_slow.py::test_ornith_35b_mlx_real_checkpoint
GEMMA4_31B_MLX_MODEL=/path/to/gemma-4-31b-mlx \
pytest -m slow -q tests/test_e2e_slow.py::test_gemma4_31b_mlx_real_checkpoint
.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- Architecture
- Attention / MoE / SSD streaming / prerouter
- Adding a model
- edge0-35b / edge0-8b / Gemma 4 31B MLX / Muse-Glimmer-30B MLX / Ornith-1.0-35B MLX / Qwen3.8-27B MLX
Edge0 is Apache-2.0. Adapted third-party code retains its stated license; see NOTICE. Downloaded Gemma model weights are not part of Edge0 and remain subject to the Gemma terms.