Skip to content

Commit

Permalink
fix low_cpu_mem intro by 4.45
Browse files Browse the repository at this point in the history
Signed-off-by: Yu Chin Fabian Lim <[email protected]>
  • Loading branch information
fabianlim committed Sep 26, 2024
1 parent 978d48b commit 0258544
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from fms_acceleration import AccelerationPlugin
from peft import LoraConfig, get_peft_model
from transformers import AutoModelForCausalLM, BitsAndBytesConfig, TrainingArguments
from transformers.utils.import_utils import _is_package_available
import torch


Expand Down Expand Up @@ -120,6 +121,24 @@ def model_loader(self, model_name: str, **kwargs):
and os.environ.get("ACCELERATE_USE_FSDP", "false").lower() == "true"
):
config_kwargs["bnb_4bit_quant_storage"] = torch_dtype

_, _transformers_version = _is_package_available("transformers", return_version=True)

if _transformers_version >= "4.45":
from fms_acceleration.model_patcher import patch_target_module

def _truthy():
return True

patch_target_module(
"transformers.modeling_utils.is_local_dist_rank_0",
_truthy,
)
warnings.warn(
"Disabling low_cpu_mem_mode as this will cause problems with "
"the fused-ops-and-kernels package"
)

elif world_size > 1:
warnings.warn(
"Running in distributed mode but bnb_4bit_quant_storage is not set. "
Expand Down

0 comments on commit 0258544

Please sign in to comment.