fix: convert FP8 to bf16 for PEFT compatibility

This commit is contained in:
Christian Medina
2026-07-01 07:30:10 -04:00
parent 6f631f00ae
commit 86b401c12f

View File

@@ -32,15 +32,15 @@ def train(config_path):
print(f"Loading model: {config['base_model']}") print(f"Loading model: {config['base_model']}")
# Load bf16 model # Load model and convert to bf16 (ignore FP8 quantization)
print(f"Loading model: {config['base_model']}") print(f"Loading model: {config['base_model']}")
model = AutoModelForCausalLM.from_pretrained( model = AutoModelForCausalLM.from_pretrained(
config["base_model"], config["base_model"],
torch_dtype=torch.bfloat16, torch_dtype=torch.bfloat16, # Convert FP8 -> bf16
device_map="cpu", # Load to CPU first device_map="cpu", # Load to CPU first
trust_remote_code=True, trust_remote_code=True,
) )
print("Model loaded.") print("Model loaded and converted to bf16.")
# Add LoRA # Add LoRA
lora_config = LoraConfig( lora_config = LoraConfig(