Incluso con QLoRA, es posible el agotamiento de memoria en Colab. Estrategias:
per_device_train_batch_sizeComienza con 1 o 2. Compensa con gradient_accumulation_steps.
max_seq_lengthReduce de 512 a 256 o 384 si el contenido lo permite.
torch.compile (experimental)model = torch.compile(model)
Puede acelerar el entrenamiento y reducir la memoria, pero no siempre es estable.
torch.cuda.empty_cache()
Útil después de cargar el modelo o entre experimentos.
CUDA out of memorygradient_accumulation_steps.max_seq_length.Some weights of the model checkpoint ... were not usedNormal si se carga con trust_remote_code=True o se usa PEFT. No es crítico.
ValueError: Attempting to unscale FP16 gradients.Usa optim="adamw_bnb_8bit" o optim="paged_adamw_8bit" en TrainingArguments.
The model is not in eval modeIgnorar. Trainer maneja el modo automáticamente.