OpenBMB 开源社区/BitCPM-CANN-3B-unquantized
模型介绍文件和版本Pull Requests讨论分析
下载使用量0

GitHub 代码库 | 技术报告

👋 欢迎加入我们的 Discord 和 微信 交流群

概述

BitCPM-CANN-3B-unquantized 是 BitCPM-CANN-3B 的未量化量化感知训练(QAT)检查点,专为持续预训练和微调而设计。它保留了全精度的潜在权重,并通过 modeling.py 中定义的三元伪量化器(权重 → {-1, 0, 1},带分组缩放,通过 STE 训练),使模型能够在量化约束下继续学习。技术细节请参见我们的技术报告。

⚠️ 此模型不适合直接推理。 如需推理,请使用伪量化版本:openbmb/BitCPM-CANN-3B。

持续预训练与微调

唯一要求是前向传播必须通过附带的 modeling.py(其中包含三元伪量化器)。加载时需设置 trust_remote_code=True,且不要替换或绕过模型的前向逻辑。

选项 1:DeepSpeed(推荐)

我们在 example 目录中提供了即用型训练脚本(以 1B 模型为例):

  • 持续预训练:example/run.sh + example/train.py
  • 监督微调(SFT):example/run_sft.sh + example/train_sft.py

快速开始:

# Continued pre-training
cd example && bash run.sh

# Supervised fine-tuning
cd example && bash run_sft.sh

选项 2:兼容 HuggingFace 的框架

任何支持通过自定义代码加载 HuggingFace 模型的框架都可以使用,例如 LLaMA Factory、HuggingFace Trainer 等。关键是要确保设置 trust_remote_code=True:

from transformers import AutoModelForCausalLM, AutoTokenizer

path = 'openbmb/BitCPM-CANN-3B-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-3B 相同的方式加载以进行推理,无需特殊的量化库。

工作流程

┌─────────────────────────────────┐
│  BitCPM-CANN-3B-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-3B)
└─────────────────────────────────┘

BitCPM-CANN 模型系列

模型HuggingFace(推理)HuggingFace(微调)
BitCPM-CANN-0.5Bopenbmb/BitCPM-CANN-0.5Bopenbmb/BitCPM-CANN-0.5B-unquantized
BitCPM-CANN-1Bopenbmb/BitCPM-CANN-1Bopenbmb/BitCPM-CANN-1B-unquantized
BitCPM-CANN-3Bopenbmb/BitCPM-CANN-3Bopenbmb/BitCPM-CANN-3B-unquantized
BitCPM-CANN-8Bopenbmb/BitCPM-CANN-8Bopenbmb/BitCPM-CANN-8B-unquantized

声明

  • 作为一种语言模型,BitCPM-CANN 通过学习海量文本生成内容。
  • 但它不具备理解或表达个人观点、价值判断的能力。
  • BitCPM-CANN 生成的任何内容均不代表模型开发者的观点或立场。
  • 因此,用户在使用 BitCPM-CANN 生成的内容时,应自行对其进行评估和验证,并承担全部责任。

许可证

  • 本仓库及 BitCPM-CANN 模型均基于 Apache-2.0 许可证发布。

引用

  • 如果您认为我们的工作有价值,请引用我们的技术报告。
@article{bitcpmcann,
  title={{BitCPM-CANN}: Native 1.58-Bit Large Language Model Training on Ascend NPU},
  author={BitCPM Team},
  year={2026}
}