Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
163c6a9e
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
163c6a9e
编写于
1月 13, 2023
作者:
W
wuhuachaocoding
提交者:
GitHub
1月 13, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update reader in sharding unit test. (#49652)
上级
a000e9b8
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
160 addition
and
161 deletion
+160
-161
python/paddle/fluid/tests/unittests/collective/fleet/dygraph_dist_save_load.py
...ests/unittests/collective/fleet/dygraph_dist_save_load.py
+19
-18
python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_api.py
...s/unittests/collective/fleet/dygraph_group_sharded_api.py
+19
-18
python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_api_eager.py
...tests/collective/fleet/dygraph_group_sharded_api_eager.py
+19
-18
python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage2.py
...nittests/collective/fleet/dygraph_group_sharded_stage2.py
+19
-18
python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage2_comm_overlap.py
...ective/fleet/dygraph_group_sharded_stage2_comm_overlap.py
+19
-18
python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage2_offload.py
.../collective/fleet/dygraph_group_sharded_stage2_offload.py
+9
-16
python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage3.py
...nittests/collective/fleet/dygraph_group_sharded_stage3.py
+18
-19
python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage3_offload.py
.../collective/fleet/dygraph_group_sharded_stage3_offload.py
+19
-18
python/paddle/fluid/tests/unittests/collective/multinode/mn_dygraph_group_sharded_stage3.py
...s/collective/multinode/mn_dygraph_group_sharded_stage3.py
+19
-18
未找到文件。
python/paddle/fluid/tests/unittests/collective/fleet/dygraph_dist_save_load.py
浏览文件 @
163c6a9e
...
...
@@ -54,14 +54,18 @@ class MLP(fluid.Layer):
return
y
def
reader_decorator
(
linear_size
=
1000
):
def
__reader__
():
for
_
in
range
(
100
):
img
=
np
.
random
.
rand
(
linear_size
).
astype
(
'float32'
)
class
RandomDataset
(
paddle
.
io
.
Dataset
):
def
__init__
(
self
,
num_samples
=
2000
,
linear_size
=
1000
):
self
.
num_samples
=
num_samples
self
.
linear_size
=
linear_size
def
__getitem__
(
self
,
idx
):
img
=
np
.
random
.
rand
(
self
.
linear_size
).
astype
(
'float32'
)
label
=
np
.
ones
(
1
).
astype
(
'int64'
)
yield
img
,
label
return
img
,
label
return
__reader__
def
__len__
(
self
):
return
self
.
num_samples
def
optimizer_setting
(
model
,
use_pure_fp16
,
opt_group
=
False
):
...
...
@@ -125,18 +129,15 @@ def train_mlp(
)
return
train_reader
=
paddle
.
batch
(
reader_decorator
(),
batch_size
=
batch_size
,
drop_last
=
True
)
train_loader
=
paddle
.
io
.
DataLoader
.
from_generator
(
capacity
=
32
,
use_double_buffer
=
True
,
iterable
=
True
,
return_list
=
True
,
use_multiprocess
=
True
,
paddle
.
seed
(
2023
)
np
.
random
.
seed
(
2023
)
train_loader
=
paddle
.
io
.
DataLoader
(
RandomDataset
(),
batch_size
=
batch_size
,
shuffle
=
False
,
drop_last
=
True
,
num_workers
=
0
,
)
train_loader
.
set_sample_list_generator
(
train_reader
)
if
sharding_stage
==
2
:
model
.
to
(
device
=
"gpu"
)
...
...
python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_api.py
浏览文件 @
163c6a9e
...
...
@@ -50,14 +50,18 @@ class MLP(fluid.Layer):
return
y
def
reader_decorator
(
linear_size
=
1000
):
def
__reader__
():
for
_
in
range
(
100
):
img
=
np
.
random
.
rand
(
linear_size
).
astype
(
'float32'
)
class
RandomDataset
(
paddle
.
io
.
Dataset
):
def
__init__
(
self
,
num_samples
=
2000
,
linear_size
=
1000
):
self
.
num_samples
=
num_samples
self
.
linear_size
=
linear_size
def
__getitem__
(
self
,
idx
):
img
=
np
.
random
.
rand
(
self
.
linear_size
).
astype
(
'float32'
)
label
=
np
.
ones
(
1
).
astype
(
'int64'
)
yield
img
,
label
return
img
,
label
return
__reader__
def
__len__
(
self
):
return
self
.
num_samples
def
optimizer_setting
(
model
,
use_multi_precision
,
opt_group
=
False
):
...
...
@@ -92,18 +96,15 @@ def train_mlp(
model
=
model
,
optimizer
=
optimizer
,
level
=
shard_level
,
scaler
=
scaler
)
train_reader
=
paddle
.
batch
(
reader_decorator
(),
batch_size
=
batch_size
,
drop_last
=
True
)
train_loader
=
paddle
.
io
.
DataLoader
.
from_generator
(
capacity
=
32
,
use_double_buffer
=
True
,
iterable
=
True
,
return_list
=
True
,
use_multiprocess
=
True
,
paddle
.
seed
(
2023
)
np
.
random
.
seed
(
2023
)
train_loader
=
paddle
.
io
.
DataLoader
(
RandomDataset
(),
batch_size
=
batch_size
,
shuffle
=
False
,
drop_last
=
True
,
num_workers
=
0
,
)
train_loader
.
set_sample_list_generator
(
train_reader
)
for
eop
in
range
(
epoch
):
model
.
train
()
...
...
python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_api_eager.py
浏览文件 @
163c6a9e
...
...
@@ -48,14 +48,18 @@ class MLP(fluid.Layer):
return
y
def
reader_decorator
(
linear_size
=
1000
):
def
__reader__
():
for
_
in
range
(
100
):
img
=
np
.
random
.
rand
(
linear_size
).
astype
(
'float32'
)
class
RandomDataset
(
paddle
.
io
.
Dataset
):
def
__init__
(
self
,
num_samples
=
2000
,
linear_size
=
1000
):
self
.
num_samples
=
num_samples
self
.
linear_size
=
linear_size
def
__getitem__
(
self
,
idx
):
img
=
np
.
random
.
rand
(
self
.
linear_size
).
astype
(
'float32'
)
label
=
np
.
ones
(
1
).
astype
(
'int64'
)
yield
img
,
label
return
img
,
label
return
__reader__
def
__len__
(
self
):
return
self
.
num_samples
def
optimizer_setting
(
model
,
use_multi_precision
,
opt_group
=
False
):
...
...
@@ -103,18 +107,15 @@ def train_mlp(
if
shard_level
==
"os_g"
:
optimizer
.
set_lr
(
optimizer
.
get_lr
())
train_reader
=
paddle
.
batch
(
reader_decorator
(),
batch_size
=
batch_size
,
drop_last
=
True
)
train_loader
=
paddle
.
io
.
DataLoader
.
from_generator
(
capacity
=
32
,
use_double_buffer
=
True
,
iterable
=
True
,
return_list
=
True
,
use_multiprocess
=
True
,
paddle
.
seed
(
2023
)
np
.
random
.
seed
(
2023
)
train_loader
=
paddle
.
io
.
DataLoader
(
RandomDataset
(),
batch_size
=
batch_size
,
shuffle
=
False
,
drop_last
=
True
,
num_workers
=
0
,
)
train_loader
.
set_sample_list_generator
(
train_reader
)
for
eop
in
range
(
epoch
):
model
.
train
()
...
...
python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage2.py
浏览文件 @
163c6a9e
...
...
@@ -53,14 +53,18 @@ class MLP(fluid.Layer):
return
y
def
reader_decorator
(
linear_size
=
1000
):
def
__reader__
():
for
_
in
range
(
100
):
img
=
np
.
random
.
rand
(
linear_size
).
astype
(
'float32'
)
class
RandomDataset
(
paddle
.
io
.
Dataset
):
def
__init__
(
self
,
num_samples
=
2000
,
linear_size
=
1000
):
self
.
num_samples
=
num_samples
self
.
linear_size
=
linear_size
def
__getitem__
(
self
,
idx
):
img
=
np
.
random
.
rand
(
self
.
linear_size
).
astype
(
'float32'
)
label
=
np
.
ones
(
1
).
astype
(
'int64'
)
yield
img
,
label
return
img
,
label
return
__reader__
def
__len__
(
self
):
return
self
.
num_samples
def
optimizer_setting
(
model
,
use_pure_fp16
,
opt_group
=
False
):
...
...
@@ -122,18 +126,15 @@ def train_mlp(
)
return
train_reader
=
paddle
.
batch
(
reader_decorator
(),
batch_size
=
batch_size
,
drop_last
=
True
)
train_loader
=
paddle
.
io
.
DataLoader
.
from_generator
(
capacity
=
32
,
use_double_buffer
=
True
,
iterable
=
True
,
return_list
=
True
,
use_multiprocess
=
True
,
paddle
.
seed
(
2023
)
np
.
random
.
seed
(
2023
)
train_loader
=
paddle
.
io
.
DataLoader
(
RandomDataset
(),
batch_size
=
batch_size
,
shuffle
=
False
,
drop_last
=
True
,
num_workers
=
0
,
)
train_loader
.
set_sample_list_generator
(
train_reader
)
if
sharding_stage
==
2
:
model
.
to
(
device
=
"gpu"
)
...
...
python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage2_comm_overlap.py
浏览文件 @
163c6a9e
...
...
@@ -53,14 +53,18 @@ class MLP(fluid.Layer):
return
y
def
reader_decorator
(
linear_size
=
1000
):
def
__reader__
():
for
_
in
range
(
100
):
img
=
np
.
random
.
rand
(
linear_size
).
astype
(
'float32'
)
class
RandomDataset
(
paddle
.
io
.
Dataset
):
def
__init__
(
self
,
num_samples
=
2000
,
linear_size
=
1000
):
self
.
num_samples
=
num_samples
self
.
linear_size
=
linear_size
def
__getitem__
(
self
,
idx
):
img
=
np
.
random
.
rand
(
self
.
linear_size
).
astype
(
'float32'
)
label
=
np
.
ones
(
1
).
astype
(
'int64'
)
yield
img
,
label
return
img
,
label
return
__reader__
def
__len__
(
self
):
return
self
.
num_samples
def
optimizer_setting
(
model
,
use_pure_fp16
,
opt_group
=
False
):
...
...
@@ -124,18 +128,15 @@ def train_mlp(
)
return
train_reader
=
paddle
.
batch
(
reader_decorator
(),
batch_size
=
batch_size
,
drop_last
=
True
)
train_loader
=
paddle
.
io
.
DataLoader
.
from_generator
(
capacity
=
32
,
use_double_buffer
=
True
,
iterable
=
True
,
return_list
=
True
,
use_multiprocess
=
True
,
paddle
.
seed
(
2023
)
np
.
random
.
seed
(
2023
)
train_loader
=
paddle
.
io
.
DataLoader
(
RandomDataset
(),
batch_size
=
batch_size
,
shuffle
=
False
,
drop_last
=
True
,
num_workers
=
0
,
)
train_loader
.
set_sample_list_generator
(
train_reader
)
if
sharding_stage
==
2
:
model
.
to
(
device
=
"gpu"
)
...
...
python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage2_offload.py
浏览文件 @
163c6a9e
...
...
@@ -15,11 +15,7 @@
# limitations under the License.
import
numpy
as
np
from
dygraph_group_sharded_stage2
import
(
MLP
,
optimizer_setting
,
reader_decorator
,
)
from
dygraph_group_sharded_stage2
import
MLP
,
RandomDataset
,
optimizer_setting
import
paddle
from
paddle.distributed.fleet.meta_parallel.sharding.group_sharded_optimizer_stage2
import
(
...
...
@@ -53,18 +49,15 @@ def train_mlp(model, offload=False):
)
model
=
GroupShardedStage2
(
model
,
optimizer
,
buffer_max_size
=
2
**
21
)
train_reader
=
paddle
.
batch
(
reader_decorator
(
linear_size
),
batch_size
=
batch_size
,
drop_last
=
True
)
train_loader
=
paddle
.
io
.
DataLoader
.
from_generator
(
capacity
=
32
,
use_double_buffer
=
True
,
iterable
=
True
,
return_list
=
True
,
use_multiprocess
=
True
,
paddle
.
seed
(
2023
)
np
.
random
.
seed
(
2023
)
train_loader
=
paddle
.
io
.
DataLoader
(
RandomDataset
(),
batch_size
=
batch_size
,
shuffle
=
False
,
drop_last
=
True
,
num_workers
=
0
,
)
train_loader
.
set_sample_list_generator
(
train_reader
)
for
eop
in
range
(
epoch
):
model
.
train
()
...
...
python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage3.py
浏览文件 @
163c6a9e
...
...
@@ -44,7 +44,7 @@ l2_decay = 1e-4
class
MLP
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
,
linear_size
=
10
00
,
param_attr
=
None
,
bias_attr
=
None
):
def
__init__
(
self
,
linear_size
=
10
24
,
param_attr
=
None
,
bias_attr
=
None
):
super
().
__init__
()
self
.
_linear1
=
Linear
(
linear_size
,
linear_size
)
...
...
@@ -102,14 +102,18 @@ class SpecialModel(paddle.nn.Layer):
return
x
def
reader_decorator
(
linear_size
=
1000
):
def
__reader__
():
for
_
in
range
(
100
):
img
=
np
.
random
.
rand
(
linear_size
).
astype
(
'float32'
)
class
RandomDataset
(
paddle
.
io
.
Dataset
):
def
__init__
(
self
,
num_samples
=
2000
,
linear_size
=
1024
):
self
.
num_samples
=
num_samples
self
.
linear_size
=
linear_size
def
__getitem__
(
self
,
idx
):
img
=
np
.
random
.
rand
(
self
.
linear_size
).
astype
(
'float32'
)
label
=
np
.
ones
(
1
).
astype
(
'int64'
)
yield
img
,
label
return
img
,
label
return
__reader__
def
__len__
(
self
):
return
self
.
num_samples
def
optimizer_setting
(
model
,
use_pure_fp16
,
opt_group
=
False
):
...
...
@@ -181,21 +185,16 @@ def train_mlp(
)
return
train_reader
=
paddle
.
batch
(
reader_decorator
(
linear_size
=
linear_size
),
paddle
.
seed
(
2023
)
np
.
random
.
seed
(
2023
)
train_loader
=
paddle
.
io
.
DataLoader
(
RandomDataset
(),
batch_size
=
batch_size
,
shuffle
=
False
,
drop_last
=
True
,
num_workers
=
0
,
)
train_loader
=
paddle
.
io
.
DataLoader
.
from_generator
(
capacity
=
32
,
use_double_buffer
=
True
,
iterable
=
True
,
return_list
=
True
,
use_multiprocess
=
True
,
)
train_loader
.
set_sample_list_generator
(
train_reader
)
for
eop
in
range
(
epoch
):
model
.
train
()
for
batch_id
,
data
in
enumerate
(
train_loader
()):
...
...
python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage3_offload.py
浏览文件 @
163c6a9e
...
...
@@ -52,14 +52,18 @@ class MLP(fluid.Layer):
return
y
def
reader_decorator
(
linear_size
=
1000
):
def
__reader__
():
for
_
in
range
(
100
):
img
=
np
.
random
.
rand
(
linear_size
).
astype
(
'float32'
)
class
RandomDataset
(
paddle
.
io
.
Dataset
):
def
__init__
(
self
,
num_samples
=
2000
,
linear_size
=
1000
):
self
.
num_samples
=
num_samples
self
.
linear_size
=
linear_size
def
__getitem__
(
self
,
idx
):
img
=
np
.
random
.
rand
(
self
.
linear_size
).
astype
(
'float32'
)
label
=
np
.
ones
(
1
).
astype
(
'int64'
)
yield
img
,
label
return
img
,
label
return
__reader__
def
__len__
(
self
):
return
self
.
num_samples
def
optimizer_setting
(
model
,
use_pure_fp16
,
opt_group
=
False
):
...
...
@@ -103,18 +107,15 @@ def train_mlp(
segment_size
=
2
**
15
,
)
train_reader
=
paddle
.
batch
(
reader_decorator
(),
batch_size
=
batch_size
,
drop_last
=
True
)
train_loader
=
paddle
.
io
.
DataLoader
.
from_generator
(
capacity
=
32
,
use_double_buffer
=
True
,
iterable
=
True
,
return_list
=
True
,
use_multiprocess
=
True
,
paddle
.
seed
(
2023
)
np
.
random
.
seed
(
2023
)
train_loader
=
paddle
.
io
.
DataLoader
(
RandomDataset
(),
batch_size
=
batch_size
,
shuffle
=
False
,
drop_last
=
True
,
num_workers
=
0
,
)
train_loader
.
set_sample_list_generator
(
train_reader
)
for
eop
in
range
(
epoch
):
model
.
train
()
...
...
python/paddle/fluid/tests/unittests/collective/multinode/mn_dygraph_group_sharded_stage3.py
浏览文件 @
163c6a9e
...
...
@@ -63,14 +63,18 @@ class MLP(fluid.Layer):
return
y
def
reader_decorator
(
linear_size
=
1000
):
def
__reader__
():
for
_
in
range
(
100
):
img
=
np
.
random
.
rand
(
linear_size
).
astype
(
'float32'
)
class
RandomDataset
(
paddle
.
io
.
Dataset
):
def
__init__
(
self
,
num_samples
=
2000
,
linear_size
=
1000
):
self
.
num_samples
=
num_samples
self
.
linear_size
=
linear_size
def
__getitem__
(
self
,
idx
):
img
=
np
.
random
.
rand
(
self
.
linear_size
).
astype
(
'float32'
)
label
=
np
.
ones
(
1
).
astype
(
'int64'
)
yield
img
,
label
return
img
,
label
return
__reader__
def
__len__
(
self
):
return
self
.
num_samples
def
optimizer_setting
(
model
,
use_pure_fp16
,
opt_group
=
False
):
...
...
@@ -141,18 +145,15 @@ def train_mlp(
)
return
train_reader
=
paddle
.
batch
(
reader_decorator
(),
batch_size
=
batch_size
,
drop_last
=
True
)
train_loader
=
paddle
.
io
.
DataLoader
.
from_generator
(
capacity
=
32
,
use_double_buffer
=
True
,
iterable
=
True
,
return_list
=
True
,
use_multiprocess
=
True
,
paddle
.
seed
(
2023
)
np
.
random
.
seed
(
2023
)
train_loader
=
paddle
.
io
.
DataLoader
(
RandomDataset
(),
batch_size
=
batch_size
,
shuffle
=
False
,
drop_last
=
True
,
num_workers
=
0
,
)
train_loader
.
set_sample_list_generator
(
train_reader
)
for
eop
in
range
(
epoch
):
model
.
train
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录