Repository navigation
feat(moe): add hierarchical expert offloading and early-layer speculative prefetcher - #2463
Open
presentyourlove wants to merge 1 commit into
Conversation
…tive prefetcher Introduce hierarchical MoE expert offloading across VRAM, host RAM, and NVMe SSD with an EarlyLayerPrefetchPredictor and non-blocking HierarchicalExpertEngine. Enables 4GB devices to virtualize large 32GB+ MoE expert pools by prefetching layer L+4 experts during layer L compute.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR implements Frontier Dimension 3.1: Hierarchical Expert Offloading & Early-Layer Speculative Prefetching, enabling ultra-low-memory edge devices (e.g. 4GB RAM) to virtualize and serve giant MoE models (such as DeepSeek-V3 or Mixtral 8x22B) with negligible I/O stall overhead.
Background & Motivation
Serving cutting-edge Mixture-of-Experts (MoE) models on consumer edge devices is bottlenecked by physical memory capacity. Even when sharded, retaining active expert weights exceeds local RAM limits.$L+4$ cold experts asynchronously during layer $L$ forward compute), transfer latencies from disk/host memory are completely hidden behind computation, enabling a 4GB device to "pseudo-host" a 32GB+ expert pool.
By partitioning MoE experts into tiered storage (resident VRAM/RAM for hot experts, NVMe SSD for cold experts) and employing an early-layer predictor (prefetching layer
Key Changes
Tiered MoE Expert Models & Telemetry (
src/exo/shared/types/moe_offload.py):OffloadedExpertWeight: Immutable container capturing expert weights across tiered storage (vram,host_ram,nvme_ssd), access timestamps, and hot-pinning flags.ExpertCacheSlot: Defines physical slot capacity and assigned keys.MoEOffloadTelemetry: Tracks hot cache hits, prefetch hits, cold SSD misses, total swap-in volume, and I/O latency masking ratios.Early-Layer Predictor & Hierarchical Engine (
src/exo/worker/engines/moe/hierarchical_expert_manager.py):EarlyLayerPrefetchPredictor: Extracts Top-K expert activations and projects candidate indices across lookahead layers (HierarchicalExpertEngine:Module Exports (
src/exo/worker/engines/moe/__init__.py):HierarchicalExpertEngineandEarlyLayerPrefetchPredictor.Unit Tests (
src/exo/shared/tests/test_moe_hierarchical_offload.py):Verification
.venv/Scripts/pytest.exe src/exo/shared/tests/test_moe_hierarchical_offload.py # 6 passed in 0.10s.venv/Scripts/ruff.exe check src/exo/shared/types/moe_offload.py src/exo/worker/engines/moe/hierarchical_expert_manager.py src/exo/worker/engines/moe/__init__.py src/exo/shared/tests/test_moe_hierarchical_offload.py # All checks passed!Related Issues
人人都能跑llm.md(Hierarchical Expert Offloading & Speculative Prefetching)