Skip to content

Commit 9b05413

Browse files
committed
[model] support ZhipuAI/GLM-4.5 series (#5142)
1 parent 0e1d83d commit 9b05413

File tree

5 files changed

+35
-1
lines changed

5 files changed

+35
-1
lines changed

docs/source/Instruction/支持的模型和数据集.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@
217217
|[swift/Qwen3-235B-A22B-Instruct-2507-AWQ](https://modelscope.cn/models/swift/Qwen3-235B-A22B-Instruct-2507-AWQ)|qwen3_moe|qwen3|transformers>=4.51|✘|-|-|
218218
|[Qwen/Qwen3-Coder-480B-A35B-Instruct](https://modelscope.cn/models/Qwen/Qwen3-Coder-480B-A35B-Instruct)|qwen3_moe|qwen3|transformers>=4.51|✔|coding|[Qwen/Qwen3-Coder-480B-A35B-Instruct](https://huggingface.co/Qwen/Qwen3-Coder-480B-A35B-Instruct)|
219219
|[Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8](https://modelscope.cn/models/Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8)|qwen3_moe|qwen3|transformers>=4.51|✘|coding|[Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8](https://huggingface.co/Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8)|
220+
|[swift/Qwen3-Coder-480B-A35B-Instruct-AWQ](https://modelscope.cn/models/swift/Qwen3-Coder-480B-A35B-Instruct-AWQ)|qwen3_moe|qwen3|transformers>=4.51|✘|coding|-|
220221
|[Qwen/Qwen3-235B-A22B-Thinking-2507](https://modelscope.cn/models/Qwen/Qwen3-235B-A22B-Thinking-2507)|qwen3_moe_thinking|qwen3_thinking|transformers>=4.51|✔|-|[Qwen/Qwen3-235B-A22B-Thinking-2507](https://huggingface.co/Qwen/Qwen3-235B-A22B-Thinking-2507)|
221222
|[Qwen/Qwen3-235B-A22B-Thinking-2507-FP8](https://modelscope.cn/models/Qwen/Qwen3-235B-A22B-Thinking-2507-FP8)|qwen3_moe_thinking|qwen3_thinking|transformers>=4.51|✘|-|[Qwen/Qwen3-235B-A22B-Thinking-2507-FP8](https://huggingface.co/Qwen/Qwen3-235B-A22B-Thinking-2507-FP8)|
222223
|[swift/Qwen3-235B-A22B-Thinking-2507-AWQ](https://modelscope.cn/models/swift/Qwen3-235B-A22B-Thinking-2507-AWQ)|qwen3_moe_thinking|qwen3_thinking|transformers>=4.51|✘|-|-|
@@ -343,6 +344,12 @@
343344
|[ZhipuAI/GLM-4-32B-Base-0414](https://modelscope.cn/models/ZhipuAI/GLM-4-32B-Base-0414)|glm4_0414|glm4_0414|transformers>=4.51|✘|-|[THUDM/GLM-4-32B-Base-0414](https://huggingface.co/THUDM/GLM-4-32B-Base-0414)|
344345
|[ZhipuAI/GLM-Z1-9B-0414](https://modelscope.cn/models/ZhipuAI/GLM-Z1-9B-0414)|glm4_0414|glm4_0414|transformers>=4.51|✘|-|[THUDM/GLM-Z1-9B-0414](https://huggingface.co/THUDM/GLM-Z1-9B-0414)|
345346
|[ZhipuAI/GLM-Z1-32B-0414](https://modelscope.cn/models/ZhipuAI/GLM-Z1-32B-0414)|glm4_0414|glm4_0414|transformers>=4.51|✘|-|[THUDM/GLM-Z1-32B-0414](https://huggingface.co/THUDM/GLM-Z1-32B-0414)|
347+
|[ZhipuAI/GLM-4.5-Air-Base](https://modelscope.cn/models/ZhipuAI/GLM-4.5-Air-Base)|glm4_5|glm4_5|transformers>=4.54|✔|-|[THUDM/GLM-4.5-Air-Base](https://huggingface.co/THUDM/GLM-4.5-Air-Base)|
348+
|[ZhipuAI/GLM-4.5-Air](https://modelscope.cn/models/ZhipuAI/GLM-4.5-Air)|glm4_5|glm4_5|transformers>=4.54|✔|-|[THUDM/GLM-4.5-Air](https://huggingface.co/THUDM/GLM-4.5-Air)|
349+
|[ZhipuAI/GLM-4.5-Air-FP8](https://modelscope.cn/models/ZhipuAI/GLM-4.5-Air-FP8)|glm4_5|glm4_5|transformers>=4.54|✘|-|[THUDM/GLM-4.5-Air-FP8](https://huggingface.co/THUDM/GLM-4.5-Air-FP8)|
350+
|[ZhipuAI/GLM-4.5-Base](https://modelscope.cn/models/ZhipuAI/GLM-4.5-Base)|glm4_5|glm4_5|transformers>=4.54|✔|-|[THUDM/GLM-4.5-Base](https://huggingface.co/THUDM/GLM-4.5-Base)|
351+
|[ZhipuAI/GLM-4.5](https://modelscope.cn/models/ZhipuAI/GLM-4.5)|glm4_5|glm4_5|transformers>=4.54|✔|-|[THUDM/GLM-4.5](https://huggingface.co/THUDM/GLM-4.5)|
352+
|[ZhipuAI/GLM-4.5-FP8](https://modelscope.cn/models/ZhipuAI/GLM-4.5-FP8)|glm4_5|glm4_5|transformers>=4.54|✘|-|[THUDM/GLM-4.5-FP8](https://huggingface.co/THUDM/GLM-4.5-FP8)|
346353
|[ZhipuAI/GLM-Z1-Rumination-32B-0414](https://modelscope.cn/models/ZhipuAI/GLM-Z1-Rumination-32B-0414)|glm4_z1_rumination|glm4_z1_rumination|transformers>4.51|✘|-|[THUDM/GLM-Z1-Rumination-32B-0414](https://huggingface.co/THUDM/GLM-Z1-Rumination-32B-0414)|
347354
|[ZhipuAI/glm-edge-1.5b-chat](https://modelscope.cn/models/ZhipuAI/glm-edge-1.5b-chat)|glm_edge|glm4|transformers>=4.46|✘|-|[THUDM/glm-edge-1.5b-chat](https://huggingface.co/THUDM/glm-edge-1.5b-chat)|
348355
|[ZhipuAI/glm-edge-4b-chat](https://modelscope.cn/models/ZhipuAI/glm-edge-4b-chat)|glm_edge|glm4|transformers>=4.46|✘|-|[THUDM/glm-edge-4b-chat](https://huggingface.co/THUDM/glm-edge-4b-chat)|

docs/source_en/Instruction/Supported-models-and-datasets.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ The table below introduces the models integrated with ms-swift:
217217
|[swift/Qwen3-235B-A22B-Instruct-2507-AWQ](https://modelscope.cn/models/swift/Qwen3-235B-A22B-Instruct-2507-AWQ)|qwen3_moe|qwen3|transformers>=4.51|✘|-|-|
218218
|[Qwen/Qwen3-Coder-480B-A35B-Instruct](https://modelscope.cn/models/Qwen/Qwen3-Coder-480B-A35B-Instruct)|qwen3_moe|qwen3|transformers>=4.51|✔|coding|[Qwen/Qwen3-Coder-480B-A35B-Instruct](https://huggingface.co/Qwen/Qwen3-Coder-480B-A35B-Instruct)|
219219
|[Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8](https://modelscope.cn/models/Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8)|qwen3_moe|qwen3|transformers>=4.51|✘|coding|[Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8](https://huggingface.co/Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8)|
220+
|[swift/Qwen3-Coder-480B-A35B-Instruct-AWQ](https://modelscope.cn/models/swift/Qwen3-Coder-480B-A35B-Instruct-AWQ)|qwen3_moe|qwen3|transformers>=4.51|✘|coding|-|
220221
|[Qwen/Qwen3-235B-A22B-Thinking-2507](https://modelscope.cn/models/Qwen/Qwen3-235B-A22B-Thinking-2507)|qwen3_moe_thinking|qwen3_thinking|transformers>=4.51|✔|-|[Qwen/Qwen3-235B-A22B-Thinking-2507](https://huggingface.co/Qwen/Qwen3-235B-A22B-Thinking-2507)|
221222
|[Qwen/Qwen3-235B-A22B-Thinking-2507-FP8](https://modelscope.cn/models/Qwen/Qwen3-235B-A22B-Thinking-2507-FP8)|qwen3_moe_thinking|qwen3_thinking|transformers>=4.51|✘|-|[Qwen/Qwen3-235B-A22B-Thinking-2507-FP8](https://huggingface.co/Qwen/Qwen3-235B-A22B-Thinking-2507-FP8)|
222223
|[swift/Qwen3-235B-A22B-Thinking-2507-AWQ](https://modelscope.cn/models/swift/Qwen3-235B-A22B-Thinking-2507-AWQ)|qwen3_moe_thinking|qwen3_thinking|transformers>=4.51|✘|-|-|
@@ -343,6 +344,12 @@ The table below introduces the models integrated with ms-swift:
343344
|[ZhipuAI/GLM-4-32B-Base-0414](https://modelscope.cn/models/ZhipuAI/GLM-4-32B-Base-0414)|glm4_0414|glm4_0414|transformers>=4.51|✘|-|[THUDM/GLM-4-32B-Base-0414](https://huggingface.co/THUDM/GLM-4-32B-Base-0414)|
344345
|[ZhipuAI/GLM-Z1-9B-0414](https://modelscope.cn/models/ZhipuAI/GLM-Z1-9B-0414)|glm4_0414|glm4_0414|transformers>=4.51|✘|-|[THUDM/GLM-Z1-9B-0414](https://huggingface.co/THUDM/GLM-Z1-9B-0414)|
345346
|[ZhipuAI/GLM-Z1-32B-0414](https://modelscope.cn/models/ZhipuAI/GLM-Z1-32B-0414)|glm4_0414|glm4_0414|transformers>=4.51|✘|-|[THUDM/GLM-Z1-32B-0414](https://huggingface.co/THUDM/GLM-Z1-32B-0414)|
347+
|[ZhipuAI/GLM-4.5-Air-Base](https://modelscope.cn/models/ZhipuAI/GLM-4.5-Air-Base)|glm4_5|glm4_5|transformers>=4.54|✔|-|[THUDM/GLM-4.5-Air-Base](https://huggingface.co/THUDM/GLM-4.5-Air-Base)|
348+
|[ZhipuAI/GLM-4.5-Air](https://modelscope.cn/models/ZhipuAI/GLM-4.5-Air)|glm4_5|glm4_5|transformers>=4.54|✔|-|[THUDM/GLM-4.5-Air](https://huggingface.co/THUDM/GLM-4.5-Air)|
349+
|[ZhipuAI/GLM-4.5-Air-FP8](https://modelscope.cn/models/ZhipuAI/GLM-4.5-Air-FP8)|glm4_5|glm4_5|transformers>=4.54|✘|-|[THUDM/GLM-4.5-Air-FP8](https://huggingface.co/THUDM/GLM-4.5-Air-FP8)|
350+
|[ZhipuAI/GLM-4.5-Base](https://modelscope.cn/models/ZhipuAI/GLM-4.5-Base)|glm4_5|glm4_5|transformers>=4.54|✔|-|[THUDM/GLM-4.5-Base](https://huggingface.co/THUDM/GLM-4.5-Base)|
351+
|[ZhipuAI/GLM-4.5](https://modelscope.cn/models/ZhipuAI/GLM-4.5)|glm4_5|glm4_5|transformers>=4.54|✔|-|[THUDM/GLM-4.5](https://huggingface.co/THUDM/GLM-4.5)|
352+
|[ZhipuAI/GLM-4.5-FP8](https://modelscope.cn/models/ZhipuAI/GLM-4.5-FP8)|glm4_5|glm4_5|transformers>=4.54|✘|-|[THUDM/GLM-4.5-FP8](https://huggingface.co/THUDM/GLM-4.5-FP8)|
346353
|[ZhipuAI/GLM-Z1-Rumination-32B-0414](https://modelscope.cn/models/ZhipuAI/GLM-Z1-Rumination-32B-0414)|glm4_z1_rumination|glm4_z1_rumination|transformers>4.51|✘|-|[THUDM/GLM-Z1-Rumination-32B-0414](https://huggingface.co/THUDM/GLM-Z1-Rumination-32B-0414)|
347354
|[ZhipuAI/glm-edge-1.5b-chat](https://modelscope.cn/models/ZhipuAI/glm-edge-1.5b-chat)|glm_edge|glm4|transformers>=4.46|✘|-|[THUDM/glm-edge-1.5b-chat](https://huggingface.co/THUDM/glm-edge-1.5b-chat)|
348355
|[ZhipuAI/glm-edge-4b-chat](https://modelscope.cn/models/ZhipuAI/glm-edge-4b-chat)|glm_edge|glm4|transformers>=4.46|✘|-|[THUDM/glm-edge-4b-chat](https://huggingface.co/THUDM/glm-edge-4b-chat)|

swift/llm/model/model/glm.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,16 @@ def get_model_tokenizer_glm_edge_v(model_dir: str, *args, **kwargs):
423423
register_model(
424424
ModelMeta(
425425
LLMModelType.glm4_5,
426-
[],
426+
[
427+
ModelGroup([
428+
Model('ZhipuAI/GLM-4.5-Air-Base', 'THUDM/GLM-4.5-Air-Base'),
429+
Model('ZhipuAI/GLM-4.5-Air', 'THUDM/GLM-4.5-Air'),
430+
Model('ZhipuAI/GLM-4.5-Air-FP8', 'THUDM/GLM-4.5-Air-FP8'),
431+
Model('ZhipuAI/GLM-4.5-Base', 'THUDM/GLM-4.5-Base'),
432+
Model('ZhipuAI/GLM-4.5', 'THUDM/GLM-4.5'),
433+
Model('ZhipuAI/GLM-4.5-FP8', 'THUDM/GLM-4.5-FP8'),
434+
]),
435+
],
427436
TemplateType.glm4_5,
428437
get_model_tokenizer_with_flash_attn,
429438
architectures=['Glm4MoeForCausalLM'],

swift/llm/model/model/qwen.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,7 @@ def _get_cast_dtype(self) -> torch.dtype:
561561
ModelGroup([
562562
Model('Qwen/Qwen3-Coder-480B-A35B-Instruct', 'Qwen/Qwen3-Coder-480B-A35B-Instruct'),
563563
Model('Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8', 'Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8'),
564+
Model('swift/Qwen3-Coder-480B-A35B-Instruct-AWQ'),
564565
],
565566
tags=['coding']),
566567
],

tests/test_align/test_template/test_llm.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,15 @@ def test_ernie():
446446
assert res == res2, f'res: {res}, res2: {res2}'
447447

448448

449+
def test_glm4_5():
450+
messages = [{'role': 'user', 'content': '浙江的省会在哪?'}]
451+
pt_engine = PtEngine('ZhipuAI/GLM-4.5-Air')
452+
res = _infer_model(pt_engine, messages=messages)
453+
pt_engine.default_template.template_backend = 'jinja'
454+
res2 = _infer_model(pt_engine, messages=messages)
455+
assert res == res2, f'res: {res}, res2: {res2}'
456+
457+
449458
if __name__ == '__main__':
450459
from swift.llm import PtEngine, RequestConfig
451460
from swift.utils import get_logger, seed_everything
@@ -490,3 +499,4 @@ def test_ernie():
490499
# test_kimi_dev()
491500
# test_hunyuan()
492501
# test_ernie()
502+
test_glm4_5()

0 commit comments

Comments
 (0)