Text Generation
Transformers
Safetensors
glm_moe_dsa
llm-compressor
tiny-model
mtp
pr-3225
test-fixture
conversational
Instructions to use inference-optimization/GLM-5-0.88B-MTP with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use inference-optimization/GLM-5-0.88B-MTP with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="inference-optimization/GLM-5-0.88B-MTP") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("inference-optimization/GLM-5-0.88B-MTP") model = AutoModelForCausalLM.from_pretrained("inference-optimization/GLM-5-0.88B-MTP", device_map="auto") 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use inference-optimization/GLM-5-0.88B-MTP with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "inference-optimization/GLM-5-0.88B-MTP" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "inference-optimization/GLM-5-0.88B-MTP", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/inference-optimization/GLM-5-0.88B-MTP
- SGLang
How to use inference-optimization/GLM-5-0.88B-MTP 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 "inference-optimization/GLM-5-0.88B-MTP" \ --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": "inference-optimization/GLM-5-0.88B-MTP", "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 "inference-optimization/GLM-5-0.88B-MTP" \ --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": "inference-optimization/GLM-5-0.88B-MTP", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use inference-optimization/GLM-5-0.88B-MTP with Docker Model Runner:
docker model run hf.co/inference-optimization/GLM-5-0.88B-MTP
simplify model card to recipe and usage
Browse files
README.md
CHANGED
|
@@ -9,73 +9,32 @@ tags:
|
|
| 9 |
- test-fixture
|
| 10 |
---
|
| 11 |
|
| 12 |
-
# GLM-5-0.88B-MTP
|
| 13 |
|
| 14 |
-
|
| 15 |
|
| 16 |
-
##
|
| 17 |
|
| 18 |
-
|
| 19 |
-
- Transformers class: `GlmMoeDsaForCausalLM`.
|
| 20 |
-
- Total source parameters including synthetic MTP: **881,036,032** (0.881B).
|
| 21 |
-
- Backbone parameters: **765,051,392**; MTP parameters: **115,984,640**.
|
| 22 |
-
- Estimated active backbone parameters: **708,428,288**. This routing estimate includes embeddings/dense components, excludes MTP, and is not a FLOP measurement.
|
| 23 |
-
- Precision: BF16.
|
| 24 |
-
- Checkpoint: 5 indexed safetensors shards; 192 indexed tensors. Tokenizer assets are included.
|
| 25 |
-
|
| 26 |
-
## Configuration
|
| 27 |
-
|
| 28 |
-
| Field | Original | Tiny |
|
| 29 |
-
| --- | --- | --- |
|
| 30 |
-
| `num_hidden_layers` | 78 | 4 |
|
| 31 |
-
| `hidden_size` | 6144 | 1536 |
|
| 32 |
-
| `intermediate_size` | 12288 | 6144 |
|
| 33 |
-
| `moe_intermediate_size` | 2048 | 1024 |
|
| 34 |
-
| `n_routed_experts` | 256 | 16 |
|
| 35 |
-
| `num_experts_per_tok` | 8 | 4 |
|
| 36 |
-
| `num_attention_heads` | 64 | 16 |
|
| 37 |
-
| `num_key_value_heads` | 64 | 16 |
|
| 38 |
-
| `q_lora_rank` | 2048 | 2048 |
|
| 39 |
-
| `kv_lora_rank` | 512 | 512 |
|
| 40 |
-
| `num_mtp_layers` | not explicitly set | 1 |
|
| 41 |
-
|
| 42 |
-
The saved `config.json` is authoritative. Depth is reduced; the limitations below apply.
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
## Validation and scope
|
| 46 |
-
|
| 47 |
-
The BF16 backbone reload passed. Model-based MTP loading fails for this reduced-depth fixture: the upstream registered checkpoint pattern expects layer 78, while this fixture's MTP tensors begin at layer 4. No loader or architecture override was applied. MFPTQ successfully quantized 136 modules, including 56 MTP modules. Its Transformers backbone reload had toy perplexity 1.440128 (BF16: 1.439453). MTP execution remains unverified; the vLLM attempt encountered a DeepGEMM extension ABI mismatch.
|
| 48 |
-
|
| 49 |
-
The reloaded **BF16 backbone** toy perplexity was **1.439453** on the same small corpus used for training. This demonstrates learning/reload integrity, not generalization or benchmark quality.
|
| 50 |
-
|
| 51 |
-
MTP projections are synthetic initializations and decoder weights were copied from trained backbone blocks. **MTP was not separately trained**, so these artifacts do not establish draft acceptance quality or inference acceleration.
|
| 52 |
-
|
| 53 |
-
The tested model-based environment used **Transformers 5.17.0**, Torch 2.14.0+cu130, LLM Compressor [`2d52420`](https://github.com/vllm-project/llm-compressor/commit/2d5242056a8a00028686a303771ffc8e2fe27d07), and compressed-tensors [`e69c8dc`](https://github.com/vllm-project/compressed-tensors/commit/e69c8dc58aa152e5f5e36e85800ec1d2e7de5271). Serving smoke checks used vLLM 0.30.0. GLM/DeepSeek model-based MTP loading failed on Transformers **5.15.0**; **5.16 was not tested**. Calibration-dependent MTP quantization remains follow-up work.
|
| 54 |
-
|
| 55 |
-
The model class/loader was not patched to make tests pass. Construction changes were configuration reductions and explicit synthetic checkpoint fixture creation. Structured results and configuration provenance are in [validation.json](validation.json); [artifact-manifest.json](artifact-manifest.json) records checkpoint file hashes.
|
| 56 |
-
|
| 57 |
-
## Backbone loading
|
| 58 |
-
|
| 59 |
-
With the tested Transformers environment (and compressed-tensors for FP8), this loads the backbone. MTP is opt-in; ordinary Transformers backbone generation does not execute it.
|
| 60 |
|
| 61 |
```python
|
| 62 |
-
import
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
)
|
| 70 |
-
inputs = tokenizer("The capital of France is", return_tensors="pt")
|
| 71 |
-
output = model.generate(**inputs, max_new_tokens=16, do_sample=False)
|
| 72 |
-
print(tokenizer.decode(output[0], skip_special_tokens=True))
|
| 73 |
```
|
| 74 |
-
|
| 75 |
-
## Training
|
| 76 |
-
|
| 77 |
-
Random seed 3225; AdamW with learning rate 0.0004 and weight decay 0.01; batch size 2; text truncated to 160 tokens. Training stopped after three consecutive checks at toy perplexity <=3. The corpus follows the [repository tiny-model workflow](https://github.com/vllm-project/llm-compressor/tree/2d5242056a8a00028686a303771ffc8e2fe27d07/.agents/skills/create-tiny-model), with one additional short saying. These are the trained/reloaded artifacts used in testing.
|
| 78 |
-
|
| 79 |
-
## License and attribution
|
| 80 |
-
|
| 81 |
-
Upstream architecture/tokenizer provenance and license: [zai-org/GLM-5](https://huggingface.co/zai-org/GLM-5/tree/c183ef8c61faee82855eca1ed9bb3a9a7ce3b0b2).
|
|
|
|
| 9 |
- test-fixture
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# GLM-5-0.88B-MTP
|
| 13 |
|
| 14 |
+
Small BF16 test model using [zai-org/GLM-5](https://huggingface.co/zai-org/GLM-5), with a toy-trained backbone and synthetic MTP weights.
|
| 15 |
|
| 16 |
+
## Quantization recipe
|
| 17 |
|
| 18 |
+
Uses [LLM Compressor](https://github.com/vllm-project/llm-compressor/pull/3225) model-free quantization. MTP inference has not been verified for this fixture.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
```python
|
| 21 |
+
from llmcompressor import model_free_ptq
|
| 22 |
+
|
| 23 |
+
MODEL_ID = "inference-optimization/GLM-5-0.88B-MTP"
|
| 24 |
+
SAVE_DIR = "GLM-5-0.88B-MTP-FP8-Dynamic-MFPTQ"
|
| 25 |
+
|
| 26 |
+
model_free_ptq(
|
| 27 |
+
model_stub=MODEL_ID,
|
| 28 |
+
save_directory=SAVE_DIR,
|
| 29 |
+
scheme="FP8_DYNAMIC",
|
| 30 |
+
ignore=[
|
| 31 |
+
"lm_head",
|
| 32 |
+
"model.embed_tokens",
|
| 33 |
+
r"re:.*\.mlp\.gate$",
|
| 34 |
+
r"re:.*\.eh_proj$",
|
| 35 |
+
r"re:.*\.indexer\..*",
|
| 36 |
+
],
|
| 37 |
+
max_workers=2,
|
| 38 |
+
device="cuda",
|
| 39 |
)
|
|
|
|
|
|
|
|
|
|
| 40 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|