# %% Cell 5: Attach LoRA Adapter
model = FastLanguageModel.get_peft_model(
    model,
    r=LORA_R,
    lora_alpha=LORA_ALPHA,
    lora_dropout=0,
    bias="none",
    use_gradient_checkpointing="unsloth",
    random_state=3407,
    target_modules=[
        "q_proj", "k_proj", "v_proj", "o_proj",
        "gate_proj", "up_proj", "down_proj",
    ],
)

model.print_trainable_parameters()

gc.collect()
torch.cuda.empty_cache()
print(f"VRAM after LoRA: {torch.cuda.memory_allocated() / 1024**3:.1f} GB")
print("\n→ Run Cell 6 to set training arguments.")
