fix(moe): size mixed-GGUF expert banks from GGUF metadata - #1
Open
zyy0212time-del wants to merge 1 commit into
Open
Conversation
bank_bytes_estimate() returned None for the mixed-GGUF route (expert_quant="gguf"), so the auto pageable-GPU planner could not size the expert banks and silently skipped split residency. Add a generic expert_bank_geometry() helper (shared with the qwen35moe/laguna GGUF expert loaders) and a "gguf" branch in bank_bytes_estimate() that sizes the uniform flat-slot HostBank geometry (layers x experts x aligned gate_up/down strides), not raw payload bytes. Unknown, missing, or malformed type metadata returns None instead of guessing.
Author
|
Hi @lucaspirola — just a gentle ping on this stacked fix when you have a chance. It is still scoped to the mixed-GGUF bank-sizing gap discovered while validating FlashML-org#196, with the regression tests and native-Windows E2E result included in the PR description. Happy to rebase or retarget it if you would prefer to update FlashML-org#196 first. No rush — I mainly wanted to make sure it didn't get lost. |
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.
Summary
bank_bytes_estimate()can now size mixed-GGUF expert banks (expert_quant="gguf") from model metadata, allowing the automatic pageable-GPU residency planner to account for them before loading. Allocation and estimation share the same GGUF expert-bank geometry helper.Problem
For mixed-GGUF checkpoints such as qwen35moe / Laguna GGUF,
bank_bytes_estimate()returnedNone, so the automatic planner had no usable bank size and skipped pre-load split-residency planning.Raw GGUF tensor payload bytes are not an equivalent substitute. The expert banks use uniform flat
[num_experts, stride]slots, with gate/up and down strides determined by the maximum participating quant geometry and aligned to 64 bytes. For example, a Q4_K down layer may occupy a slot sized for the larger Q6_K down geometry.Root cause
The GGUF expert-bank geometry already existed in the qwen35moe and Laguna loaders, but the same calculation was duplicated locally and unavailable to
bank_bytes_estimate().The generic fixed-format sizing table therefore could not safely size the mixed-GGUF layout.
Fix
Add a shared
expert_bank_geometry(config)helper based on the existing GGUFrow_bytes()block geometry and per-layergguf_expert_types.Reuse that helper in both the qwen35moe and Laguna GGUF loaders.
Add a
"gguf"path tobank_bytes_estimate()using:num_moe_layers * num_experts * (gate_up_stride + down_stride)Return
Nonefor unknown quant types, incomplete metadata, or malformed type entries rather than producing a potentially unsafe estimate.Leave existing non-GGUF estimation paths unchanged.
Validation
Added 8 CPU/synthetic repository regression tests covering mixed global-max geometry, homogeneous GGUF layouts, exact sizing, unsupported/missing/malformed metadata, the existing non-GGUF path, and shared geometry use across both model loaders and the estimator.
For
Ornith-1.5-35B-A3B-Abliterated-Q4_K_M:1,179,648B/expert860,160B/expert522,190,848B20,887,633,920BA native Windows / RTX 5060 Laptop E2E validation with a 15 GiB pin budget and no
FT55_DEBUG_BANK_BYTESoverride selected 10 pageable + 30 pinned MoE layers, completed 60/60 host registrations with14.589844 GiBcumulatively registered, reached/health = ready, and returned HTTP 200 with the expected"OK"smoke response.This is a generic sizing fix rather than a Windows-specific change; no performance claims are made.