You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/tutorials/basics/Distributed_Configuration.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -45,7 +45,7 @@ from .common.train import train
45
45
train.dist.pipeline_parallel_size =8
46
46
```
47
47
48
-
**Note:** For models which have been configured with pipeline parallelism(e.g., BERT, GPT-2, T5 and ViT), you can simply update the distributed config to execute pipeline parallel training on them. If you need to train your own model with pipeline parallel strategy, please refer to [Write Models]() for more details about configuring your own model with pipeline parallelism.
48
+
**Note:** For models which have been configured with pipeline parallelism(e.g., BERT, GPT-2, T5 and ViT), you can simply update the distributed config to execute pipeline parallel training on them. If you need to train your own model with pipeline parallel strategy, please refer to [Write Models](https://libai.readthedocs.io/en/latest/tutorials/basics/Write_Models.html) for more details about configuring your own model with pipeline parallelism.
49
49
50
50
#### **Data Parallel + Tensor Parallel for 2D Parallel Training on 8 GPUs**
In this section, we will introduce how to implement a new model entirely from scratch and make it compatible with LiBai.
4
+
5
+
6
+
## Construct Models in LiBai
7
+
8
+
LiBai uses [LazyConfig](https://libai.readthedocs.io/en/latest/tutorials/Config_System.html) for more flexible config system, which means you can simply import your own model in your config and train it under LiBai.
9
+
10
+
For image classification task, the input data is usually a batch of images and labels. The following code shows how to build a toy model for this task, import it in your code:
- For classification models, the ``forward`` function must have ``images`` and ``labels`` as arguments, which corresponds to the output in ``__getitem__`` of LiBai's built-in datasets, please refer to [imagenet.py](https://github.com/Oneflow-Inc/libai/blob/main/libai/data/datasets/imagenet.py) for more details about the dataset.
42
+
-**This toy model** will return ``losses`` during training and ``prediction_scores`` during inference, and both of them should be the type of ``dict``, which means you should implement the ``loss function`` in your model, like ``self.loss_func=nn.CrossEntropyLoss()`` as the ToyModel showing above.
43
+
44
+
45
+
## Import the model in config
46
+
47
+
With ``LazyConfig System``, you can simply import the model in your config file. The following code shows how to use ``ToyModel`` in your config file:
0 commit comments