# How to parallelize inference on a quantized model

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-parallelize-inference-on-a-quantized-model%2F108499%3E%5C
**Category:** Intermediate\
**Created:** [September 24, 2024, 8:06pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-parallelize-inference-on-a-quantized-model%2F108499 "2024-09-24T20:06:17Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [September 24, 2024, 10:04pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-parallelize-inference-on-a-quantized-model%2F108499%2F2 "2024-09-24T22:04:10Z")

</div>

Offloading to CPU may or may not be possible depending on the type of quantization library, but it seems to be possible for multi-GPU use, but I’m not sure if just specifying device\_map with the accelerate library will work.  
If it’s still unsupported or buggy, I guess it would be like piecing together the following information to deal with it…

> **[Bitsandbytes](https://huggingface.co/docs/transformers/main/quantization/bitsandbytes)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

> **[Accelerated inference on NVIDIA GPUs](https://huggingface.co/docs/optimum-onnx/onnxruntime/usage_guides/gpu)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

> **[Parallelism methods](https://huggingface.co/docs/transformers/perf_train_gpu_many)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

> **[Quantization-Aware Training for Large Language Models with PyTorch – PyTorch](https://pytorch.org/blog/quantization-aware-training/)**

But well, I don’t know how people have multiple GPUs and such.  
I’ve seen at least two people on the forum complain that **load balancing to multiple GPUs doesn’t work properly** , so you’re on the hook for that. That might be a bug.

> [@CUDA Memory issue for model.generate() in AutoModelForCausalLM](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcuda-memory-issue-for-model-generate-in-automodelforcausallm%2F74216%2F1)%3A
>
> Hello everyone, I have 4 A100 GPUs and I’m utilizing Mixtral with dtype set as bfloat16 for a text generation task on these GPUs. I’m aware that by using device\_map="balanced\_low\_0", I can distribute the model across GPUs 1, 2, and 3, while leaving GPU 0 available for the model.generate() function, as detailed in the documentation here: [[Handling big models for inference](https://huggingface.co/docs/accelerate/en/concept_guides/big_model_inference)]. The Mixtral model with bfloat16 type occupies approximately 90 GB, which is loaded onto GPUs 1, 2, and partially on GPU 3.…

---

_[View the full topic](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-parallelize-inference-on-a-quantized-model%2F108499)._
