GGUF
glm5_next
Mixture of Experts
expert-pruning
reap
quantization
evaluation
negative-result
imatrix
conversational
Instructions to use patrickbdevaney/GLM-5.3-Flash-prune-vs-quant-matched-bytes with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use patrickbdevaney/GLM-5.3-Flash-prune-vs-quant-matched-bytes with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf patrickbdevaney/GLM-5.3-Flash-prune-vs-quant-matched-bytes # Run inference directly in the terminal: llama cli -hf patrickbdevaney/GLM-5.3-Flash-prune-vs-quant-matched-bytes
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf patrickbdevaney/GLM-5.3-Flash-prune-vs-quant-matched-bytes # Run inference directly in the terminal: llama cli -hf patrickbdevaney/GLM-5.3-Flash-prune-vs-quant-matched-bytes
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf patrickbdevaney/GLM-5.3-Flash-prune-vs-quant-matched-bytes # Run inference directly in the terminal: ./build/bin/llama cli -hf patrickbdevaney/GLM-5.3-Flash-prune-vs-quant-matched-bytes
Use Docker
docker model run hf.co/patrickbdevaney/GLM-5.3-Flash-prune-vs-quant-matched-bytes
- Llama new
- LM Studio
- Jan
- Ollama
How to use patrickbdevaney/GLM-5.3-Flash-prune-vs-quant-matched-bytes with Ollama:
ollama run hf.co/patrickbdevaney/GLM-5.3-Flash-prune-vs-quant-matched-bytes
- Unsloth Desktop
- Pi
How to use patrickbdevaney/GLM-5.3-Flash-prune-vs-quant-matched-bytes with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf patrickbdevaney/GLM-5.3-Flash-prune-vs-quant-matched-bytes
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:9931/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "patrickbdevaney/GLM-5.3-Flash-prune-vs-quant-matched-bytes" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use patrickbdevaney/GLM-5.3-Flash-prune-vs-quant-matched-bytes with Docker Model Runner:
docker model run hf.co/patrickbdevaney/GLM-5.3-Flash-prune-vs-quant-matched-bytes
- Lemonade
How to use patrickbdevaney/GLM-5.3-Flash-prune-vs-quant-matched-bytes with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull patrickbdevaney/GLM-5.3-Flash-prune-vs-quant-matched-bytes
Run and chat with the model
lemonade run user.GLM-5.3-Flash-prune-vs-quant-matched-bytes-{{QUANT_TAG}}List all available models
lemonade list
- Hermes Agent
How to use patrickbdevaney/GLM-5.3-Flash-prune-vs-quant-matched-bytes with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf patrickbdevaney/GLM-5.3-Flash-prune-vs-quant-matched-bytes
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:9931/v1 hermes config set model.default patrickbdevaney/GLM-5.3-Flash-prune-vs-quant-matched-bytes
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use patrickbdevaney/GLM-5.3-Flash-prune-vs-quant-matched-bytes with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf patrickbdevaney/GLM-5.3-Flash-prune-vs-quant-matched-bytes
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:9931/v1 \ --custom-model-id "patrickbdevaney/GLM-5.3-Flash-prune-vs-quant-matched-bytes" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
File size: 5,686 Bytes
41a0653 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | """Convert the FP8 GLM-5.3-Flash teacher straight to a PRUNED GGUF, with no pruned-safetensors step.
Why this exists: an s04b-style pruned FP8 checkpoint at 216 experts is ~232 GiB, and its Q8_0
GGUF is another ~246 GiB. Both disks together cannot hold the pair next to the teacher. Expert
pruning is pure selection: drop the experts that are not kept, renumber the survivors 0..K-1 in
ascending original order, and slice the router weight and its correction bias to the same rows.
So the prune can happen while the converter indexes tensor NAMES, before anything is read.
What it changes in upstream `Glm5NextModel` (monkeypatched here; llama.cpp-upstream is untouched):
* filter_tensors: model.layers.L.mlp.experts.X.* -> dropped, or renamed to experts.<new id>
(the FP8 weight_scale_inv tensors are renamed the same way, so dequant pairing still holds);
model.layers.L.mlp.gate.weight / gate.e_score_correction.bias -> index_select(kept).
* n_routed_experts in hparams -> K, so the expert stacking and GGUF expert_count both use K.
Layers absent from the retained file (dense layers 0-2) pass through untouched.
Usage:
convert_pruned_gguf.py --retained artifacts/masks/retained_216.json -- <convert_hf_to_gguf args>
"""
from __future__ import annotations
import json
import re
import sys
from pathlib import Path
LLAMA = Path(__file__).resolve().parent.parent / "llama.cpp-upstream"
def load_keep(path: Path) -> tuple[dict[int, list[int]], int]:
raw = json.loads(path.read_text())
keep: dict[int, list[int]] = {}
for k, ids in raw.items():
m = re.search(r"layers\.(\d+)\.mlp$", k)
if not m:
raise SystemExit(f"unexpected key in {path}: {k}")
ids = sorted(int(i) for i in ids)
if len(set(ids)) != len(ids):
raise SystemExit(f"duplicate expert ids in layer {m.group(1)}")
keep[int(m.group(1))] = ids
sizes = {len(v) for v in keep.values()}
if len(sizes) != 1:
raise SystemExit(f"non-uniform keep counts {sorted(sizes)}: glm5-next has one expert_count")
return keep, sizes.pop()
def main() -> None:
argv = sys.argv[1:]
if "--retained" not in argv or "--" not in argv:
raise SystemExit(__doc__)
retained = Path(argv[argv.index("--retained") + 1])
conv_args = argv[argv.index("--") + 1:]
keep, K = load_keep(retained)
remap = {L: {old: new for new, old in enumerate(ids)} for L, ids in keep.items()}
sys.path.insert(0, str(LLAMA))
sys.path.insert(0, str(LLAMA / "gguf-py"))
import torch
import convert_hf_to_gguf as C
from conversion.glm import Glm5NextModel
from conversion.base import logger
idx_t = {L: torch.tensor(ids, dtype=torch.long) for L, ids in keep.items()}
seen = {"dropped": 0, "renamed": 0, "router": 0, "bias": 0, "n_orig": None}
exp_re = re.compile(r"^model\.layers\.(\d+)\.mlp\.experts\.(\d+)\.(.+)$")
gate_re = re.compile(r"^model\.layers\.(\d+)\.mlp\.gate\.(weight|e_score_correction\.bias)$")
orig_filter = Glm5NextModel.filter_tensors.__func__
def filter_tensors(cls, item):
titem = orig_filter(cls, item)
if titem is None:
return None
name, gen = titem
m = exp_re.match(name)
if m:
L, x, rest = int(m.group(1)), int(m.group(2)), m.group(3)
if L not in remap:
raise RuntimeError(f"routed expert in layer {L}, which has no keep list")
new = remap[L].get(x)
if new is None:
seen["dropped"] += 1
return None
seen["renamed"] += 1
return f"model.layers.{L}.mlp.experts.{new}.{rest}", gen
m = gate_re.match(name)
if m:
L = int(m.group(1))
if L not in idx_t:
raise RuntimeError(f"router in layer {L}, which has no keep list")
seen["router" if m.group(2) == "weight" else "bias"] += 1
idx = idx_t[L]
return name, (lambda g=gen, i=idx: torch.index_select(g(), 0, i))
return name, gen
Glm5NextModel.filter_tensors = classmethod(filter_tensors)
orig_init = Glm5NextModel.__init__
def __init__(self, *a, **kw):
orig_init(self, *a, **kw)
n_orig = self.hparams["n_routed_experts"]
seen["n_orig"] = n_orig
bad = [L for L, ids in keep.items() if ids[-1] >= n_orig]
if bad:
raise RuntimeError(f"keep ids >= {n_orig} in layers {bad}")
self.hparams["n_routed_experts"] = K
if isinstance(self.hparams.get("text_config"), dict):
self.hparams["text_config"]["n_routed_experts"] = K
logger.info(f"PRUNE: {retained.name}: {len(keep)} layers -> {K}/{n_orig} experts; "
f"index pass dropped {seen['dropped']} / renamed {seen['renamed']} expert "
f"tensors, sliced {seen['router']} routers + {seen['bias']} biases")
n_layers = len(keep)
exp_per = seen["renamed"] + seen["dropped"]
# Every routed layer must have been seen in full, and every router sliced.
if seen["router"] != n_layers or seen["bias"] != n_layers:
raise RuntimeError(f"router/bias slices {seen['router']}/{seen['bias']} != {n_layers}")
if exp_per != n_layers * n_orig * 6 or seen["renamed"] != n_layers * K * 6:
raise RuntimeError(f"expert tensor counts off: renamed {seen['renamed']} dropped "
f"{seen['dropped']} for {n_layers} layers x {n_orig} (x6 w+scale)")
Glm5NextModel.__init__ = __init__
sys.argv = ["convert_hf_to_gguf.py", *conv_args]
C.main()
if __name__ == "__main__":
main()
|