# ==========================================
# CELL 8: START TRAINING (THE LONG ONE)
# ==========================================
# Run this AFTER cell_07. This takes 4-6 hours on A4000.

print("=" * 60)
print("STARTING TRAINING")
print("=" * 60)
print(f"  Conversations : {len(dataset):,}")
print(f"  Epochs        : {EPOCHS}")
print(f"  Batch size    : {BATCH_SIZE} (effective: {BATCH_SIZE * GRAD_ACCUM})")
print(f"  Context       : {MAX_SEQ_LENGTH}")
print(f"  Learning rate : {LR} (cosine)")
print(f"  LoRA rank     : {LORA_R}")
print(f"  Expected time : ~{total_steps / 2.5 / 3600:.1f} hours on A4000")
print("=" * 60)

trainer.train()

print("\nTraining complete!")
print(f"Final loss: {trainer.state.log_history[-1].get('loss', 'N/A')}")
