BitCPM-CANN-8B-unquantized 是 BitCPM-CANN-8B 的未量化量化感知训练(QAT)检查点,专为持续预训练和微调而设计。它保留了全精度的潜在权重,并通过 modeling.py 中定义的三元伪量化器(权重 → {-1, 0, 1},带有分组缩放,通过 STE 进行训练),使模型能够在量化约束下继续学习。技术细节请参见我们的技术报告。
⚠️ 此模型不适合直接推理。 如需推理,请使用伪量化版本:openbmb/BitCPM-CANN-8B。
唯一要求是前向传播必须通过附带的 modeling.py(其中包含三元伪量化器)。加载模型时需设置 trust_remote_code=True,且不要替换或绕过模型的前向逻辑。
我们在 example 目录中提供了即用型训练脚本(以 1B 模型为例):
example/run.sh + example/train.pyexample/run_sft.sh + example/train_sft.py快速开始:
# Continued pre-training
cd example && bash run.sh
# Supervised fine-tuning
cd example && bash run_sft.sh任何支持使用自定义代码加载 HuggingFace 模型的框架都可使用,例如 LLaMA Factory、HuggingFace Trainer 等。关键是要确保设置 trust_remote_code=True:
from transformers import AutoModelForCausalLM, AutoTokenizer
path = 'openbmb/BitCPM-CANN-8B-unquantized'
tokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
path,
torch_dtype=torch.bfloat16,
trust_remote_code=True
)
# Use with your preferred framework (LLaMA Factory, HF Trainer, etc.)
# The ternary fake quantizer in modeling.py is applied automatically during forward pass.训练完成后,使用 qat-convert.py 融合伪量化器,并生成可用于推理的伪量化权重:
python qat-convert.py \
--input_bin <path-to-finetuned-pytorch.bin> \
--output <path-to-output-pseudo-quantized-pytorch.bin> \
--quant_type ternary \
--group_size -1转换后的模型可以按照与 openbmb/BitCPM-CANN-8B 相同的方式加载进行推理,无需特殊的量化库。
┌─────────────────────────────────┐
│ BitCPM-CANN-8B-unquantized │ ← This model (QAT checkpoint + fake quantizer in modeling.py)
└───────────────┬─────────────────┘
│
▼ Train (DeepSpeed / LLaMA Factory / HF Trainer / ...)
┌─────────────────────────────────┐
│ Fine-tuned checkpoint │ ← Still contains un-fused QAT parameters
└───────────────┬─────────────────┘
│
▼ python qat-convert.py --quant_type ternary --group_size -1
┌─────────────────────────────────┐
│ Pseudo-quantized model │ ← Ready for inference (same format as BitCPM-CANN-8B)
└─────────────────────────────────┘| 模型 | HuggingFace(推理) | HuggingFace(微调) |
|---|---|---|
| BitCPM-CANN-0.5B | openbmb/BitCPM-CANN-0.5B | openbmb/BitCPM-CANN-0.5B-unquantized |
| BitCPM-CANN-1B | openbmb/BitCPM-CANN-1B | openbmb/BitCPM-CANN-1B-unquantized |
| BitCPM-CANN-3B | openbmb/BitCPM-CANN-3B | openbmb/BitCPM-CANN-3B-unquantized |
| BitCPM-CANN-8B | openbmb/BitCPM-CANN-8B | openbmb/BitCPM-CANN-8B-unquantized |
@article{bitcpmcann,
title={{BitCPM-CANN}: Native 1.58-Bit Large Language Model Training on Ascend NPU},
author={BitCPM Team},
year={2026}
}