Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
DeepSpeed
提交
dc226fdb
D
DeepSpeed
项目概览
Greenplum
/
DeepSpeed
上一次同步 大约 1 年
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DeepSpeed
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dc226fdb
编写于
2月 01, 2020
作者:
E
Elton Zheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add two test files
上级
8c4e2a30
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
117 addition
and
0 deletion
+117
-0
tests/unit/test_config.py
tests/unit/test_config.py
+9
-0
tests/unit/test_run.py
tests/unit/test_run.py
+108
-0
未找到文件。
tests/unit/test_config.py
0 → 100644
浏览文件 @
dc226fdb
# A test on its own
import
torch
# A test on its own
import
deepspeed
def
test_cuda
():
assert
(
torch
.
cuda
.
is_available
())
tests/unit/test_run.py
0 → 100644
浏览文件 @
dc226fdb
import
pytest
from
deepspeed.pt
import
deepspeed_run
as
dsrun
def
test_parser_mutual_exclusive
():
'''Ensure dsrun.parse_resource_filter() raises a ValueError when include_str and
exclude_str are both provided.
'''
with
pytest
.
raises
(
ValueError
):
dsrun
.
parse_resource_filter
({},
include_str
=
'A'
,
exclude_str
=
'B'
)
def
test_parser_local
():
''' Test cases with only one node. '''
# First try no incude/exclude
hosts
=
{
'worker-0'
:
[
0
,
1
,
2
,
3
]}
ret
=
dsrun
.
parse_resource_filter
(
hosts
)
assert
(
ret
==
hosts
)
# exclude slots
ret
=
dsrun
.
parse_resource_filter
(
hosts
,
exclude_str
=
'worker-0:1'
)
assert
(
ret
==
{
'worker-0'
:
[
0
,
2
,
3
]})
ret
=
dsrun
.
parse_resource_filter
(
hosts
,
exclude_str
=
'worker-0:1,2'
)
assert
(
ret
==
{
'worker-0'
:
[
0
,
3
]})
# only use one slot
ret
=
dsrun
.
parse_resource_filter
(
hosts
,
include_str
=
'worker-0:1'
)
assert
(
ret
==
{
'worker-0'
:
[
1
]})
# including slots multiple times shouldn't break things
ret
=
dsrun
.
parse_resource_filter
(
hosts
,
include_str
=
'worker-0:1,1'
)
assert
(
ret
==
{
'worker-0'
:
[
1
]})
ret
=
dsrun
.
parse_resource_filter
(
hosts
,
include_str
=
'worker-0:1@worker-0:0,1'
)
assert
(
ret
==
{
'worker-0'
:
[
0
,
1
]})
# including just 'worker-0' without : should still use all GPUs
ret
=
dsrun
.
parse_resource_filter
(
hosts
,
include_str
=
'worker-0'
)
assert
(
ret
==
hosts
)
# excluding just 'worker-0' without : should eliminate everything
ret
=
dsrun
.
parse_resource_filter
(
hosts
,
exclude_str
=
'worker-0'
)
assert
(
ret
==
{})
# exclude all slots manually
ret
=
dsrun
.
parse_resource_filter
(
hosts
,
exclude_str
=
'worker-0:0,1,2,3'
)
assert
(
ret
==
{})
def
test_parser_multinode
():
# First try no incude/exclude
hosts
=
{
'worker-0'
:
[
0
,
1
,
2
,
3
],
'worker-1'
:
[
0
,
1
,
2
,
3
]}
ret
=
dsrun
.
parse_resource_filter
(
hosts
)
assert
(
ret
==
hosts
)
# include a node
ret
=
dsrun
.
parse_resource_filter
(
hosts
,
include_str
=
'worker-1:0,3'
)
assert
(
ret
==
{
'worker-1'
:
[
0
,
3
]})
# exclude a node
ret
=
dsrun
.
parse_resource_filter
(
hosts
,
exclude_str
=
'worker-1'
)
assert
(
ret
==
{
'worker-0'
:
[
0
,
1
,
2
,
3
]})
# exclude part of each node
ret
=
dsrun
.
parse_resource_filter
(
hosts
,
exclude_str
=
'worker-0:0,1@worker-1:3'
)
assert
(
ret
==
{
'worker-0'
:
[
2
,
3
],
'worker-1'
:
[
0
,
1
,
2
]})
def
test_parser_errors
():
'''Ensure we catch errors. '''
hosts
=
{
'worker-0'
:
[
0
,
1
,
2
,
3
],
'worker-1'
:
[
0
,
1
,
2
,
3
]}
# host does not exist
with
pytest
.
raises
(
ValueError
):
dsrun
.
parse_resource_filter
(
hosts
,
include_str
=
'jeff'
)
with
pytest
.
raises
(
ValueError
):
dsrun
.
parse_resource_filter
(
hosts
,
exclude_str
=
'jeff'
)
# slot does not exist
with
pytest
.
raises
(
ValueError
):
dsrun
.
parse_resource_filter
(
hosts
,
include_str
=
'worker-1:4'
)
with
pytest
.
raises
(
ValueError
):
dsrun
.
parse_resource_filter
(
hosts
,
exclude_str
=
'worker-1:4'
)
# formatting
with
pytest
.
raises
(
ValueError
):
dsrun
.
parse_resource_filter
(
hosts
,
exclude_str
=
'worker-1@worker-0:1@5'
)
def
test_num_plus_parser
():
''' Ensure we catch errors relating to num_nodes/num_gpus + -i/-e being mutually exclusive'''
# inclusion
with
pytest
.
raises
(
ValueError
):
dsrun
.
main
(
args
=
"--num_nodes 1 -i localhost foo.py"
.
split
())
with
pytest
.
raises
(
ValueError
):
dsrun
.
main
(
args
=
"--num_nodes 1 --num_gpus 1 -i localhost foo.py"
.
split
())
with
pytest
.
raises
(
ValueError
):
dsrun
.
main
(
args
=
"--num_gpus 1 -i localhost foo.py"
.
split
())
# exclusion
with
pytest
.
raises
(
ValueError
):
dsrun
.
main
(
args
=
"--num_nodes 1 -e localhost foo.py"
.
split
())
with
pytest
.
raises
(
ValueError
):
dsrun
.
main
(
args
=
"--num_nodes 1 --num_gpus 1 -e localhost foo.py"
.
split
())
with
pytest
.
raises
(
ValueError
):
dsrun
.
main
(
args
=
"--num_gpus 1 -e localhost foo.py"
.
split
())
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录