Porting PyTorch Models to Gaudi
Porting PyTorch Models to Gaudi¶
This section details the steps required to prepare PyTorch models to run on Gaudi. To create and execute a simple PyTorch model with Gaudi, see Getting Started with PyTorch and Gaudi.
Import Habana Torch Library:
import habana_frameworks.torch.core as htcore
Target the Gaudi HPU device:
device = torch.device("hpu")
mark_step(). In Lazy mode,
mark_step()must be added in all training scripts right after
mark_step()at any arbitrary point in the code is currently not supported.
Migrating BERT-like models to run on Gaudi when module weights are shared among two or more layers requires these weights to be shared after moving the model to the HPU device. For more details, refer to Weight Sharing.