Repository navigation
Add experimental MoE hybrid CPU and GPU expert execution - #1270
Merged
Merged
Conversation
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.
Adds experimental CPU/GPU expert execution for disk-backed MoE sessions through the common model session option
moe_cpu_share. The CLI exposes--moe-cpu-shareas shorthand for--session-option moe_cpu_share=…; server configuration sets the value inside each model’ssession_options. Cache hits remain on GPU; a configurable fraction of subsequent cache misses executes on CPU while GPU expert work proceeds. CPU computation uses the configured thread count and native quantized weights.The default is
0, leaving hybrid execution disabled. The policy is separate fromBackendConfig; backend selection and server-wide settings are unchanged from main. No model-local changes are required for eligible shared MoE callers.For example, add
"moe_cpu_share": 0.5to the selected model’ssession_optionsobject alongside its existing disk-expert options. Recipes use--session-option <role>.moe_cpu_share=0.5; workflows may configure the option per step.Implementation and scope
PreparedGraphand the GGML scheduler, preserving the original allocation graph and enforcing region boundaries around backend optimization.Hybrid execution performance
RTX 5090, Ryzen 9 7900X, CUDA Debug build, eight CPU threads, disk experts enabled and eight GPU expert-cache slots. Same binary,
moe_cpu_share=0versus0.5, measured sequentially in warmed A→B→B→A order. Wall time is the mean total for three measured requests per block, after a separate short warmup.Nemotron improves by 21.1% and 21.3% in the two run orders. Drama3 and Ming3 timing differences are consistent with run variation, rather than an established performance regression. Peak VRAM is the maximum process-attributed usage over each session's request sequence.
Default-path validation against main
Compared main
33ca47fcbagainst PRb0d9479f5withmoe_cpu_shareomitted, using separate statically linked Debug binaries and identical build settings. Sequential warmed main→PR→PR→main runs used eight threads and local NVMe storage, with a separate short warmup before measured requests. The three MoE models ran on CUDA; FireRed VAD used CPU+BLAS to exercise the shared scheduler without MoE.No material default-path slowdown was observed in this matrix. Drama3 full-GPU and the CPU control averaged approximately 0.5% slower; repeated paired comparisons changed sign. These small differences are not claimed as optimization gains or proof of literally zero overhead.
Hybrid correctness and limitations
Debug CLI/server builds and the focused PreparedGraph and CUDA disk-expert tests pass. A real CUDA server run with separate ordinary and hybrid model entries returns matching transcripts; assignment counters confirm CPU expert execution only for the enabled path. The CLI shorthand also completes a real CUDA request with CPU expert assignments. Invalid values and session isolation are covered by the focused tests.
git diff --checkpasses.