Skip to content

Commit

Permalink
osx training
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishekkrthakur committed Oct 5, 2023
1 parent b3890b8 commit c04f61f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/autotrain/trainers/clm/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,23 @@ def train(config):
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_use_double_quant=False,
)
config.fp16 = True
elif config.use_int8:
bnb_config = BitsAndBytesConfig(load_in_8bit=config.use_int8)
config.fp16 = True
else:
bnb_config = BitsAndBytesConfig()
bnb_config = None

model = AutoModelForCausalLM.from_pretrained(
config.model,
config=model_config,
token=config.token,
quantization_config=bnb_config,
torch_dtype=torch.float16,
torch_dtype=torch.float16 if config.fp16 else torch.float32,
device_map={"": Accelerator().process_index} if torch.cuda.is_available() else None,
trust_remote_code=True,
use_flash_attention_2=config.use_flash_attention_2,
)

else:
model = AutoModelForCausalLM.from_pretrained(
config.model,
Expand Down

0 comments on commit c04f61f

Please sign in to comment.