Instructions to use giannisan/GLM-5.2-ds4-gguf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use giannisan/GLM-5.2-ds4-gguf with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="giannisan/GLM-5.2-ds4-gguf", filename="GLM-5.2-UD-IQ2_XXS_RoutedIQ2XXS_blk78Q2K.gguf", )
llm.create_chat_completion( messages = "No input example has been defined for this model task." )
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use giannisan/GLM-5.2-ds4-gguf 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 giannisan/GLM-5.2-ds4-gguf:UD-IQ2_XXS_ROUTEDIQ # Run inference directly in the terminal: llama cli -hf giannisan/GLM-5.2-ds4-gguf:UD-IQ2_XXS_ROUTEDIQ
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf giannisan/GLM-5.2-ds4-gguf:UD-IQ2_XXS_ROUTEDIQ # Run inference directly in the terminal: llama cli -hf giannisan/GLM-5.2-ds4-gguf:UD-IQ2_XXS_ROUTEDIQ
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf giannisan/GLM-5.2-ds4-gguf:UD-IQ2_XXS_ROUTEDIQ # Run inference directly in the terminal: ./llama-cli -hf giannisan/GLM-5.2-ds4-gguf:UD-IQ2_XXS_ROUTEDIQ
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf giannisan/GLM-5.2-ds4-gguf:UD-IQ2_XXS_ROUTEDIQ # Run inference directly in the terminal: ./build/bin/llama-cli -hf giannisan/GLM-5.2-ds4-gguf:UD-IQ2_XXS_ROUTEDIQ
Use Docker
docker model run hf.co/giannisan/GLM-5.2-ds4-gguf:UD-IQ2_XXS_ROUTEDIQ
- LM Studio
- Jan
- Ollama
How to use giannisan/GLM-5.2-ds4-gguf with Ollama:
ollama run hf.co/giannisan/GLM-5.2-ds4-gguf:UD-IQ2_XXS_ROUTEDIQ
- Unsloth Studio
How to use giannisan/GLM-5.2-ds4-gguf with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for giannisan/GLM-5.2-ds4-gguf to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for giannisan/GLM-5.2-ds4-gguf to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for giannisan/GLM-5.2-ds4-gguf to start chatting
- Pi
How to use giannisan/GLM-5.2-ds4-gguf with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf giannisan/GLM-5.2-ds4-gguf:UD-IQ2_XXS_ROUTEDIQ
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "giannisan/GLM-5.2-ds4-gguf:UD-IQ2_XXS_ROUTEDIQ" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use giannisan/GLM-5.2-ds4-gguf with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf giannisan/GLM-5.2-ds4-gguf:UD-IQ2_XXS_ROUTEDIQ
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:8080/v1 hermes config set model.default giannisan/GLM-5.2-ds4-gguf:UD-IQ2_XXS_ROUTEDIQ
Run Hermes
hermes
- Atomic Chat new
- OpenClaw new
How to use giannisan/GLM-5.2-ds4-gguf with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf giannisan/GLM-5.2-ds4-gguf:UD-IQ2_XXS_ROUTEDIQ
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:8080/v1 \ --custom-model-id "giannisan/GLM-5.2-ds4-gguf:UD-IQ2_XXS_ROUTEDIQ" \ --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"
- Docker Model Runner
How to use giannisan/GLM-5.2-ds4-gguf with Docker Model Runner:
docker model run hf.co/giannisan/GLM-5.2-ds4-gguf:UD-IQ2_XXS_ROUTEDIQ
- Lemonade
How to use giannisan/GLM-5.2-ds4-gguf with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull giannisan/GLM-5.2-ds4-gguf:UD-IQ2_XXS_ROUTEDIQ
Run and chat with the model
lemonade run user.GLM-5.2-ds4-gguf-UD-IQ2_XXS_ROUTEDIQ
List all available models
lemonade list
GLM-5.2 GGUF for ds4 (SSD streaming, CUDA)
This is a mirror of the official ds4 GGUF of GLM-5.2 (743B MoE) built by antirez and published at antirez/GLM-5.2-GGUF (bit-identical file, same sha256). Credit for the quantization is his; this repo re-documents it with the full per-tensor recipe below and pairs it with the CUDA/SSD-streaming usage notes. It is the file used by the ds4 inference engine, specifically the glm-local branch which adds the CUDA port, SSD expert streaming optimizations, and the first MTP speculative-decoding implementation for GLM 5.2 on any backend.
The design target is machines that cannot hold the model in RAM at all: routed experts are read from disk per token while the ~20 GiB of attention/shared weights stay resident. On an RTX 4060 Ti 16GB + 30GB RAM + a Gen4 NVMe it decodes at ~0.4 tokens/s and climbs with disk bandwidth. Yes, that is slow. It is also a 743B model answering on hardware worth less than a mid-range gaming rig.
Files
| File | Size | Routed experts (ffn_{gate,up,down}_exps) | Everything else |
|---|---|---|---|
| GLM-5.2-UD-IQ2_XXS_RoutedIQ2XXS_blk78Q2K.gguf | 196.6 GiB | IQ2_XXS (layers 3-77, 225 tensors, 177 GiB); blk.78 MTP layer at Q2_K | Q8_0 attention/shared-expert/embeddings/output (872 tensors) + F32 norms (709 tensors), 19.6 GiB |
The MTP draft head (blk.78: full GLM layer + nextn eh_proj/enorm/hnorm/shared_head_norm) is included in the main file. No separate draft gguf is needed: pass the same file to --mtp.
Quantization recipe
The filename is the spec. In detail:
| Tensor class | Quant | Notes |
|---|---|---|
| blk.*.ffn_{gate,up,down}_exps (layers 3-77) | IQ2_XXS | routed experts, uniform on purpose: the streaming expert cache uses fixed-size slabs and the dp4a decode kernels read IQ2_XXS directly |
| blk.78.ffn_{gate,up,down}_exps | Q2_K | the MTP draft layer's experts; never runs in the main decode loop, only feeds speculation |
| blk.*.ffn_{gate,up,down}_shexp | Q8_0 | shared experts |
| blk.{0,1,2}.ffn_{gate,up,down} | Q8_0 | leading dense layers |
| blk.*.attn_q_a, attn_q_b, attn_kv_a_mqa, attn_k_b, attn_v_b, attn_output | Q8_0 | all MLA attention projections |
| blk.*.indexer.attn_q_b, indexer.attn_k | Q8_0 | DSA sparse-indexer projections |
| blk.*.indexer.proj, indexer.k_norm(+bias) | F32 | indexer scoring head |
| blk..ffn_gate_inp (router), blk..exp_probs_b (router bias) | F32 | learned router, kept exact |
| blk.78.nextn.eh_proj | Q8_0 | MTP embed/hidden fusion |
| blk.78.nextn.{enorm,hnorm,shared_head_norm} | F32 | MTP glue norms |
| token_embd.weight, output.weight | Q8_0 | embeddings and output head |
| all *_norm.weight | F32 |
The motivation behind the asymmetry: the routed experts are the majority of the parameter count but each individual expert handles only a fraction of tokens, so aggressive quantization on them costs less in average quality than the same treatment of the router, projections, or shared experts. Keeping the decision-making components at Q8_0 preserves model behavior; crushing the experts buys the size.
SSD streaming adds a second reason: the Q8_0/F32 set (~20 GiB) is resident, so its bytes are paid once in RAM, while the experts are read from disk again and again. Quantizing the experts harder is a per-token bandwidth win; quantizing the resident set harder would save only idle memory. The asymmetry follows the traffic, not just the parameter count.
Usage
Needs the glm-local branch of ds4 (CUDA, sm_89 tested) and a fast NVMe. Expert reads are O_DIRECT through io_uring; host RAM is used for a popularity (LFU) expert cache, so give it whatever you can spare with DS4_CUDA_HOST_EXPERT_CACHE_GB.
git clone -b glm-local https://github.com/giannisanni/neutronstar
cd ds4 && make cuda CUDA_ARCH=sm_89
DS4_GLM_CUDA_UNSAFE=1 DS4_CUDA_HOST_EXPERT_CACHE_GB=7 DS4_CUDA_PARALLEL_FETCH_THREADS=16 \
./ds4 -m GLM-5.2-UD-IQ2_XXS_RoutedIQ2XXS_blk78Q2K.gguf \
--cuda --ssd-streaming --ssd-streaming-cache-experts 64 \
--ctx 4096 --tokens 400 --nothink -p "Tell me something surprising about Suriname."
Interactive chat: drop -p. MTP probe telemetry: add --mtp with DS4_MTP_PROBE=1 and DS4_MTP_STREAMING_UNSAFE=1.
Measured on RTX 4060 Ti 16GB / 30GB DDR5 / Gen4 x4 NVMe: prefill 0.35 t/s, generation
~0.40 t/s with a 7 GiB host expert cache (30% hit rate: the hottest 4% of experts serve
30% of lookups). The engine runs at ~89% of the PCIe link ceiling; a faster disk moves the
number almost linearly.
sha256: a49de64c5020432bdae23de36a423a9660a5621bc0db8d12b66bd8814b07fea0
License
Inherits the upstream GLM-5.2 model license (zai-org). The quantization recipe and this card: MIT.
- Downloads last month
- 174
2-bit
Model tree for giannisan/GLM-5.2-ds4-gguf
Base model
zai-org/GLM-5.2