# ==========================================
# CELL 7: INITIALIZE TRAINER
# ==========================================
# Run this AFTER cell_06

trainer = SFTTrainer(
    model=model,
    tokenizer=tokenizer,
    train_dataset=dataset,
    dataset_text_field="text",
    max_seq_length=MAX_SEQ_LENGTH,
    args=training_args,
    packing=False,  # NEVER pack for instruction/chat data (breaks boundaries)
)

print("Trainer initialized successfully.")
print(f"VRAM before training: {torch.cuda.memory_allocated() / 1024**3:.1f} GB")
print("\n>>> READY TO TRAIN. Run cell_08_train.py to start!")
