# ==========================================
# CELL 4: LOAD MODEL FROM LOCAL CACHE
# ==========================================
# Run this AFTER cell_03

model, tokenizer = FastLanguageModel.from_pretrained(
    model_name=MODEL_NAME,
    max_seq_length=MAX_SEQ_LENGTH,
    dtype=None,               # Auto-detect: bf16 on Ampere (A4000), fp16 on older
    load_in_4bit=True,        # QLoRA 4-bit weights (huge VRAM saver)
)

print(f"Model loaded successfully: {MODEL_NAME}")
print(f"VRAM used after model load: {torch.cuda.memory_allocated() / 1024**3:.1f} GB")

# Clear cache before next cell
gc.collect()
torch.cuda.empty_cache()
