Skip to content
Open
Changes from 62 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
c9b12af
Reduced the experts allreduce number per layer to ONCE for the Qwen2-…
gyou2021 Jan 21, 2025
590ea36
Fixed format
gyou2021 Jan 21, 2025
889c275
Removed print
gyou2021 Jan 21, 2025
2ec6c34
Fix a bug about set.
gyou2021 Jan 21, 2025
504d696
Add the missing view operations from sequence parallel(async). (#6750)
inkcherry Jan 21, 2025
c266dc9
Update `torch.norm` to `torch.linalg.norm` and `torch.linalg.vector_n…
loadams Jan 21, 2025
ae12993
Using explicit GPU upcast for ZeRO-Offload (#6962)
xylian86 Jan 21, 2025
deb09a3
Update version.txt after 0.16.3 release (#6965)
loadams Jan 21, 2025
128d436
Precisely track nvme optimizer offload (#6963)
tjruwase Jan 23, 2025
864472b
Update build_win.bat script to exclue GDS op as it lacks Windows supp…
loadams Jan 24, 2025
1ac398c
Add CUDA 12.8 support and comment on CUDA 12.7 (#6975)
loadams Jan 28, 2025
eda53d8
Update torch versions to support 2.6 (#6977)
loadams Jan 29, 2025
112a7c6
generalize deepspeed linear and implement it for non cuda systems (#6…
oelayan7 Jan 29, 2025
7d2c5fe
Update recommended Windows whl building versions (#6983)
loadams Jan 30, 2025
f1d326c
Title: Fix setup_env_ranks to Properly Set Environment Variables Inst…
fabiosanger Jan 30, 2025
46545d7
Specify torchvision in nv-ds-chat workflow (prevents errors with torc…
loadams Jan 30, 2025
af1ba94
Remove assumption that padding only occurs on last rank (#6974)
xylian86 Jan 31, 2025
e235921
Use ds-specific module id to avoid conflicts (#6847)
tjruwase Jan 31, 2025
f5e9796
Update A6000 workflows to use newer docker container - 24.09 vs 24.03…
loadams Jan 31, 2025
07634b9
Allow NVIDIA Blackwell (#6991)
fabiendupont Feb 4, 2025
0e57fa0
Update GH org references (#6998)
tjruwase Feb 5, 2025
e86c0c3
Update CNAME
loadams Feb 5, 2025
0d7f0eb
Update CNAME
loadams Feb 5, 2025
cd8a988
[XPU] max1100 workflow update for docker and softwares (#7003)
Liangliang-Ma Feb 5, 2025
18c712f
autotp training(fix dco) (#7004)
inkcherry Feb 5, 2025
c5bf6f6
import triton files when triton is supported and installed (#6989)
oelayan7 Feb 6, 2025
590de5f
Update A6000 tests transformers version (#7016)
loadams Feb 8, 2025
693c39f
Fix ds-chat CI regression (#7015)
tjruwase Feb 10, 2025
322a05a
[Ulysses tutorial] typos (#7024)
stas00 Feb 11, 2025
8869d78
fix hostname -I for macOS #6497 (#6990)
fitzjalen Feb 12, 2025
e4d03af
Update workflows to cuda 12.4 (#7000)
loadams Feb 12, 2025
8c6251d
[ROCm] Enable fp_quantizer on ROCm (#7027)
rraminen Feb 13, 2025
e3e179c
add gds chinese blog (#7034)
GuanhuaWang Feb 13, 2025
fd2787b
Add chinese blog for deepspeed windows, and fix format (#7035)
hwchen2017 Feb 14, 2025
ba8ef57
AIO on ROCM (#7023)
jomayeri Feb 14, 2025
f4b0f58
Control trace cache warnings (#7039)
tjruwase Feb 18, 2025
3ca3e2f
Update CUDA compute capability to support Blackwell (#7047)
hwchen2017 Feb 18, 2025
5612778
Update setup.py handling of ROCm cupy (#7051)
loadams Feb 19, 2025
af8c190
nv-ds-chat breaks with latest transformers (#7052)
loadams Feb 19, 2025
225471a
Rename aio_thread_count to intra_op_parallelism (#7056)
tjruwase Feb 19, 2025
1df293a
add autoTP training zero2 tests (#7049)
inkcherry Feb 19, 2025
94abf68
Fix, bf16 optimizer remove dup loop (#7054)
wukong1992 Feb 20, 2025
4a4ff9b
Update version.txt after 0.16.4 release (#7063)
loadams Feb 20, 2025
e5eda47
fix an outdated doc wrt CUDA_VISIBLE_DEVICES (#7058)
stas00 Feb 20, 2025
675ec9a
Tecorigin sdaa accelerator (#6903)
siqi654321 Feb 20, 2025
81c1fee
Handle special case of libuv for Windows (#7064)
loadams Feb 20, 2025
17f544c
Update README with info on newest accelerator (#7065)
loadams Feb 21, 2025
20fd872
Bug Fix for offload_states API (#7050)
U-rara Feb 21, 2025
0b289a2
Fix TOCTOU issues, switch to fstat (#7067)
loadams Feb 24, 2025
4a86d02
config torch to avoid graph breaks caused by logger (#6999)
ShellyNR Feb 24, 2025
594b5bb
Fix meta load tensor imcompatible issue (#7073)
Yejing-Lai Feb 24, 2025
a843e39
Replace calls to `python setup.py sdist` with `python -m build --sdis…
loadams Feb 24, 2025
4cbc52c
Revert "Handle special case of libuv for Windows (#7064)" (#7076)
loadams Feb 25, 2025
586e436
Add DeepseekV3 AutoTP. (#7045)
Yejing-Lai Feb 26, 2025
5e379ad
Improve inference tutorial docs (#7083)
loadams Feb 26, 2025
13bf866
Added support for the environment variable DS_MOE_EXPERTS_REDUCE_ONCE…
gyou2021 Feb 27, 2025
d5115be
Changed env variable name to 'DS_MOE_TP_SINGLE_ALLREDUCE'
gyou2021 Feb 28, 2025
f0044cb
Pin transformers version on tests that use latest. (#7085)
loadams Feb 27, 2025
16ad5fd
Update README.md with ICS '23 MoE paper link (#7087)
siddharth9820 Feb 27, 2025
47d4420
Update parallelism for nv-torch-latest/nightly tests due to more GPUs…
loadams Feb 27, 2025
b3c64dd
Remove workflows for very old torch versions (#7090)
loadams Feb 28, 2025
9b1fe98
Fixed conflicts
gyou2021 Feb 28, 2025
6b96dd9
Update auto_tp.py
gyou2021 Mar 5, 2025
e7883e7
Merge branch 'master' into autoTP_Qwen2Moe_DeepSeekv2
hwchen2017 Mar 5, 2025
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
76 changes: 67 additions & 9 deletions deepspeed/module_inject/auto_tp.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
from deepspeed.module_inject.tp_shard import get_shard_size, get_shard_size_list
from deepspeed.utils import groups
from deepspeed.module_inject.layers import is_autotp_training_mode
<<<<<<< HEAD
import os
import ast
=======
>>>>>>> origin/master


def move(tensor, device, copy=True):
Expand Down Expand Up @@ -191,6 +196,7 @@ def load(module, state_dict, prefix, mp_group=None):


class AutoTP():
moe_experts_reduce_once = False

def __init__(self,
module,
Expand All @@ -214,6 +220,8 @@ def __init__(self,
self.keep_module_on_host = keep_module_on_host

def in_module_list(module, module_list):
if 'DeepseekV2' in str(type(module)):
return False
for item in module_list:
if type(item).__name__ == type(module).__name__:
return True
Expand Down Expand Up @@ -261,7 +269,7 @@ def update_policy_list(policy_list, new_module, new_gems):
for i, policy in enumerate(policy_list):
# if module already exists in policy, combine gems and remove duplicates
if policy[0] == type(new_module):
new_gems = set(new_gems + policy[1])
new_gems = list(set(new_gems + policy[1]))
policy_list[i] = tuple([type(new_module), new_gems])
return policy_list
policy_list.append(tuple([type(new_module), new_gems]))
Expand All @@ -287,6 +295,12 @@ def tp_parser(model):
module_list = []
layer_list = []
gem_list = []
#'DS_MOE_TP_SINGLE_ALLREDUCE' is a environment variable that indicates
# whether the MoE experts adopt the reduce-once optimization.
if not AutoTP.moe_experts_reduce_once:
ds_moe_experts_reduce_once = os.environ.get('DS_MOE_TP_SINGLE_ALLREDUCE')
if ds_moe_experts_reduce_once:
AutoTP.moe_experts_reduce_once = ast.literal_eval(ds_moe_experts_reduce_once)

module_list = AutoTP.get_module_list(model)
assert AutoTP.supported(model), "AutoTP not supported for model. Please use kernel injection since container policy for model exists." \
Expand All @@ -309,7 +323,16 @@ def tp_parser(model):
gem_list = gem_list + [layer]
elif 'o_proj' in layer:
gem_list = gem_list + [layer]
elif 'down_proj' in layer:
elif 'down_proj' in layer and not (('DeepseekV2' in str(type(module))) or \
('qwen2_moe' in str(type(module))) or \
not AutoTP.moe_experts_reduce_once):
gem_list = gem_list + [layer]
elif 'shared_experts.down_proj' in layer and (('DeepseekV2' in str(type(module))) or \
('qwen2_moe' in str(type(module)))) \
and AutoTP.moe_experts_reduce_once:
gem_list = gem_list + [layer]
elif 'mlp.down_proj' in layer and ('DeepseekV2' in str(type(module)) \
and AutoTP.moe_experts_reduce_once):
gem_list = gem_list + [layer]
elif 'attention.dense' in layer and 'GPTNeoX' in str(model):
gem_list = gem_list + [layer]
Expand Down Expand Up @@ -377,7 +400,8 @@ def _replace(self, child, name, conv_linear_layer):
arctic_w2_all_reduce_linear = True
# For MoE MLP model, e.g., deepseek and jamba
down_proj = False
if 'down_proj' in name:
#Deepseek processes different down_proj in different ways.
if 'down_proj' in name and 'DeepseekV2' not in str(type(self.module)):
down_proj = True
if name in self.all_reduce_linears or arctic_w2_all_reduce_linear or down_proj:

Expand All @@ -390,14 +414,48 @@ def _replace(self, child, name, conv_linear_layer):
return LinearAllreduce(child, self.mp_group, name=name)
else:

setattr(child, "replaced", True)
# if conv_linear_layer [weight_shape[1], weight_shape[0] // mp_size]
# else [weight_shape[0] // mp_size, weight_shape[1]]
if self.conv_linear_layer:
conv_LinearLayer(child, self.mp_group)
elif require_tp_fused_qkvw(name, self.mp_size):
#Check and handle fused qkv for TP
return fused_LinearLayer(child, self.mp_group, fused_module=self.module)
child.weight.data = child.weight.data.transpose(-1, -2).contiguous()

return LinearLayer(child, self.mp_group, name=name)
if require_tp_fused_qkvw(name, self.mp_size):
#Check and handle fused qkv for TP
#The copy is a regular copy, The shape of dst and src is the same
data_dc = move(
prepare_tp_fused_qkvw(self.module, child.weight.data, self.mp_size, mp_replace.gpu_index),
device_name, return_new_copy)

bias_data_dc = None if child.bias is None else move(
prepare_tp_fused_qkvw(self.module, child.bias.data, self.mp_size, mp_replace.gpu_index),
device_name, return_new_copy)
else:
if ('shared_experts.down_proj' not in name and 'mlp.down_proj' not in name and 'down_proj' in name \
and ('DeepseekV2' in str(type(self.module)) or 'qwen2_moe' in str(type(self.module))) \
and AutoTP.moe_experts_reduce_once ):
data = child.weight.data.split(get_shard_size_list(weight_shape[1], self.mp_size), dim=1)
data_dc = move(data[mp_replace.gpu_index], get_accelerator().current_device_name()).detach()
del data
bias_data_dc = None if child.bias is None else \
torch.nn.parameter.Parameter(move(child.bias, get_accelerator().current_device_name()))
else:
data = child.weight.data.split(get_shard_size_list(weight_shape[0], self.mp_size, name),
dim=1 if self.conv_linear_layer else 0)
data_dc = move(data[mp_replace.gpu_index], device_name, return_new_copy).detach()
del data

if child.bias is not None:
bias_data = child.bias.data.split(get_shard_size_list(
weight_shape[1] if self.conv_linear_layer else weight_shape[0], self.mp_size, name),
dim=0)
bias_data = move(bias_data[mp_replace.gpu_index], device_name, return_new_copy)
bias_data_dc = torch.nn.parameter.Parameter(bias_data, requires_grad=False)
del bias_data
else:
bias_data_dc = None

setattr(child, "replaced", True)
return LinearLayer(weight=torch.nn.parameter.Parameter(data_dc, requires_grad=False), bias=bias_data_dc)

def _slice_embedding(self, child, name, conv_linear_layer):
if getattr(child, "replaced", False) == True:
Expand Down
Loading