sft_qat / config.py
starcrow's picture
Upload folder using huggingface_hub
458260e verified
Raw History Blame Contribute Delete
2.12 kB
"""JSONL SFT + QAT-LoRA ํ•™์Šต ์„ค์ •."""
from dataclasses import dataclass, field
@dataclass
class PathConfig:
base_model: str = r"/workspace/model"
dataset_path: str = "./data/train.jsonl"
output_dir: str = "./output_sft_qat"
log_file: str = "./logs/train_sft_qat.log"
checkpoint_dir: str = "./output_sft_qat"
@dataclass
class DataConfig:
# auto: messages, instruction/output, prompt/completion ์„ ํ–‰๋ณ„๋กœ ์ž๋™ ๊ฐ์ง€
format: str = "auto"
@dataclass
class LoraConfig:
r: int = 64
lora_alpha: int = 128
lora_dropout: float = 0.05
target_modules: list = field(default_factory=lambda: [
"q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"
])
bias: str = "none"
task_type: str = "CAUSAL_LM"
@dataclass
class QATConfig:
enabled: bool = True
block_size: int = 32
quant_warmup_steps: int = 0
target_modules: list | None = None
@dataclass
class TrainingConfig:
max_seq_length: int = 4063
seed: int = 42
per_device_train_batch_size: int = 1
gradient_accumulation_steps: int = 8
num_train_epochs: int = 1
max_steps: int = -1
learning_rate: float = 2e-4
lr_scheduler_type: str = "cosine"
warmup_ratio: float = 0.05
weight_decay: float = 0.01
optim: str = "paged_adamw_8bit"
bf16: bool = True
fp16: bool = False
tf32: bool = True
logging_steps: int = 10
save_steps: int = 200
save_total_limit: int = 3
report_to: str = "none"
dataloader_num_workers: int = 0
gradient_checkpointing: bool = True
ddp_find_unused_parameters: bool = False
@dataclass
class SFTConfig:
paths: PathConfig = field(default_factory=PathConfig)
data: DataConfig = field(default_factory=DataConfig)
lora: LoraConfig = field(default_factory=LoraConfig)
training: TrainingConfig = field(default_factory=TrainingConfig)
qat: QATConfig = field(default_factory=QATConfig)
def __post_init__(self):
if self.qat.target_modules is None:
self.qat.target_modules = self.lora.target_modules
DEFAULT_CONFIG = SFTConfig()