Instructions to use casperhansen/mixtral-instruct-awq with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use casperhansen/mixtral-instruct-awq with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="casperhansen/mixtral-instruct-awq") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("casperhansen/mixtral-instruct-awq") model = AutoModelForCausalLM.from_pretrained("casperhansen/mixtral-instruct-awq") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use casperhansen/mixtral-instruct-awq with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "casperhansen/mixtral-instruct-awq" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "casperhansen/mixtral-instruct-awq", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/casperhansen/mixtral-instruct-awq
- SGLang
How to use casperhansen/mixtral-instruct-awq with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "casperhansen/mixtral-instruct-awq" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "casperhansen/mixtral-instruct-awq", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "casperhansen/mixtral-instruct-awq" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "casperhansen/mixtral-instruct-awq", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use casperhansen/mixtral-instruct-awq with Docker Model Runner:
docker model run hf.co/casperhansen/mixtral-instruct-awq
Out of memory on RTX 3090
I’m getting out of memory on RTX 3090 (24Go).torch.cuda.OutOfMemoryError: CUDA out of memory....
Here my Python code:
from transformers import AutoTokenizer, AutoModelForCausalLM
from transformers import TextStreamer
# https://huggingface.co/casperhansen/mixtral-instruct-awq
MODEL_ID = "casperhansen/mixtral-instruct-awq"
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForCausalLM.from_pretrained(
MODEL_ID,
device_map="cuda:0",
attn_implementation="flash_attention_2"
)
streamer=TextStreamer(
tokenizer=tokenizer,
skip_prompt=True,
skip_special_tokens=True
)
prompt="[INST] Donne moi un codePython optimisé pour calculer la racine carrée [/INST]"
tokens = tokenizer(
text=prompt,
return_tensors='pt'
).inputs_id.to("cuda:0")
generation_ouput=model.generate(
tokens=tokens,
streamer=streamer,
max_new_tokens=512
)
on vllm and with a different model, I often see a short spike in Memory usage when loading a AWQ model. This is on a 48GB card, so I have the extra memory, shortly after the spike the memory usage is lowered again. Maybe offloading to disk might help.
Could you explain to me how to offloading to disk?
on vllm and with a different model, I often see a short spike in Memory usage when loading a AWQ model. This is on a 48GB card, so I have the extra memory, shortly after the spike the memory usage is lowered again. Maybe offloading to disk might help.
how much of a spike? will 40gb gpu be enough?
UPD: takes around 30-31gb VRAM