-
Notifications
You must be signed in to change notification settings - Fork 903
Update mixtral.md #1940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Update mixtral.md #1940
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -285,8 +285,30 @@ output = model.generate(**inputs, max_new_tokens=50) | |
print(tokenizer.decode(output[0], skip_special_tokens=True)) | ||
``` | ||
|
||
Note that for both QLoRA and GPTQ you need at least 30 GB of GPU VRAM to fit the model. You can make it work with 24 GB if you use `device_map="auto"`, like in the example above, so some layers are offloaded to CPU. | ||
You could also just load the model using a GPTQ configuration setting the desired parameters , as usual when working with transformers . | ||
For faster inference and production load we want to leverage the [exllama kernels](https://github.com/turboderp/exllama) ( Achieving the same latency as fp16 model, but 4x less memory usage ) . | ||
|
||
```python | ||
import torch | ||
from transformers | ||
|
||
model_id = "TheBloke/Mixtral-8x7B-v0.1-GPTQ" | ||
tokenizer = AutoTokenizer.from_pretrained(model_id) | ||
|
||
gptq_config = GPTQConfig(bits=4, use_exllama=True) | ||
model = AutoModelForCausalLM.from_pretrained(model_id,quantization_config=gptq_config, | ||
device_map="auto") | ||
saahil1801 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
prompt = "[INST] Explain what a Mixture of Experts is in less than 100 words. [/INST]" | ||
inputs = tokenizer(prompt, return_tensors="pt").to(0) | ||
|
||
output = model.generate(**inputs, max_new_tokens=50) | ||
print(tokenizer.decode(output[0], skip_special_tokens=True)) | ||
``` | ||
|
||
If left unset , the "use_exllama" parameter defaults to True , enabling the exllama backend functionality, specifically designed to work with the "bits" value of 4 . | ||
saahil1801 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Note that for both QLoRA and GPTQ you need at least 30 GB of GPU VRAM to fit the model. You can make it work with 24 GB if you use `device_map="auto"`, like in the example above, so some layers are offloaded to CPU. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this also true when exllama is enabled? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using exllama kernels would significantly reduce only the inferencing speed of the fitted model as it uses 4-bit GPTQ weights for faster computation |
||
|
||
## Disclaimers and ongoing work | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.