You can log validation perplexity during QLoRA training by computing exponentiated loss in the validation_step and logging it with PyTorch Lightning. Here is the code snippet you can refer to:

In the above code we are using the following key strategies:
-
Adds validation_step with loss and perplexity calculation.
-
Uses torch.exp(loss) for perplexity.
-
Logs metrics with prog_bar=True for live updates in Lightning.
Hence, integrating perplexity logging in QLoRA with Lightning enables real-time monitoring of model generalization during training.