Skip to content

Commit

Permalink
[fix] quantization properties for lmi dist and hf acc (#1318)
Browse files Browse the repository at this point in the history
Co-authored-by: Somasundaram <sindhuvahini.s@gmail.com>
  • Loading branch information
sindhuvahinis and sindhuvahini-s committed Nov 15, 2023
1 parent 60f5519 commit f0ea80b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,13 @@ def construct_kwargs_quantize(cls, properties):
if "device_map" not in kwargs:
raise ValueError(
"device_map should be set when load_in_8bit is set")
kwargs["load_in_8bit"] = properties['load_in_8bit']
properties['quantize'] = HFQuantizeMethods.bitsandbytes8
kwargs["load_in_8bit"] = True
if properties[
'quantize'].value == HFQuantizeMethods.bitsandbytes4.value:
if "device_map" not in kwargs:
raise ValueError(
"device_map should set when load_in_4bit is set")
kwargs["load_in_4bit"] = properties['load_in_4bit']
properties['quantize'] = HFQuantizeMethods.bitsandbytes4
kwargs["load_in_4bit"] = True

properties['kwargs'] = kwargs
return properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import torch

QUANTIZATION_SUPPORT_ALGO = ["bitsandbytes", "gptq"]
QUANTIZATION_SUPPORT_ALGO = ["bitsandbytes8", "bitsandbytes", "gptq"]


class LmiDistRollingBatch(RollingBatch):
Expand Down Expand Up @@ -58,15 +58,17 @@ def _init_model(self, kwargs, model_id_or_path):
revision = self.properties.get('revision', None)
paged_attention = self.properties.get("paged_attention",
"true").lower() == "true"
if quantize is not None and dtype is not None:
raise ValueError(
f"Can't set both dtype: {dtype} and quantize: {quantize}")
if quantize is not None and quantize not in QUANTIZATION_SUPPORT_ALGO:
raise ValueError(
f"Invalid value for quantize: {quantize}. Valid values when using option rolling_batch=lmi-dist are: {QUANTIZATION_SUPPORT_ALGO}"
)
if quantize is not None:
os.environ["CUDA_MEMORY_FRACTION"] = "0.9"
if dtype is not None:
raise ValueError(
f"Can't set both dtype: {dtype} and quantize: {quantize}")
if quantize not in QUANTIZATION_SUPPORT_ALGO:
raise ValueError(
f"Invalid value for quantize: {quantize}. Valid values when using option rolling_batch=lmi-dist are: {QUANTIZATION_SUPPORT_ALGO}"
)
if quantize == "bitsandbytes8":
quantize = "bitsandbytes"
if quantize is None and dtype == "int8":
quantize = "bitsandbytes"
from lmi_dist.models import get_model
Expand Down

0 comments on commit f0ea80b

Please sign in to comment.