Instructions to use zai-org/GLM-5-FP8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zai-org/GLM-5-FP8 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="zai-org/GLM-5-FP8") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("zai-org/GLM-5-FP8") model = AutoModelForCausalLM.from_pretrained("zai-org/GLM-5-FP8") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use zai-org/GLM-5-FP8 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "zai-org/GLM-5-FP8" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "zai-org/GLM-5-FP8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/zai-org/GLM-5-FP8
- SGLang
How to use zai-org/GLM-5-FP8 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "zai-org/GLM-5-FP8" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "zai-org/GLM-5-FP8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "zai-org/GLM-5-FP8" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "zai-org/GLM-5-FP8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use zai-org/GLM-5-FP8 with Docker Model Runner:
docker model run hf.co/zai-org/GLM-5-FP8
Update README.md
#1
by UnicornChan - opened
README.md
CHANGED
|
@@ -103,6 +103,24 @@ vLLM, SGLang, and xLLM all support local deployment of GLM-5. A simple deploymen
|
|
| 103 |
docker pull lmsysorg/sglang:glm5-blackwell # For Blackwell GPU
|
| 104 |
```
|
| 105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
### Deploy
|
| 107 |
|
| 108 |
+ vLLM
|
|
@@ -139,6 +157,40 @@ vLLM, SGLang, and xLLM all support local deployment of GLM-5. A simple deploymen
|
|
| 139 |
|
| 140 |
Check the [sglang cookbook](https://cookbook.sglang.io/autoregressive/GLM/GLM-5) for more details.
|
| 141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
+ xLLM and other Ascend NPU
|
| 143 |
|
| 144 |
Please check the deployment guide [here](https://github.com/zai-org/GLM-5/blob/main/example/ascend.md).
|
|
|
|
| 103 |
docker pull lmsysorg/sglang:glm5-blackwell # For Blackwell GPU
|
| 104 |
```
|
| 105 |
|
| 106 |
+
+ KTransformers (SGLang + KT-Kernel, CPU-GPU heterogeneous inference)
|
| 107 |
+
|
| 108 |
+
Install SGLang:
|
| 109 |
+
|
| 110 |
+
```bash
|
| 111 |
+
git clone https://github.com/kvcache-ai/sglang.git
|
| 112 |
+
cd sglang
|
| 113 |
+
pip install -e "python[all]"
|
| 114 |
+
```
|
| 115 |
+
|
| 116 |
+
Install KT-Kernel:
|
| 117 |
+
|
| 118 |
+
```bash
|
| 119 |
+
git clone https://github.com/kvcache-ai/ktransformers.git
|
| 120 |
+
git submodule update --init --recursive
|
| 121 |
+
cd kt-kernel && ./install.sh
|
| 122 |
+
```
|
| 123 |
+
|
| 124 |
### Deploy
|
| 125 |
|
| 126 |
+ vLLM
|
|
|
|
| 157 |
|
| 158 |
Check the [sglang cookbook](https://cookbook.sglang.io/autoregressive/GLM/GLM-5) for more details.
|
| 159 |
|
| 160 |
+
+ KTransformers (SGLang + KT-Kernel)
|
| 161 |
+
|
| 162 |
+
```bash
|
| 163 |
+
export PYTORCH_ALLOC_CONF=expandable_segments:True
|
| 164 |
+
export SGLANG_ENABLE_JIT_DEEPGEMM=0
|
| 165 |
+
|
| 166 |
+
python -m sglang.launch_server \
|
| 167 |
+
--host 0.0.0.0 \
|
| 168 |
+
--port 30000 \
|
| 169 |
+
--model zai-org/GLM-5-FP8 \
|
| 170 |
+
--kt-weight-path /path/to/GLM-5-FP8 \
|
| 171 |
+
--kt-cpuinfer 96 \
|
| 172 |
+
--kt-threadpool-count 2 \
|
| 173 |
+
--kt-num-gpu-experts 10 \
|
| 174 |
+
--kt-method BF16 \
|
| 175 |
+
--kt-gpu-prefill-token-threshold 1024 \
|
| 176 |
+
--kt-enable-dynamic-expert-update \
|
| 177 |
+
--kt-expert-placement-strategy uniform \
|
| 178 |
+
--trust-remote-code \
|
| 179 |
+
--mem-fraction-static 0.75 \
|
| 180 |
+
--served-model-name glm-5-fp8 \
|
| 181 |
+
--enable-mixed-chunk \
|
| 182 |
+
--tensor-parallel-size 8 \
|
| 183 |
+
--enable-p2p-check \
|
| 184 |
+
--disable-shared-experts-fusion \
|
| 185 |
+
--chunked-prefill-size 16384 \
|
| 186 |
+
--max-running-requests 4 \
|
| 187 |
+
--max-total-tokens 128000 \
|
| 188 |
+
--attention-backend flashinfer \
|
| 189 |
+
--watchdog-timeout 3000
|
| 190 |
+
```
|
| 191 |
+
|
| 192 |
+
Check the [KTransformers GLM-5 tutorial](https://github.com/kvcache-ai/ktransformers/blob/main/doc/en/kt-kernel/GLM-5-Tutorial.md) for more details.
|
| 193 |
+
|
| 194 |
+ xLLM and other Ascend NPU
|
| 195 |
|
| 196 |
Please check the deployment guide [here](https://github.com/zai-org/GLM-5/blob/main/example/ascend.md).
|