Trainer — PyTorch Lightning 2.4.0 documentation
Once you’ve organized your PyTorch code into a LightningModule, the Trainer automates everything else. The Trainer achieves the following: You maintain control over all aspects via PyTorch code in your LightningModule. The trainer uses best practices embedded by contributors and users from top AI labs such as Facebook AI Research, NYU, MIT, Stanford, etc… The trainer allows disabling any key part that you don’t want automated. This is the basic use of the trainer: The Lightning Trainer does much more than just “training”. Under the hood, it handles all loop details for you, some examples include: Automatically enabling/disabling grads Running the training, validation and test dataloaders Calling the Callbacks at the appropriate times Putting batches and computations on the correct devices Here’s the pseudocode for what the trainer does under the hood (showing the train loop only) In Python scripts, it’s recommended you use a main function to call the Trainer. So you can run it like so:
Trainer ¶ Once you’ve organized your PyTorch code into a LightningModule , the Trainer automates everything else. The Trainer achieves the following: You maintain control over all aspects via PyTorch code in your LightningModule . The trainer uses best practices embedded by contributors and users from top AI labs such as Facebook AI Research, NYU, MIT, Stanford, etc… The trainer allows disabling any key part that you don’t want automated. Basic use ¶ This is the basic use of the trainer: model = MyLightningModule () trainer = Trainer () trainer . fit ( model , train_dataloader , val_dataloader
Explore this link on the map →related reading
- LightningModule - PyTorch Lightning 2.6.1 documentationlightning.ai
- Customize checkpointing behavior (intermediate) - PyTorch Lightning 2.6.1 documentationlightning.ai
- ⚡ Migrating from PTL - Composerdocs.mosaicml.com
- Get Started with Distributed Training using PyTorch Lightning — Ray 2.56.0docs.ray.io
- Optimization - PyTorch Lightning 2.6.1 documentationlightning.ai
- Saving and loading checkpoints (basic) - PyTorch Lightning 2.6.1 documentationlightning.ai
- ModelCheckpoint - PyTorch Lightning 2.6.1 documentationlightning.ai
- Composer2.pdfcursor.com
- Fine-tuning a model with the Trainer API · Hugging Facehuggingface.co
- frontier model training methodologies | Alex Wa's Blogdjdumpling.github.io
- 👨👩👧👦 Distributed Training - Composerdocs.mosaicml.com
- Efficient LLM Finetuning with Unsloth | Modal Docsmodal.com