mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-09-10 13:30:19 +00:00
[misc] refactor launch API and tensor constructor (#5666)
* [misc] remove config arg from initialize * [misc] remove old tensor contrusctor * [plugin] add npu support for ddp * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [devops] fix doc test ci * [test] fix test launch * [doc] update launch doc --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -45,7 +45,7 @@ We then need to initialize distributed environment. For demo purpose, we uses `l
|
||||
parser = colossalai.get_default_parser()
|
||||
args = parser.parse_args()
|
||||
# launch from torch
|
||||
colossalai.launch_from_torch(config=dict())
|
||||
colossalai.launch_from_torch()
|
||||
```
|
||||
|
||||
### Step 3. Create training components
|
||||
|
@@ -61,7 +61,7 @@ We then need to initialize distributed environment. For demo purpose, we uses `l
|
||||
for other initialization methods.
|
||||
|
||||
```python
|
||||
colossalai.launch_from_torch(config=dict())
|
||||
colossalai.launch_from_torch()
|
||||
logger = get_dist_logger()
|
||||
```
|
||||
|
||||
|
@@ -29,7 +29,7 @@ from colossalai.booster.plugin import GeminiPlugin
|
||||
|
||||
from transformers import LlamaForCausalLM, LlamaConfig, BertForPreTraining
|
||||
|
||||
colossalai.launch({})
|
||||
colossalai.launch()
|
||||
plugin = GeminiPlugin()
|
||||
booster = Booster(plugin)
|
||||
|
||||
|
@@ -20,10 +20,10 @@ In Colossal-AI, we have incorporated different implementations of mixed precisio
|
||||
3. naive amp
|
||||
|
||||
| Colossal-AI | support tensor parallel | support pipeline parallel | fp16 extent |
|
||||
| -------------- | ----------------------- | ------------------------- | ---------------------------------------------------------------------------------------------------- |
|
||||
| AMP_TYPE.TORCH | ✅ | ❌ | Model parameters, activation, gradients are downcast to fp16 during forward and backward propagation |
|
||||
| AMP_TYPE.APEX | ❌ | ❌ | More fine-grained, we can choose opt_level O0, O1, O2, O3 |
|
||||
| AMP_TYPE.NAIVE | ✅ | ✅ | Model parameters, forward and backward operations are all downcast to fp16 |
|
||||
|----------------|-------------------------|---------------------------|------------------------------------------------------------------------------------------------------|
|
||||
| AMP_TYPE.TORCH | ✅ | ❌ | Model parameters, activation, gradients are downcast to fp16 during forward and backward propagation |
|
||||
| AMP_TYPE.APEX | ❌ | ❌ | More fine-grained, we can choose opt_level O0, O1, O2, O3 |
|
||||
| AMP_TYPE.NAIVE | ✅ | ✅ | Model parameters, forward and backward operations are all downcast to fp16 |
|
||||
|
||||
The first two rely on the original implementation of PyTorch (version 1.6 and above) and NVIDIA Apex.
|
||||
The last method is similar to Apex O2 level.
|
||||
@@ -164,7 +164,7 @@ parser = colossalai.get_default_parser()
|
||||
args = parser.parse_args()
|
||||
|
||||
# launch from torch
|
||||
colossalai.launch_from_torch(config=dict())
|
||||
colossalai.launch_from_torch()
|
||||
|
||||
```
|
||||
|
||||
|
@@ -185,7 +185,7 @@ Then we can train GPT model with Gemini. The placement policy of Gemini should b
|
||||
|
||||
```python
|
||||
def train_gemini_cpu(nvme_offload_fraction: float = 0.0):
|
||||
colossalai.launch_from_torch({})
|
||||
colossalai.launch_from_torch()
|
||||
config = GPT2Config()
|
||||
with ColoInitContext(device=torch.cuda.current_device()):
|
||||
model = GPT2LMHeadModel(config)
|
||||
|
@@ -174,7 +174,7 @@ def main():
|
||||
SEQ_LEN = 1024
|
||||
VOCAB_SIZE = 50257
|
||||
NUM_STEPS = 10
|
||||
colossalai.launch_from_torch(config={})
|
||||
colossalai.launch_from_torch()
|
||||
|
||||
# build criterion
|
||||
criterion = GPTLMLoss()
|
||||
|
Reference in New Issue
Block a user