Skip to content

fix(moe): size mixed-GGUF expert banks from GGUF metadata - #1

Open
zyy0212time-del wants to merge 1 commit into
lucaspirola:ornith-sm120-gguf-mmq-phase2from
zyy0212time-del:fix/mixed-gguf-bank-sizing
Open

fix(moe): size mixed-GGUF expert banks from GGUF metadata#1
zyy0212time-del wants to merge 1 commit into
lucaspirola:ornith-sm120-gguf-mmq-phase2from
zyy0212time-del:fix/mixed-gguf-bank-sizing

Conversation

@zyy0212time-del

@zyy0212time-del zyy0212time-del commented Aug 31, 2026

Copy link
Copy Markdown

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() returned None, 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 GGUF row_bytes() block geometry and per-layer gguf_expert_types.

  • Reuse that helper in both the qwen35moe and Laguna GGUF loaders.

  • Add a "gguf" path to bank_bytes_estimate() using:

    num_moe_layers * num_experts * (gate_up_stride + down_stride)

  • Return None for 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:

  • gate/up stride: 1,179,648 B/expert
  • down stride: 860,160 B/expert
  • logical bank size per layer: 522,190,848 B
  • 40-layer total: 20,887,633,920 B
  • estimator delta: 0

A native Windows / RTX 5060 Laptop E2E validation with a 15 GiB pin budget and no FT55_DEBUG_BANK_BYTES override selected 10 pageable + 30 pinned MoE layers, completed 60/60 host registrations with 14.589844 GiB cumulatively 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.

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.
@zyy0212time-del

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant