File size: 10,362 Bytes
03d6b4a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
---
license: cc-by-nc-sa-4.0
datasets:
- camel-ai/code
- ehartford/wizard_vicuna_70k_unfiltered
- anon8231489123/ShareGPT_Vicuna_unfiltered
- timdettmers/openassistant-guanaco
- camel-ai/math
- camel-ai/biology
- camel-ai/chemistry
- camel-ai/ai_society
- jondurbin/airoboros-gpt4-1.2
- LongConversations
- camel-ai/physics
tags:
- Composer
- MosaicML
- llm-foundry
- gptq
- quantized
- 8bit
- w8a8
base_model: mosaicml/mpt-30b-chat
quantized_by: adamrb
inference: true
---
# MPT-30B-Chat W8A8-GPTQ Quantized
This is an 8-bit weight, 8-bit activation (W8A8) GPTQ-quantized version of the original [MPT-30B-Chat](https://huggingface.co/mosaicml/mpt-30b-chat) model from MosaicML. The model has been quantized using [GPTQModel](https://github.com/ModelCloud/GPTQModel) to reduce memory requirements while maintaining excellent performance.
MPT-30B-Chat is a chatbot-like model for dialogue generation. It was built by finetuning [MPT-30B](https://huggingface.co/mosaicml/mpt-30b) on the [ShareGPT-Vicuna](https://huggingface.co/datasets/anon8231489123/ShareGPT_Vicuna_unfiltered), [Camel-AI](https://huggingface.co/camel-ai), [GPTeacher](https://github.com/teknium1/GPTeacher), [Guanaco](https://huggingface.co/datasets/timdettmers/openassistant-guanaco), [Baize](https://github.com/project-baize/baize-chatbot) and some generated datasets.
* License: _CC-By-NC-SA-4.0_ (non-commercial use only)
This model was trained by [MosaicML](https://www.mosaicml.com) and quantized by adamrb using GPTQModel.
## Quantization Benefits
- **Balanced Performance**: 8-bit quantization offers excellent quality with good memory savings
- **Better Quality**: Higher precision than 4-bit while still reducing memory usage significantly
- **Stable Inference**: More numerically stable than 4-bit quantization
- **Wide Compatibility**: Works well across different hardware configurations
## Quantization Details
- **Method**: GPTQ (8-bit weights and activations)
- **Group Size**: 128
- **Calibration Dataset**: HuggingFaceH4/ultrachat_200k (20 samples)
- **Quantization Library**: GPTQModel v2.2.0+
- **Supported Kernels**: MarlinQuantLinear, TritonV2QuantLinear, TorchQuantLinear
## Model Date
June 22, 2023 (Original), Quantized: July 2025
## Model License
_CC-By-NC-SA-4.0_ (non-commercial use only)
## Documentation
* [Blog post: Raising the bar for open-source foundation models](https://www.mosaicml.com/blog/mpt-30b)
* [Codebase (mosaicml/llm-foundry repo)](https://github.com/mosaicml/llm-foundry/)
* [GPTQModel Documentation](https://github.com/ModelCloud/GPTQModel)
* Questions: Feel free to contact us via the [MosaicML Community Slack](https://mosaicml.me/slack)!
## How to Use
### With GPTQModel (Recommended)
```python
from gptqmodel import GPTQModel
# Load the quantized model
model = GPTQModel.load(
"adamrb/mpt-30b-chat-w8a8-gptq",
device="cuda:0",
trust_remote_code=True
)
# Generate text
result = model.generate("Hello, my name is")[0]
print(model.tokenizer.decode(result))
```
### With Transformers + AutoGPTQ
```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, GPTQConfig
# Configure GPTQ for 8-bit
gptq_config = GPTQConfig(
bits=8,
group_size=128,
desc_act=False
)
# Load model and tokenizer
model = AutoModelForCausalLM.from_pretrained(
"adamrb/mpt-30b-chat-w8a8-gptq",
device_map="auto",
torch_dtype=torch.float16,
quantization_config=gptq_config,
trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained(
"adamrb/mpt-30b-chat-w8a8-gptq",
trust_remote_code=True
)
# Generate text
inputs = tokenizer("Hello, how can I help you today?", return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=100,
do_sample=True,
temperature=0.7,
pad_token_id=tokenizer.eos_token_id
)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
```
### With vLLM (High Performance Inference)
```python
from vllm import LLM, SamplingParams
# Initialize vLLM with GPTQ quantization
llm = LLM(
model="adamrb/mpt-30b-chat-w8a8-gptq",
quantization="gptq",
dtype="float16",
trust_remote_code=True,
max_model_len=4096
)
# Set up sampling parameters
sampling_params = SamplingParams(
temperature=0.7,
top_p=0.9,
max_tokens=100
)
# Generate text
prompts = ["Hello, my name is", "The future of AI is"]
outputs = llm.generate(prompts, sampling_params)
for output in outputs:
print(f"Generated text: {output.outputs[0].text}")
```
Note: This model requires that `trust_remote_code=True` be passed to the loading methods. This is because we use a custom `MPT` model architecture.
## Chat Template
This model uses a specific chat template. Here's how to format conversations:
```python
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("adamrb/mpt-30b-chat-w8a8-gptq")
messages = [
{"role": "user", "content": "What is the capital of France?"},
{"role": "assistant", "content": "The capital of France is Paris."},
{"role": "user", "content": "What is its population?"}
]
formatted_chat = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
print(formatted_chat)
```
## Model Performance
### Memory Usage Comparison
| Model Version | Size | VRAM Usage (FP16) | VRAM Usage (BF16) |
|---------------|------|-------------------|-------------------|
| Original FP16 | ~58GB | ~60GB | ~58GB |
| **W8A8 GPTQ** | **~30GB** | **~32GB** | **~30GB** |
| W4A16 GPTQ | ~15GB | ~16GB | ~15GB |
### Quality vs Efficiency Trade-off
- **W8A8**: Better quality retention, moderate memory savings
- **W4A16**: Maximum memory savings, slight quality trade-off
### Hardware Requirements
- **Minimum VRAM**: 32GB (for basic inference)
- **Recommended VRAM**: 40GB+ (for optimal performance)
- **Supported GPUs**: A6000, RTX 6000 Ada, A100, H100, etc.
## Model Description
The architecture is a modification of a standard decoder-only transformer, now optimized with 8-bit quantization.
The model has been modified from a standard transformer in the following ways:
* It uses [FlashAttention](https://arxiv.org/pdf/2205.14135.pdf)
* It uses [ALiBi (Attention with Linear Biases)](https://arxiv.org/abs/2108.12409) and does not use positional embeddings
* It does not use biases
* **Quantized with GPTQ for 8-bit weights and activations**
| Hyperparameter | Value |
|----------------|-------|
|n_parameters | 29.95B |
|n_layers | 48 |
| n_heads | 64 |
| d_model | 7168 |
| vocab size | 50432 |
| sequence length | 8192 |
| **quantization** | **8-bit weights and activations** |
| **group size** | **128** |
## Quantization Configuration
```json
{
"bits": 8,
"group_size": 128,
"damp_percent": 0.1,
"desc_act": false,
"static_groups": false,
"sym": true,
"true_sequential": true,
"model_name_or_path": null,
"model_file_base_name": "model"
}
```
## Training Data Mix
The original model was trained on the following data mix:
| Data Source | Number of Tokens in Source | Proportion |
|-------------|----------------------------|------------|
| Airoboros/GPT4-1.2 | 26.4M | 1.71% |
| Baize | 55.0M | 3.57% |
| Camel | 301M | 19.54% |
| GPTeacher | 7.56M | 0.49% |
| Guanaco | 15.6M | 1.02% |
| LongCoversations | 18.4M | 1.19% |
| ShareGPT | 821M | 53.24% |
| WizardLM | 297M | 19.23% |
## Use Cases
### When to Choose W8A8 over W4A16:
- **Quality Priority**: When you need the best possible quality retention
- **Moderate Memory Constraints**: When you have sufficient VRAM but want some memory savings
- **Stable Inference**: When numerical stability is important for your application
- **Production Deployment**: When you need a balance of efficiency and reliability
### When to Choose W4A16 instead:
- **Extreme Memory Constraints**: When VRAM is very limited
- **Maximum Throughput**: When you need to serve many concurrent requests
- **Edge Deployment**: When running on resource-constrained hardware
## Limitations and Biases
_The following language is modified from [EleutherAI's GPT-NeoX-20B](https://huggingface.co/EleutherAI/gpt-neox-20b)_
MPT-30B-Chat can produce factually incorrect output, and should not be relied on to produce factually accurate information.
MPT-30B-Chat was trained on various public datasets.
While great efforts have been taken to clean the pretraining data, it is possible that this model could generate lewd, biased or otherwise offensive outputs.
**Additional Quantization Considerations:**
- 8-bit quantization provides better numerical stability than 4-bit
- Quality retention is excellent compared to the original model
- Performance may vary across different hardware configurations
## Troubleshooting
### Common Issues
1. **CUDA Out of Memory**: This model requires more VRAM than the 4-bit version
2. **Slow Inference**: Ensure you're using the appropriate quantization backend for your hardware
3. **Quality Issues**: Try different sampling parameters (temperature, top_p, top_k)
### Performance Tips
- Use `torch.compile()` for faster inference on compatible PyTorch versions
- Enable FlashAttention with `attn_impl='triton'` for better memory efficiency
- Use mixed precision (fp16/bf16) for optimal performance
## Acknowledgements
This model was finetuned by Sam Havens and the MosaicML NLP team. GPTQ quantization by adamrb using GPTQModel.
## Disclaimer
The license on this model does not constitute legal advice. We are not responsible for the actions of third parties who use this model. Please consult an attorney before using this model for commercial purposes.
## Citation
Please cite this model using the following format:
```
@online{MosaicML2023Introducing,
author = {MosaicML NLP Team},
title = {Introducing MPT-30B: Raising the bar for open-source foundation models},
year = {2023},
url = {www.mosaicml.com/blog/mpt-30b},
note = {Accessed: 2023-06-22},
urldate = {2023-06-22}
}
```
For the quantization method, please also cite:
```
@article{frantar-gptq,
title={{GPTQ}: Accurate Post-training Compression for Generative Pretrained Transformers},
author={Elias Frantar and Saleh Ashkboos and Torsten Hoefler and Dan Alistarh},
journal={arXiv preprint arXiv:2210.17323},
year={2022}
}
``` |