Views
No views yet

modeling.py, enabling the model to keep learning under quantization constraints. For technical details, see our Technical Report.⚠️ This model is NOT for direct inference. For inference, use the pseudo-quantized version: openbmb/BitCPM-CANN-8B.
modeling.py (which contains the ternary fake quantizer). Load with trust_remote_code=True and do NOT replace or bypass the model's forward logic.example/run.sh + example/train.pyexample/run_sft.sh + example/train_sft.py1# Continued pre-training
2cd example && bash run.sh
3
4# Supervised fine-tuning
5cd example && bash run_sft.shtrust_remote_code=True:1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3path = 'openbmb/BitCPM-CANN-8B-unquantized'
4tokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True)
5model = AutoModelForCausalLM.from_pretrained(
6 path,
7 torch_dtype=torch.bfloat16,
8 trust_remote_code=True
9)
10
11# Use with your preferred framework (LLaMA Factory, HF Trainer, etc.)
12# The ternary fake quantizer in modeling.py is applied automatically during forward pass.qat-convert.py to fuse the fake quantizer and produce inference-ready pseudo-quantized weights:1python qat-convert.py \
2 --input_bin <path-to-finetuned-pytorch.bin> \
3 --output <path-to-output-pseudo-quantized-pytorch.bin> \
4 --quant_type ternary \
5 --group_size -1┌─────────────────────────────────┐
│ 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)
└─────────────────────────────────┘| Model | HuggingFace (Inference) | HuggingFace (Fine-tuning) |
|---|---|---|
| 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 |
1@article{bitcpmcann,
2 title={{BitCPM-CANN}: Native 1.58-Bit Large Language Model Training on Ascend NPU},
3 author={BitCPM Team},
4 year={2026}
5}