Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
db017fd
Minor tweaks to support Megatron 2.4 + DS 3D
Jun 6, 2021
407ff0f
pipe partitioning
Jun 6, 2021
8e48756
unit test for bugfix #1135 (#1148)
Jun 9, 2021
71ecf7e
Add Windows support in README, use c++17 on Windows to support lates…
eltonzheng Jun 10, 2021
a096d32
re-enable grad buffer partitioning
Jun 11, 2021
9b4093b
Avoid partitioning small activations
tjruwase Jun 11, 2021
182be7b
Merge pull request #4 from ShadenSmith/olruwase/partition_activation
tjruwase Jun 11, 2021
3e948df
send/recv
Jun 13, 2021
b6a2cb3
isend/irecv missing wait
Jun 13, 2021
6bb63b8
turn off async ops
Jun 14, 2021
8097690
Merge branch 'megatron2.4-3d-sendrecv' into megatron2.4-3d
Jun 14, 2021
aa16828
Fix bugs in the tutorial documentation (#1157)
hyunwoongko Jun 15, 2021
4eaf910
Samyamr/largest partitioned params calculation fix (#1150)
samyam Jun 16, 2021
fa7921e
[Doc] Fix steps_per_print description (#1163)
tjruwase Jun 16, 2021
da1fe2f
Remove hard torch dependency at install (#1166)
jeffra Jun 16, 2021
4c114a2
patch in ompi local rank if local_rank isn't set (#1164)
jeffra Jun 16, 2021
1ba3e8e
add assert to make sure zero isn't enabled with 1bit-* (#1169)
jeffra Jun 17, 2021
b1669c0
Avoid partitioning small activations (#1154)
tjruwase Jun 18, 2021
3b68984
remove torchvision dependency (#1178)
jeffra Jun 21, 2021
0982ecc
bump to 0.4.2
jeffra Jun 23, 2021
df8b1f8
zero_to_fp32: restore persistent buffers (#1146)
stas00 Jun 23, 2021
0c1802c
ZeRO 2+3 memory estimators (#965)
stas00 Jun 23, 2021
c0c4ebf
introduce debug utils (#1136)
stas00 Jun 23, 2021
429cbc8
Fix bugs about non-contiguous tensor broadcasting (#1168)
hyunwoongko Jun 24, 2021
bc019a5
undo noise (#1191)
stas00 Jun 26, 2021
bd9e953
less verbose load
Jun 26, 2021
a029239
clean up logging (#1190)
stas00 Jun 28, 2021
081ddb5
Merge branch 'master' into megatron2.4-3d
jeffra Jun 30, 2021
d26c258
added shaden's set_train_batch_size patches, plus formatting
jeffra Jul 13, 2021
9dbfdbd
Adds engine.was_step_applied() (#1251)
Jul 26, 2021
d6945de
Cleaning up tensor/pipe parallel accounting. (#1252)
Jul 26, 2021
f93e22b
Correctness fix PP+ZeRO for gradient accumulation + updates from mast…
jeffra Jul 30, 2021
e9b5dff
dont clear grads in stage 1 code path
jeffra Jul 31, 2021
4b35409
prevent none grads from being reduced
jeffra Jul 31, 2021
bc17042
fix empty grad zero tests
jeffra Aug 2, 2021
6b42882
Use mpu in DeepSpeedConfig() call (#1271)
tjruwase Aug 9, 2021
cce85b8
API for obtaining global gradient norm (#1292)
tjruwase Aug 9, 2021
e65e511
turn excessive noise off (#1293)
stas00 Aug 11, 2021
db2f8a0
[zero] restore fp16 params if no zero ckpts available (#1322)
jeffra Aug 25, 2021
72ce55a
Fix PP checkpoint bloat (#1324)
tjruwase Aug 25, 2021
c7f3bc5
update for cuda-11.4 (#1329)
stas00 Aug 30, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ If you would like to pre-install any of the DeepSpeed extensions/ops (instead
of JIT compiling) or install pre-compiled ops via PyPI please see our [advanced
installation instructions](https://www.deepspeed.ai/tutorials/advanced-install/).

On Windows you can build wheel with following steps, currently only inference mode is supported.
1. Install pytorch, such as pytorch 1.8 + cuda 11.1
2. Install visual cpp build tools, such as VS2019 C++ x64/x86 build tools
3. Launch cmd console with Administrator privilege for creating required symlink folders
4. Run `python setup.py bdist_wheel` to build wheel in `dist` folder

# Features
Below we provide a brief feature list, see our detailed [feature
overview](https://www.deepspeed.ai/features/) for descriptions and usage.
Expand Down
45 changes: 20 additions & 25 deletions csrc/adam/cpu_adam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,42 +322,37 @@ int create_adam_optimizer(int optimizer_id,
float betta2 = 0.999,
float eps = 1e-8,
float weight_decay = 0,
bool adamw_mode = true)
bool adamw_mode = true,
bool should_log = false)
{
auto opt =
std::make_shared<Adam_Optimizer>(alpha, betta1, betta2, eps, weight_decay, adamw_mode);

s_optimizers[optimizer_id] = opt;

if (should_log) {
std::string avx_type = "";
#if defined(__AVX512__)
std::cout << "Adam Optimizer #" << optimizer_id
<< " is created with AVX512 arithmetic capability." << std::endl;
printf("Config: alpha=%f, betas=(%f, %f), weight_decay=%f, adam_w=%d\n",
alpha,
betta1,
betta2,
weight_decay,
(int)adamw_mode);
avx_type = "AVX512";
#else
#if defined(__AVX256__)
std::cout << "Adam Optimizer #" << optimizer_id
<< " is created with AVX2 arithmetic capability." << std::endl;
printf("Config: alpha=%f, betas=(%f, %f), weight_decay=%f, adam_w=%d\n",
alpha,
betta1,
betta2,
weight_decay,
(int)adamw_mode);
avx_type = "AVX2";
#else
std::cout << "Adam Optimizer #" << optimizer_id
<< " is created with scalar arithmetic capability." << std::endl;
printf("Config: alpha=%f, betas=(%f, %f), weight_decay=%f, adam_w=%d\n",
alpha,
betta1,
betta2,
weight_decay,
(int)adamw_mode);
avx_type = "scalar";
#endif
#endif

printf("Adam Optimizer #%d is created with %s arithmetic capability.\n",
optimizer_id,
avx_type.c_str());
printf("Config: alpha=%f, betas=(%f, %f), weight_decay=%f, adam_w=%d\n",
alpha,
betta1,
betta2,
weight_decay,
(int)adamw_mode);
}

return 0;
}

Expand Down
8 changes: 8 additions & 0 deletions deepspeed/inference/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,16 @@ def _pre_forward_hook(self, module, *inputs, **kwargs):
if torch.is_tensor(input):
input = input.to(torch.cuda.current_device())
if self.mp_world_size > 1:
if not input.is_contiguous():
input = input.contiguous()
dist.broadcast(input, 0)

for k in kwargs:
if torch.is_tensor(kwargs[k]):
kwargs[k] = kwargs[k].to(torch.cuda.current_device())
if self.mp_world_size > 1:
if not kwargs[k].is_contiguous():
kwargs[k] = kwargs[k].contiguous()
dist.broadcast(kwargs[k], 0)

def forward(self, *inputs, **kwargs):
Expand All @@ -210,12 +214,16 @@ def forward(self, *inputs, **kwargs):
if torch.is_tensor(input):
input = input.to(torch.cuda.current_device())
if self.mp_world_size > 1:
if not input.is_contiguous():
input = input.contiguous()
dist.broadcast(input, 0)

for k in kwargs:
if torch.is_tensor(kwargs[k]):
kwargs[k] = kwargs[k].to(torch.cuda.current_device())
if self.mp_world_size > 1:
if not kwargs[k].is_contiguous():
kwargs[k] = kwargs[k].contiguous()
dist.broadcast(kwargs[k], 0)

return self.model_orig_fwd(*inputs, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion deepspeed/module_inject/replace_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def attention(self):

def get_hidden_heads(self):
"""
retun hidden_size and number of heads
return hidden_size and number of heads
"""
raise NotImplementedError

Expand Down
4 changes: 3 additions & 1 deletion deepspeed/ops/adam/cpu_adam.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import time
from pathlib import Path
from ..op_builder import CPUAdamBuilder
from deepspeed.utils.logging import should_log_le


class DeepSpeedCPUAdam(torch.optim.Optimizer):
Expand Down Expand Up @@ -83,7 +84,8 @@ def __init__(self,
betas[1],
eps,
weight_decay,
adamw_mode)
adamw_mode,
should_log_le("info"))

def __del__(self):
# need to destroy the C++ object explicitly to avoid a memory leak when deepspeed.initialize
Expand Down
22 changes: 15 additions & 7 deletions deepspeed/runtime/activation_checkpointing/checkpointing.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

from deepspeed.runtime.config import DeepSpeedConfig
from deepspeed.utils import logger
from deepspeed.runtime.utils import move_to_device, see_memory_usage
from deepspeed.runtime.utils import move_to_device, see_memory_usage, bwc_tensor_model_parallel_rank
from deepspeed.utils.timer import SynchronizedWallClockTimer as Timers

# DeepSpeed Checkpointing Enabled or Disabled
Expand Down Expand Up @@ -213,9 +213,12 @@ def model_parallel_cuda_manual_seed(seed):
model parallel regions.
"""
global mpu

tp_rank = bwc_tensor_model_parallel_rank(mpu)

# 2718 is just for fun and any POSITIVE value will work.
offset = seed + 2718
model_parallel_seed = offset + mpu.get_model_parallel_rank()
model_parallel_seed = offset + tp_rank
# Data parallel gets the original sedd.
data_parallel_seed = seed

Expand All @@ -225,7 +228,7 @@ def model_parallel_cuda_manual_seed(seed):
'model parallel rank {}, and data parallel rank {} with '
'model parallel seed: {} and data parallel seed: {}'.format(
torch.distributed.get_rank(),
mpu.get_model_parallel_rank(),
tp_rank,
mpu.get_data_parallel_rank(),
model_parallel_seed,
data_parallel_seed),
Expand Down Expand Up @@ -384,9 +387,14 @@ def save_args_for_backward(*all_args):
global data_offsets, size_offsets
if mp_rank is None:
if mpu is not None:
mp_rank = mpu.get_model_parallel_rank()
mp_size = mpu.get_model_parallel_world_size()
mp_group = mpu.get_model_parallel_group()
if hasattr(mpu, 'get_tensor_model_parallel_rank'):
mp_rank = mpu.get_tensor_model_parallel_rank()
mp_size = mpu.get_tensor_model_parallel_world_size()
mp_group = mpu.get_tensor_model_parallel_group()
else:
mp_rank = mpu.get_model_parallel_rank()
mp_size = mpu.get_model_parallel_world_size()
mp_group = mpu.get_model_parallel_group()
else:
mp_rank = 0
mp_size = 1
Expand Down Expand Up @@ -416,7 +424,7 @@ def save_args_for_backward(*all_args):

inputs = []
for i, item in enumerate(args[:-1]):
if not torch.is_tensor(item):
if not torch.is_tensor(item) or mp_size > item.numel():
inputs.append(item)
continue

Expand Down
Loading