Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/llama_cookbook/finetuning.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def main(**kwargs):
if not train_config.enable_fsdp or rank == 0:
wandb_run = setup_wandb(train_config, fsdp_config, **kwargs)

# setting quantization configs
# setting quantization configs
bnb_config = None
if train_config.quantization:
if type(train_config.quantization) == type(True):
Expand All @@ -135,6 +135,17 @@ def main(**kwargs):
update_config(quant_config, **kwargs)
bnb_config = quant_config.create_bnb_config(train_config.quantization)


if train_config.enable_fsdp:
if train_config.quantization == "4bit":
bnb_config.bnb_4bit_quant_storage = bnb_config.bnb_4bit_compute_dtype
from logging import getLogger
logger = getLogger()
logger.warning(
"FSDP and 4-bit QLoRA enabled. Setting `bnb_4bit_quant_storage` "
f"to {bnb_config.bnb_4bit_compute_dtype} for compatibility."
)

# Load the pre-trained model and setup its configuration
use_cache = False if train_config.enable_fsdp else None
config = AutoConfig.from_pretrained(train_config.model_name)
Expand Down Expand Up @@ -264,10 +275,9 @@ def main(**kwargs):
elif torch.cuda.is_available():
device_id = torch.cuda.current_device()

if train_config.freeze_LLM_only:
use_orig_params = True
else:
use_orig_params = False

use_orig_params = train_config.freeze_LLM_only or train_config.use_peft

model = FSDP(
model,
auto_wrap_policy=(
Expand Down
Loading