Model
This page will cover how to pass a model into the Trainer
. The model
is the main Module
that all training and validation is run on. It is required by all Trainer
instances.
Prerequisites
Make sure to have read through Trainer Overview and Trainer Configuration Overview which provide the basic overview of how to run Model Zoo models. In this document, you will be using the tools and configurations outlined in those pages.
Configure the Model
To set the model to train/validate using the Trainer
use the model
argument.
If passing the model
as a Module
directly, it is optimal to first initalize the model inside of the Cerebras device context.
For example:
This ensures that model parameters are automatically moved to the Cerebras device, optimizing memory usage and enhancing initialization speed. For more information, see Efficient weight initialization.
Conclusion
That covers specifying the model to train/validate with the Trainer
. You should now understand the various ways to configure the model and how the Trainer
accepts a model.
Further Reading
To learn more about how you can use the Trainer
in some core workflows, you can check out:
To learn more about how you can extend the capabilities of the Trainer
class, you can check out: