This is an 8-bit weight, 8-bit activation (W8A8) GPTQ-quantized version of the original MPT-30B-Chat model from MosaicML. The model has been quantized using GPTQModel to reduce memory requirements while maintaining excellent performance.
1from gptqmodel import GPTQModel
23# Load the quantized model4model = GPTQModel.load(5"adamrb/mpt-30b-chat-w8a8-gptq",6 device="cuda:0",7 trust_remote_code=True8)910# Generate text11result = model.generate("Hello, my name is")[0]12print(model.tokenizer.decode(result))
With Transformers + AutoGPTQ
python
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer, GPTQConfig
34# Configure GPTQ for 8-bit5gptq_config = GPTQConfig(6 bits=8,7 group_size=128,8 desc_act=False9)1011# Load model and tokenizer12model = AutoModelForCausalLM.from_pretrained(13"adamrb/mpt-30b-chat-w8a8-gptq",14 device_map="auto",15 torch_dtype=torch.float16,16 quantization_config=gptq_config,17 trust_remote_code=True18)1920tokenizer = AutoTokenizer.from_pretrained(21"adamrb/mpt-30b-chat-w8a8-gptq",22 trust_remote_code=True23)2425# Generate text26inputs = tokenizer("Hello, how can I help you today?", return_tensors="pt").to(model.device)27with torch.no_grad():28 outputs = model.generate(29**inputs,30 max_new_tokens=100,31 do_sample=True,32 temperature=0.7,33 pad_token_id=tokenizer.eos_token_id
34)35print(tokenizer.decode(outputs[0], skip_special_tokens=True))
With vLLM (High Performance Inference)
python
1from vllm import LLM, SamplingParams
23# Initialize vLLM with GPTQ quantization4llm = LLM(5 model="adamrb/mpt-30b-chat-w8a8-gptq",6 quantization="gptq",7 dtype="float16",8 trust_remote_code=True,9 max_model_len=409610)1112# Set up sampling parameters13sampling_params = SamplingParams(14 temperature=0.7,15 top_p=0.9,16 max_tokens=10017)1819# Generate text20prompts =["Hello, my name is","The future of AI is"]21outputs = llm.generate(prompts, sampling_params)2223for output in outputs:24print(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
1from transformers import AutoTokenizer
23tokenizer = AutoTokenizer.from_pretrained("adamrb/mpt-30b-chat-w8a8-gptq")45messages =[6{"role":"user","content":"What is the capital of France?"},7{"role":"assistant","content":"The capital of France is Paris."},8{"role":"user","content":"What is its population?"}9]1011formatted_chat = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)12print(formatted_chat)
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
CUDA Out of Memory: This model requires more VRAM than the 4-bit version
Slow Inference: Ensure you're using the appropriate quantization backend for your hardware
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}
}