Instructions to use solarkyle/GLM-4.7-Flash-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use solarkyle/GLM-4.7-Flash-GGUF with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="solarkyle/GLM-4.7-Flash-GGUF", filename="GLM-4.7-Flash-Q4_K_M.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use solarkyle/GLM-4.7-Flash-GGUF with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf solarkyle/GLM-4.7-Flash-GGUF:Q4_K_M # Run inference directly in the terminal: llama-cli -hf solarkyle/GLM-4.7-Flash-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf solarkyle/GLM-4.7-Flash-GGUF:Q4_K_M # Run inference directly in the terminal: llama-cli -hf solarkyle/GLM-4.7-Flash-GGUF:Q4_K_M
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 solarkyle/GLM-4.7-Flash-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf solarkyle/GLM-4.7-Flash-GGUF:Q4_K_M
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 solarkyle/GLM-4.7-Flash-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf solarkyle/GLM-4.7-Flash-GGUF:Q4_K_M
Use Docker
docker model run hf.co/solarkyle/GLM-4.7-Flash-GGUF:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use solarkyle/GLM-4.7-Flash-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "solarkyle/GLM-4.7-Flash-GGUF" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "solarkyle/GLM-4.7-Flash-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/solarkyle/GLM-4.7-Flash-GGUF:Q4_K_M
- Ollama
How to use solarkyle/GLM-4.7-Flash-GGUF with Ollama:
ollama run hf.co/solarkyle/GLM-4.7-Flash-GGUF:Q4_K_M
- Unsloth Studio new
How to use solarkyle/GLM-4.7-Flash-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 solarkyle/GLM-4.7-Flash-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 solarkyle/GLM-4.7-Flash-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for solarkyle/GLM-4.7-Flash-GGUF to start chatting
- Pi new
How to use solarkyle/GLM-4.7-Flash-GGUF with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf solarkyle/GLM-4.7-Flash-GGUF:Q4_K_M
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": "solarkyle/GLM-4.7-Flash-GGUF:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use solarkyle/GLM-4.7-Flash-GGUF with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf solarkyle/GLM-4.7-Flash-GGUF:Q4_K_M
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 solarkyle/GLM-4.7-Flash-GGUF:Q4_K_M
Run Hermes
hermes
- Docker Model Runner
How to use solarkyle/GLM-4.7-Flash-GGUF with Docker Model Runner:
docker model run hf.co/solarkyle/GLM-4.7-Flash-GGUF:Q4_K_M
- Lemonade
How to use solarkyle/GLM-4.7-Flash-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull solarkyle/GLM-4.7-Flash-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.GLM-4.7-Flash-GGUF-Q4_K_M
List all available models
lemonade list
GLM-4.7-Flash-GGUF-Q4_K_M
GGUF quantization of zai-org/GLM-4.7-Flash for use with llama.cpp and compatible inference engines.
This is my first quant! Let me know if something seems off or if you run into issues.
Model Details
| Property | Value |
|---|---|
| Architecture | Glm4MoeLiteForCausalLM (MoE with MLA) |
| Total Parameters | ~30B |
| Active Parameters | ~3B per forward pass |
| Experts | 64 routed + 1 shared, 4 active per token |
| Attention | Multi-Head Latent Attention (MLA) |
| Context Length | 32,768 tokens |
| Original Format | BF16 safetensors (62.5 GB) |
Available Quantizations
| Filename | Quant Type | Size | Description |
|---|---|---|---|
GLM-4.7-Flash-Q4_K_M.gguf |
Q4_K_M | 16.89 GB | Medium quality 4-bit, good balance of size/quality |
Quantization Process
The Challenge
GLM-4.7-Flash uses a unique architecture that wasn't directly supported by llama.cpp at the time of quantization:
- MoE (Mixture of Experts) - 64 routed experts + 1 shared expert, with 4 experts active per token
- MLA (Multi-Head Latent Attention) - A compressed attention mechanism similar to DeepSeek-V2 that uses low-rank projections
The Glm4MoeLiteForCausalLM architecture combines both features in a way that standard GLM4 support doesn't handle.
The Solution
We modified convert_hf_to_gguf.py to register Glm4MoeLiteForCausalLM under the DeepseekV2Model class, which already has proper tensor mappings for MLA attention:
# Added to DeepseekV2Model registration
@ModelBase.register(
"DeepseekV2ForCausalLM",
"DeepseekV3ForCausalLM",
"KimiVLForConditionalGeneration",
"YoutuForCausalLM",
"YoutuVLForConditionalGeneration",
"Glm4MoeLiteForCausalLM" # <-- Added this
)
class DeepseekV2Model(TextModel):
We also added the tokenizer hash for proper tokenization:
if chkhsh == "cdf5f35325780597efd76153d4d1c16778f766173908894c04afc20108536267":
res = "glm4"
Conversion Pipeline
HuggingFace safetensors (62.5 GB BF16)
โ convert_hf_to_gguf.py (modified)
BF16 GGUF (55.79 GB)
โ llama-quantize
Q4_K_M GGUF (16.89 GB)
Quantization Notes
- 47 of 563 tensors required fallback quantization (q5_0 instead of q4_K) due to dimension requirements
- MoE expert weights compressed from 384 MB each to ~108-157 MB
- Total size reduction: ~70% from BF16
Testing
Quick inference test with llama-cli (CPU):
- Prompt processing: 93.8 tokens/second
- Generation: 19.8 tokens/second
The model loads and generates coherent text. GPU acceleration with CUDA should provide significantly better performance.
Usage with llama.cpp
# Download the model
huggingface-cli download solarkyle/GLM-4.7-Flash-GGUF GLM-4.7-Flash-Q4_K_M.gguf --local-dir .
# Run inference (CPU)
./llama-cli -m GLM-4.7-Flash-Q4_K_M.gguf -p "Hello, I am GLM-4.7-Flash" -n 256
# Run inference (GPU - adjust layers based on VRAM)
./llama-cli -m GLM-4.7-Flash-Q4_K_M.gguf -p "Hello, I am GLM-4.7-Flash" -n 256 -ngl 35
Source Code
The conversion scripts and process documentation are available at: github.com/solarkyle/GLM-4.7-Flash-GGUF
Credits
- Original model: zai-org/GLM-4.7-Flash
- Quantization: solarkyle
- Tools: llama.cpp (b7772)
Feedback
This is my first quant - feedback welcome! If you notice any issues with quality, compatibility, or have suggestions for improvement, please open an issue on the GitHub repo or leave a comment here.
- Downloads last month
- 197
4-bit
Model tree for solarkyle/GLM-4.7-Flash-GGUF
Base model
zai-org/GLM-4.7-Flash