Repository navigation
docs(#1295): MoE VMM granularity trade curve — one granule, two experts (not commit-and-subdivide) - #1332
Merged
Conversation
…rts", not commit-and-subdivide #1295 follow-up (analysis before implementation, as the owner asked). Answers the owner's "can VMM commit more at once and subdivide ourselves?" from the already- measured granite router-skew distribution. Finding: the commit-unit granularity that minimises resident mapped physical (and the owner's own waste x transferred-bytes product) is ONE 2 MiB granule holding TWO granite int4 experts (E=2), NOT a large region. Resident physical is U-shaped with its minimum at E=2 (13.34 MiB/layer/step hotness-packed) and rises back to whole- bank levels (24 MiB) for every larger chunk. The "tens of MiB / ~85 experts" proposal sits at the worst end, and any region >24 MiB must span layers -> always resident (every layer active every step) -> whole-bank pinning. - E=2 beats per-expert on physical (16.00 -> 13.34, -17%) because the second expert in a granule you already pay for is free physical. - Two objectives split but both exclude large regions: min resident = E=2 (the cliff/ admission-cap metric), min transferred = E=1 (bandwidth); owner's product = E=2. - Hotness-sorted (coherent-residency) packing helps ~5-14% at every E; static packing decays only 3.4-7.1% across prompt domains, so it is justified. - Interaction with #1295/#1325: span count is NOT the cliff driver, so E=2 does not help the cliff; but lower peak mapped physical raises the admission-cap PLATEAU height (not N_max). Single shared authority preserved. - Decisive framing: sub-division matters only if WE keep VMM paging. OS 4 KiB paging dissolves the granule problem (zero waste + full selectivity). My #1295 finding (binding cost is WDDM fault-in, not our bookkeeping) leans toward OS hinting; the condition to NOT build even E=2 is the OS-hint agent confirming honoured residency hints with an adequate prediction window. Recommendation: never build large-region commit-and-subdivide. If we stay on our own VMM paging, the minimal correct change is E=2 (two experts/granule, hotness-packed, within-layer). No packing code written. Measured: granite-3.0-1b-a400m-instruct f16 Mobius, 32 experts/top-8/24 layers, real IBM router, CPU EP batch 1 greedy, 192 decode steps; granite int4 expert ~0.75 MiB, CUDA device granule 2 MiB. Box: i7-13800H, RTX 4060 Laptop 8GB, driver 591.55, CUDA 13.1, WDDM. scripts/moe_granularity_analysis.py reproduces bit-for-bit. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🔴 Benchmark Regression DetectedComparison of criterion micro-benchmarks: PR head vs merge-base, measured on the same runner in the same job (base first → PR second).
Visual flags: Host infoWhat this cannot catch
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1332 +/- ##
=========================================
+ Coverage 0 80.00% +80.00%
=========================================
Files 0 362 +362
Lines 0 157408 +157408
Branches 0 157408 +157408
=========================================
+ Hits 0 125935 +125935
- Misses 0 26839 +26839
- Partials 0 4634 +4634
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
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.
#1295 follow-up — MoE VMM sub-granule packing: the trade curve (analysis, no impl)
Reporting before implementing, as the owner asked. This answers "can VMM commit more at once and subdivide ourselves?" from the already-measured granite router-skew distribution — no packing code was written.
The question and the trap
The 2 MiB CUDA granule wastes 2.7× on granite int4 experts (~0.75 MiB). The proposed escape — commit a large region (tens of MiB), pack ~85 experts, subdivide ourselves — is favourable on granule waste alone. But committing is also the unit of residency, so the real question is whether sub-division keeps selectivity.
Finding (measured, granite-3.0-1b-a400m, 32e/top-8/24L, real IBM router, CPU EP, 192 decode steps; expert 0.75 MiB, granule 2 MiB)
The granularity that minimises resident mapped physical — and the owner's own
waste × transferredproduct — is ONE 2 MiB granule holding TWO experts (E=2), not a large region.Resident physical is U-shaped with its minimum at E=2 and rises back to whole-bank levels for every larger chunk — the "tens of MiB" proposal is at the worst end. E=2 beats per-expert (16.00→13.34, −17%) because the second expert in a granule you already pay for is free physical.
Why large regions are fatal (inferred)
Every decode step activates all 24 layers, so any chunk spanning layers is hot in 100% of steps. A 64 MiB region (~85 experts) can't fit one layer's 24 MiB bank, so it must span layers → always resident → whole-bank pinning. The "near-zero waste" arithmetic is real but irrelevant; the binding objective is resident physical.
The other answers
N_max). Single shared authority preserved. This is not conflated in the doc.Decisive framing (which architecture this assumes)
Reproduction
scripts/moe_granularity_analysis.pyreuses the exactmoe_router_skew.pyprobe, captures per-step selection sets (the committed JSON has only aggregates), and prints the curve for both packings. Deterministic, bit-for-bit.Box: i7-13800H, RTX 4060 Laptop 8GB, driver 591.55, CUDA 13.1, WDDM. Analysis is CPU-EP (the which experts question is dtype-/EP-independent); granule is the CUDA device granule. No GPU decode claimed. Doc-only + reproducible script; no source change, nothing to test beyond the script's deterministic output.
Follow-up to #1295 (closed by #1325).