Repository navigation
🚨 Introduce a standalone MoE engine with independent placement and cache policies - #1334
Merged
Merged
Conversation
Move expert resources, prepared execution and independent placement/cache policies into a self-contained engine. Compose MoE graph scheduling and execution scopes through MoePreparedGraph, and migrate Drama3, Ming3 Audio, Nemotron Transcribe, Zonos2 and Zonos3. Remove superseded MoE interfaces and generic context/session coupling. Reuse prepared graph plans, routing workspaces and native single-token expert graphs; retain existing model controls and add the moe-policy session shortcut. Validation: Debug C++17 builds of CLI, server, C API and affected fixture binaries. No tests or inference executed.
Separate completed-work observations from phase timing and supply cache context and lifecycle notifications to eviction policies. Reject evaluation callbacks consistently for shared graph allocation. Add graph ownership, overlap, concurrent-session, scheduler callback and failed-upload recovery assertions, including native Q4_K lifecycle cases. Validation: Debug builds of CLI, server, C API and affected fixture binaries. Tests and inference were not run.
Determine placement applicability from each layer's backend. CPU-only and whole-layer CPU execution bypass fractional placement while retaining policy observations and the native top-k single-token path. Add F32 and Q4_K regression assertions for cache misses with nonzero CPU share, executed row counts and independent expert outputs. Validation: Debug builds passed. Tests and inference were not run.
Keep eligible staged single-token expert operations in the parent graph and map cache IDs through scheduler evaluation while preserving caller callbacks and execution leases. Retain explicit regions for shared graph allocation and preserve phased expert bucket layouts. Align prepared slot-ID views to backend requirements, enable Drama3 shared-gate broadcasting, and migrate the Zonos2 parity caller to engine configuration. Extend independent F32/Q4_K references, exact expert-row boundaries, eviction/reload, stale-handle, synchronization and lifecycle coverage without relaxing numerical tolerances.
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.
Replace duplicated expert storage and execution machinery with a standalone MoE engine, and migrate Drama3, Ming3 Audio, Nemotron Transcribe, Zonos2 and Zonos3. Model code retains routing mathematics, shared experts, residuals and generation; the engine owns expert resources, staging, placement and eviction.
--moe-policy/ session options, with scoped parameters. Include CPU-share, cost-aware placement and frequency-aware eviction; preserve legacy controls and model defaults.Validation
Matched main-versus-branch CUDA A→B→B→A measurements, eight threads, unrelated warmup and repeated X→Y→X requests. RTF uses session wall time; VRAM is process peak.
Disk-expert staging with fractional CPU share omitted:
Drama3 uses Q4_K_S experts, context 4096, five text chunks, 32 cache slots, one CPU expert layer and unpinned staging. Its streaming TTFA is 4,164 → 4,191 ms. Ming3 uses Q4_K, eight slots, zero CPU expert layers and pinned staging. Nemotron uses Q4_K_S experts, eight slots, one CPU expert layer and unpinned staging. ASR inputs are 80 seconds. These are matched staging profiles, not full-GPU performance figures.
All 100 corresponding request results match: audio PCM is byte-identical; ASR structured outputs, including Nemotron timestamps, speaker labels and confidence, match after excluding timing telemetry. Six additional staged Zonos2/3 cases also produce byte-identical PCM versus main.
CPU-share 0.5, eight cache slots, zero whole-layer CPU expert layers and unpinned staging:
All 80 corresponding requests match main: Zonos3 PCM is byte-identical and Ming3 structured transcripts match. CPU assignment counts also match, including across request/shape reuse. An independently controlled skewed-routing case confirms the legacy 44 CPU assignments and 64-row bucket, rather than 124 assignments and a 128-row bucket.
The engine suite passes on CUDA and CPU with F32 and Q4_K fixtures; policy and Drama3 allocation/recovery fixtures pass. Explicit retirement/reprepare and failure recovery are covered by fixtures. The focused final staging/CPU-share measurements above are CUDA-only; they do not establish universal performance gains or benchmark the new cost-aware/frequency policies.