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"
GLM-5.3-Flash prune vs quantize at matched bytes: findings, data, scripts, v4 saliency and masks
41a0653 verified Download scripts/convert_pruned_gguf.py from patrickbdevaney/GLM-5.3-Flash-prune-vs-quant-matched-bytes: direct link, hf CLI and curl.
- Browser
- Download file 5.69 kB
-
https://huggingface.co/patrickbdevaney/GLM-5.3-Flash-prune-vs-quant-matched-bytes/resolve/main/scripts/convert_pruned_gguf.py
- Command line
-
hf download hf://patrickbdevaney/GLM-5.3-Flash-prune-vs-quant-matched-bytes/scripts/convert_pruned_gguf.py
-
curl -L -o convert_pruned_gguf.py https://huggingface.co/patrickbdevaney/GLM-5.3-Flash-prune-vs-quant-matched-bytes/resolve/main/scripts/convert_pruned_gguf.py
5.69 kB
| """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() | |