@RedHat_AI:红帽AI团队已为GLM-5.2创建量化检查点!https://huggingface.co/RedHatAI/GLM-5.2-NVF…

X AI KOLs Following 模型

摘要

红帽AI团队使用NVFP4和FP8量化发布了GLM-5.2的量化检查点,模型体积减小超过70%,同时在GPQA上保持高精度。该量化模型与DSpark推测器配合使用,可实现vLLM上的高效部署。

红帽AI团队已为GLM-5.2创建量化检查点! https://huggingface.co/RedHatAI/GLM-5.2-NVFP4-FP8… 该模型在2小时内使用DDP+磁盘卸载完成校准量化。全精度模型需要1.6T显存,但通过MoE层的NVFP4量化和注意力层的FP8量化,模型体积减小超过70%,同时在GPQA上保持最高水平的精度恢复。 将其与新的DSpark推测器配合使用以获得额外吞吐量:https://huggingface.co/RedHatAI/GLM-5.2-speculator.dspark…
查看原文
查看缓存全文

缓存时间: 2026/07/09 15:38

Red Hat AI 团队已为 GLM-5.2 创建量化检查点!

https://huggingface.co/RedHatAI/GLM-5.2-NVFP4-FP8…

该模型使用 DDP + 磁盘卸载在不到 2 小时内完成了校准量化。全精度模型需要 1.6T 显存,但通过将 MoE 层量化为 NVFP4、注意力层量化为 FP8,模型体积缩减超过 70%,同时在 GPQA 上保持了最先进的精度恢复。

搭配新的 DSpark 投机解码器以获得更高吞吐量:https://huggingface.co/RedHatAI/GLM-5.2-speculator.dspark…


RedHatAI/GLM-5.2-NVFP4-FP8 · Hugging Face

来源:https://huggingface.co/RedHatAI/GLM-5.2-NVFP4-FP8 这是 zai-org/GLM-5.2 的量化版本,其中 MoE 层被量化为 NVFP4,注意力层被量化为 FP8 块。

https://huggingface.co/RedHatAI/GLM-5.2-NVFP4-FP8#usage 用法

该模型设计用于 vLLM 部署,需要应用以下补丁:https://github.com/vllm-project/vllm/pull/47780。您可以通过以下命令启动模型:

vllm serve RedHatAI/GLM-5.2-NVFP4-FP8 \ --tensor_parallel_size 4 \ --reasoning-parser glm45 \ --tool-call-parser glm47 \ --enable-auto-tool-choice \ --kv_cache_dtype=fp8 \

https://huggingface.co/RedHatAI/GLM-5.2-NVFP4-FP8#creation-process 创建过程

该模型使用 LLM Compressor (https://github.com/vllm-project/llm-compressor) 创建。示例脚本位于 examples/quantizing_moe/glm5_example.py [示例] GLM5.2 示例](https://github.com/vllm-project/llm-compressor/pull/2869)。使用数据并行和 6 张 A100 量化模型大约需要 3 小时。

LLM Compressor 创建脚本 `` import torch from compressed_tensors.offload import init_dist from compressed_tensors.quantization.quant_scheme import ( FP8_BLOCK, NVFP4, QuantizationScheme, ) from datasets import load_dataset from transformers import AutoModelForCausalLM, AutoTokenizer

from llmcompressor import oneshot from llmcompressor.datasets.utils import get_rank_partition from llmcompressor.modifiers.quantization import QuantizationModifier from llmcompressor.utils import load_context

加载模型

init_dist() model_id = “zai-org/GLM-5.2” with load_context(): model = AutoModelForCausalLM.from_pretrained( model_id, device_map=“auto_offload”, max_memory={}, offload_folder=“/mnt/nvme-data/engine/kylesayrs/offload_folder”, ) tokenizer = AutoTokenizer.from_pretrained(model_id)

选择校准数据集。

DATASET_ID = “HuggingFaceH4/ultrachat_200k” DATASET_SPLIT = “train_sft”

选择样本数量。从 512 个样本开始是个好选择。

增加样本数量可以提高精度。

NUM_CALIBRATION_SAMPLES = 512 MAX_SEQUENCE_LENGTH = 2048

加载数据集并进行预处理。

ds = load_dataset( DATASET_ID, split=get_rank_partition(DATASET_SPLIT, NUM_CALIBRATION_SAMPLES) ) ds = ds.shuffle(seed=42)

def preprocess(example): return { “text”: tokenizer.apply_chat_template( example[“messages”], tokenize=False, ) }

ds = ds.map(preprocess)

对输入进行分词。

def tokenize(sample): return tokenizer( sample[“text”], padding=False, max_length=MAX_SEQUENCE_LENGTH, truncation=True, add_special_tokens=False, )

ds = ds.map(tokenize, remove_columns=ds.column_names)

配置量化算法。

recipe = QuantizationModifier( config_groups={ “attention_shared_experts”: QuantizationScheme( targets=[r“re:.self_attn..“], **FP8_BLOCK, ), “mlp”: QuantizationScheme( targets=[r“re:.mlp..“], **NVFP4, ), }, ignore=[ r“re:^model.layers.[0-2]..*” r“re:.mlp.gate.“, # 并非严格必需 r“re:.*indexer.weights_proj$”, # 对量化敏感 r“lm_head“, ], )

应用算法。

oneshot( model=model, dataset=ds, batch_size=4, recipe=recipe, shuffle_calibration_samples=False, )

压缩保存到磁盘。

注意:基础检查点的 generation_config 需要针对较新版本的 transformers 进行修复

model.generation_config.top_p = None SAVE_DIR = ( “/mnt/nvme-data/engine/kylesayrs/” + model_id.rstrip(“/”).split(“/”)[-1] + “-NVFP4-FP8” ) model.save_pretrained(SAVE_DIR, save_compressed=True) tokenizer.save_pretrained(SAVE_DIR)

torch.distributed.destroy_process_group() ``

https://huggingface.co/RedHatAI/GLM-5.2-NVFP4-FP8#evaluation 评估

基准测试zai-org/GLM-5.2RedHatAI/GLM-5.2-NVFP4-FP8
GPQA-Diamond91.289.1

相似文章

nvidia/GLM-5.2-NVFP4

Hugging Face Models Trending

NVIDIA 发布了 GLM-5.2-NVFP4,这是 ZAI 的 GLM-5.2 MoE 语言模型的量化版本,使用 Model Optimizer 进行了优化,适用于 NVIDIA Blackwell GPU 上的推理。