mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-09-10 05:20:33 +00:00
[misc] update pre-commit and run all files (#4752)
* [misc] update pre-commit * [misc] run pre-commit * [misc] remove useless configuration files * [misc] ignore cuda for clang-format
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import argparse
|
||||
import os
|
||||
import warnings
|
||||
from typing import Any, Callable, Dict, List, Tuple, Type, Union
|
||||
from typing import Any, Callable, Tuple, Type, Union
|
||||
|
||||
import torch
|
||||
import torch.distributed.rpc as rpc
|
||||
@@ -61,7 +61,7 @@ def get_batch_lengths(batch):
|
||||
|
||||
|
||||
def split_batch(batch: Any, start, stop, device: str):
|
||||
if device == 'cuda':
|
||||
if device == "cuda":
|
||||
fn = lambda x: x[start:stop].cuda()
|
||||
else:
|
||||
fn = lambda x: x[start:stop]
|
||||
@@ -102,8 +102,8 @@ def get_real_args_kwargs(args_or_kwargs):
|
||||
|
||||
|
||||
def run_worker(rank, args, master_func):
|
||||
os.environ['MASTER_ADDR'] = args.master_addr
|
||||
os.environ['MASTER_PORT'] = args.master_port
|
||||
os.environ["MASTER_ADDR"] = args.master_addr
|
||||
os.environ["MASTER_PORT"] = args.master_port
|
||||
|
||||
device = args.device
|
||||
world_size = args.world_size
|
||||
@@ -112,15 +112,17 @@ def run_worker(rank, args, master_func):
|
||||
num_worker_threads = args.num_worker_threads
|
||||
host = args.master_addr
|
||||
port = args.master_port
|
||||
backend = 'nccl' if device == 'cuda' else 'gloo'
|
||||
backend = "nccl" if device == "cuda" else "gloo"
|
||||
|
||||
launch(dict(), rank, world_size, host, int(port), backend, verbose=False)
|
||||
ppg.set_global_info(rank=rank,
|
||||
world_size=world_size,
|
||||
dp_degree=dp_degree,
|
||||
tp_degree=tp_degree,
|
||||
num_worker_threads=num_worker_threads,
|
||||
device=device)
|
||||
ppg.set_global_info(
|
||||
rank=rank,
|
||||
world_size=world_size,
|
||||
dp_degree=dp_degree,
|
||||
tp_degree=tp_degree,
|
||||
num_worker_threads=num_worker_threads,
|
||||
device=device,
|
||||
)
|
||||
ppg.args = args
|
||||
# in rpc mode, only rank 0 is needed to be coded
|
||||
if rank == 0:
|
||||
@@ -139,17 +141,17 @@ def rpc_run(args, master_func):
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--epoch', type=int, default=1)
|
||||
parser.add_argument('--world_size', type=int, default=2)
|
||||
parser.add_argument('--batch_size', type=int, default=16)
|
||||
parser.add_argument('--dp_degree', type=int, default=1)
|
||||
parser.add_argument('--tp_degree', type=int, default=1)
|
||||
parser.add_argument('--num_microbatches', type=int, default=2)
|
||||
parser.add_argument('--chunk', type=int, default=1)
|
||||
parser.add_argument('--use_checkpoint', action='store_true')
|
||||
parser.add_argument('--optimizer', type=str, choices=['SGD', 'Adam', 'RMSprop'], default='SGD')
|
||||
parser.add_argument('--device', type=str, choices=['cpu', 'cuda'], default='cuda')
|
||||
parser.add_argument('--master_addr', type=str, default='localhost')
|
||||
parser.add_argument('--master_port', type=str, default='29020')
|
||||
parser.add_argument('--num_worker_threads', type=int, default=128)
|
||||
parser.add_argument("--epoch", type=int, default=1)
|
||||
parser.add_argument("--world_size", type=int, default=2)
|
||||
parser.add_argument("--batch_size", type=int, default=16)
|
||||
parser.add_argument("--dp_degree", type=int, default=1)
|
||||
parser.add_argument("--tp_degree", type=int, default=1)
|
||||
parser.add_argument("--num_microbatches", type=int, default=2)
|
||||
parser.add_argument("--chunk", type=int, default=1)
|
||||
parser.add_argument("--use_checkpoint", action="store_true")
|
||||
parser.add_argument("--optimizer", type=str, choices=["SGD", "Adam", "RMSprop"], default="SGD")
|
||||
parser.add_argument("--device", type=str, choices=["cpu", "cuda"], default="cuda")
|
||||
parser.add_argument("--master_addr", type=str, default="localhost")
|
||||
parser.add_argument("--master_port", type=str, default="29020")
|
||||
parser.add_argument("--num_worker_threads", type=int, default=128)
|
||||
return parser.parse_args()
|
||||
|
Reference in New Issue
Block a user