mirror of https://github.com/hpcaitech/ColossalAI
[quant] fix bitsandbytes version check (#5882)
* [quant] fix bitsandbytes version check * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>pull/5891/head
parent
6cd4c32be4
commit
7afbc81d62
|
@ -1,17 +1,25 @@
|
||||||
# adapted from Hugging Face accelerate/utils/bnb.py accelerate/utils/modeling.py
|
# adapted from Hugging Face accelerate/utils/bnb.py accelerate/utils/modeling.py
|
||||||
|
|
||||||
|
import importlib.metadata
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
|
from packaging.version import Version
|
||||||
|
|
||||||
from .bnb_config import BnbQuantizationConfig
|
from .bnb_config import BnbQuantizationConfig
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import bitsandbytes as bnb
|
import bitsandbytes as bnb
|
||||||
|
|
||||||
IS_4BIT_BNB_AVAILABLE = bnb.__version__ >= "0.39.0"
|
try:
|
||||||
IS_8BIT_BNB_AVAILABLE = bnb.__version__ >= "0.37.2"
|
# in case lower version of bitsandbytes does not have __version__ attribute
|
||||||
|
BNB_VERSION = Version(bnb.__version__)
|
||||||
|
except AttributeError:
|
||||||
|
BNB_VERSION = Version(importlib.metadata.version("bitsandbytes"))
|
||||||
|
|
||||||
|
IS_4BIT_BNB_AVAILABLE = BNB_VERSION >= Version("0.39.0")
|
||||||
|
IS_8BIT_BNB_AVAILABLE = BNB_VERSION >= Version("0.37.2")
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue