fix: use CompressedTensors for Ornith, add torch import, expand LoRA targets
This commit is contained in:
@@ -5,11 +5,8 @@ base_model: deepreinforce-ai/Ornith-1.0-35B-FP8
|
|||||||
model_type: LlamaForCausalLM
|
model_type: LlamaForCausalLM
|
||||||
tokenizer_type: LlamaTokenizer
|
tokenizer_type: LlamaTokenizer
|
||||||
|
|
||||||
# Quantization (QLoRA)
|
# Model is already quantized (Ornith uses CompressedTensors)
|
||||||
load_in_4bit: true
|
# No need for BitsAndBytes configuration
|
||||||
bnb_4bit_compute_dtype: bfloat16
|
|
||||||
bnb_4bit_quant_type: nf4
|
|
||||||
use_nested_quant: false
|
|
||||||
|
|
||||||
# LoRA Configuration
|
# LoRA Configuration
|
||||||
lora_r: 16
|
lora_r: 16
|
||||||
@@ -20,6 +17,9 @@ target_modules:
|
|||||||
- v_proj
|
- v_proj
|
||||||
- k_proj
|
- k_proj
|
||||||
- o_proj
|
- o_proj
|
||||||
|
- gate_proj
|
||||||
|
- up_proj
|
||||||
|
- down_proj
|
||||||
lora_task_type: CAUSAL_LM
|
lora_task_type: CAUSAL_LM
|
||||||
|
|
||||||
# Dataset
|
# Dataset
|
||||||
|
|||||||
@@ -2,13 +2,16 @@
|
|||||||
"""
|
"""
|
||||||
Train LoRA adapter on Cyron summary dataset.
|
Train LoRA adapter on Cyron summary dataset.
|
||||||
|
|
||||||
Uses Hugging Face TRL for SFT training with QLoRA.
|
Uses Hugging Face TRL for SFT training.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import os
|
||||||
import yaml
|
import yaml
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
import torch
|
||||||
|
|
||||||
|
|
||||||
def train(config_path):
|
def train(config_path):
|
||||||
"""Train LoRA adapter using TRL."""
|
"""Train LoRA adapter using TRL."""
|
||||||
@@ -31,23 +34,13 @@ def train(config_path):
|
|||||||
|
|
||||||
print(f"Loading model: {config['base_model']}")
|
print(f"Loading model: {config['base_model']}")
|
||||||
|
|
||||||
# Load model with quantization
|
# Load model - let the model's own quantization config handle it
|
||||||
bnb_config = BitsAndBytesConfig(
|
# (Ornith uses CompressedTensors, not BitsAndBytes)
|
||||||
load_in_4bit=config.get("load_in_4bit", True),
|
|
||||||
bnb_4bit_compute_dtype=config.get("bnb_4bit_compute_dtype", "bfloat16"),
|
|
||||||
bnb_4bit_quant_type=config.get("bnb_4bit_quant_type", "nf4"),
|
|
||||||
use_nested_quant=config.get("use_nested_quant", False),
|
|
||||||
)
|
|
||||||
|
|
||||||
# Use all available GPUs
|
|
||||||
device_map = "auto" if torch.cuda.device_count() == 1 else "balanced"
|
|
||||||
|
|
||||||
model = AutoModelForCausalLM.from_pretrained(
|
model = AutoModelForCausalLM.from_pretrained(
|
||||||
config["base_model"],
|
config["base_model"],
|
||||||
quantization_config=bnb_config,
|
device_map="auto",
|
||||||
device_map=device_map,
|
torch_dtype=torch.bfloat16,
|
||||||
)
|
)
|
||||||
model = prepare_model_for_kbit_training(model)
|
|
||||||
|
|
||||||
# Add LoRA
|
# Add LoRA
|
||||||
lora_config = LoraConfig(
|
lora_config = LoraConfig(
|
||||||
|
|||||||
Reference in New Issue
Block a user