fix: use BitsAndBytes INT4 for PEFT compatibility
This commit is contained in:
@@ -32,15 +32,17 @@ def train(config_path):
|
|||||||
|
|
||||||
print(f"Loading model: {config['base_model']}")
|
print(f"Loading model: {config['base_model']}")
|
||||||
|
|
||||||
# Load model - preserve NVFP4 quantization
|
# Load model with BitsAndBytes INT4 (PEFT supports this)
|
||||||
print(f"Loading model: {config['base_model']}")
|
print(f"Loading model: {config['base_model']}")
|
||||||
|
from transformers import BitsAndBytesConfig
|
||||||
|
|
||||||
model = AutoModelForCausalLM.from_pretrained(
|
model = AutoModelForCausalLM.from_pretrained(
|
||||||
config["base_model"],
|
config["base_model"],
|
||||||
torch_dtype=torch.float16, # Keep NVFP4 quantized
|
quantization_config=BitsAndBytesConfig(load_in_4bit=True),
|
||||||
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 to CPU.")
|
print("Model loaded with INT4 quantization.")
|
||||||
|
|
||||||
# Add LoRA
|
# Add LoRA
|
||||||
lora_config = LoraConfig(
|
lora_config = LoraConfig(
|
||||||
|
|||||||
Reference in New Issue
Block a user