Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
afeixing77
Paddle
提交
d028214d
P
Paddle
项目概览
afeixing77
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
d028214d
编写于
8月 16, 2021
作者:
F
Fan Zhang
提交者:
GitHub
8月 16, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[CPU-PSLIB] Add config for scale_sparse_grad in config_fleet.py,test=develop (#34893)
上级
ae80df91
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
26 addition
and
6 deletion
+26
-6
paddle/fluid/framework/device_worker.h
paddle/fluid/framework/device_worker.h
+1
-0
paddle/fluid/framework/downpour_worker.cc
paddle/fluid/framework/downpour_worker.cc
+6
-2
paddle/fluid/framework/downpour_worker_opt.cc
paddle/fluid/framework/downpour_worker_opt.cc
+3
-1
paddle/fluid/framework/fleet/fleet_wrapper.cc
paddle/fluid/framework/fleet/fleet_wrapper.cc
+3
-2
paddle/fluid/framework/fleet/fleet_wrapper.h
paddle/fluid/framework/fleet/fleet_wrapper.h
+2
-1
paddle/fluid/framework/trainer_desc.proto
paddle/fluid/framework/trainer_desc.proto
+1
-0
python/paddle/fluid/incubate/fleet/parameter_server/pslib/optimizer_factory.py
...ncubate/fleet/parameter_server/pslib/optimizer_factory.py
+2
-0
python/paddle/fluid/trainer_desc.py
python/paddle/fluid/trainer_desc.py
+4
-0
python/paddle/fluid/trainer_factory.py
python/paddle/fluid/trainer_factory.py
+4
-0
未找到文件。
paddle/fluid/framework/device_worker.h
浏览文件 @
d028214d
...
@@ -212,6 +212,7 @@ class DeviceWorker {
...
@@ -212,6 +212,7 @@ class DeviceWorker {
FetchConfig
fetch_config_
;
FetchConfig
fetch_config_
;
bool
use_cvm_
;
bool
use_cvm_
;
bool
no_cvm_
;
bool
no_cvm_
;
bool
scale_sparse_gradient_with_batch_size_
;
TrainerDesc
trainer_desc_
;
TrainerDesc
trainer_desc_
;
// dump params or grads for debug
// dump params or grads for debug
...
...
paddle/fluid/framework/downpour_worker.cc
浏览文件 @
d028214d
...
@@ -89,6 +89,8 @@ void DownpourWorker::Initialize(const TrainerDesc& desc) {
...
@@ -89,6 +89,8 @@ void DownpourWorker::Initialize(const TrainerDesc& desc) {
use_cvm_
=
desc
.
use_cvm
();
use_cvm_
=
desc
.
use_cvm
();
// for sparse value accessor, embedding only
// for sparse value accessor, embedding only
no_cvm_
=
desc
.
no_cvm
();
no_cvm_
=
desc
.
no_cvm
();
scale_sparse_gradient_with_batch_size_
=
desc
.
scale_sparse_gradient_with_batch_size
();
scale_datanorm_
=
desc
.
scale_datanorm
();
scale_datanorm_
=
desc
.
scale_datanorm
();
dump_slot_
=
desc
.
dump_slot
();
dump_slot_
=
desc
.
dump_slot
();
adjust_ins_weight_config_
=
desc
.
adjust_ins_weight_config
();
adjust_ins_weight_config_
=
desc
.
adjust_ins_weight_config
();
...
@@ -591,7 +593,8 @@ void DownpourWorker::TrainFilesWithProfiler() {
...
@@ -591,7 +593,8 @@ void DownpourWorker::TrainFilesWithProfiler() {
*
thread_scope_
,
tid
,
features_
[
tid
],
feature_labels_
[
tid
],
*
thread_scope_
,
tid
,
features_
[
tid
],
feature_labels_
[
tid
],
sparse_key_names_
[
tid
],
sparse_grad_names_
[
tid
],
table
.
emb_dim
(),
sparse_key_names_
[
tid
],
sparse_grad_names_
[
tid
],
table
.
emb_dim
(),
&
feature_grads_
[
tid
],
&
push_sparse_status_
,
cur_batch
,
use_cvm_
,
&
feature_grads_
[
tid
],
&
push_sparse_status_
,
cur_batch
,
use_cvm_
,
dump_slot_
,
&
sparse_push_keys_
[
tid
],
no_cvm_
);
dump_slot_
,
&
sparse_push_keys_
[
tid
],
no_cvm_
,
scale_sparse_gradient_with_batch_size_
);
timeline
.
Pause
();
timeline
.
Pause
();
push_sparse_time
+=
timeline
.
ElapsedSec
();
push_sparse_time
+=
timeline
.
ElapsedSec
();
total_time
+=
timeline
.
ElapsedSec
();
total_time
+=
timeline
.
ElapsedSec
();
...
@@ -866,7 +869,8 @@ void DownpourWorker::TrainFiles() {
...
@@ -866,7 +869,8 @@ void DownpourWorker::TrainFiles() {
*
thread_scope_
,
tid
,
features_
[
tid
],
feature_labels_
[
tid
],
*
thread_scope_
,
tid
,
features_
[
tid
],
feature_labels_
[
tid
],
sparse_key_names_
[
tid
],
sparse_grad_names_
[
tid
],
table
.
emb_dim
(),
sparse_key_names_
[
tid
],
sparse_grad_names_
[
tid
],
table
.
emb_dim
(),
&
feature_grads_
[
tid
],
&
push_sparse_status_
,
cur_batch
,
use_cvm_
,
&
feature_grads_
[
tid
],
&
push_sparse_status_
,
cur_batch
,
use_cvm_
,
dump_slot_
,
&
sparse_push_keys_
[
tid
],
no_cvm_
);
dump_slot_
,
&
sparse_push_keys_
[
tid
],
no_cvm_
,
scale_sparse_gradient_with_batch_size_
);
}
}
}
}
...
...
paddle/fluid/framework/downpour_worker_opt.cc
浏览文件 @
d028214d
...
@@ -450,11 +450,13 @@ void DownpourWorkerOpt::TrainFiles() {
...
@@ -450,11 +450,13 @@ void DownpourWorkerOpt::TrainFiles() {
break
;
break
;
}
}
}
}
bool
scale_sparse_gradient_with_batch_size_
=
true
;
fleet_ptr_
->
PushSparseVarsWithLabelAsync
(
fleet_ptr_
->
PushSparseVarsWithLabelAsync
(
*
thread_scope_
,
tid
,
features_
[
tid
],
feature_labels_
[
tid
],
*
thread_scope_
,
tid
,
features_
[
tid
],
feature_labels_
[
tid
],
sparse_key_names_
[
tid
],
sparse_grad_names_
[
tid
],
table
.
emb_dim
(),
sparse_key_names_
[
tid
],
sparse_grad_names_
[
tid
],
table
.
emb_dim
(),
&
feature_grads_
[
tid
],
&
push_sparse_status_
,
cur_batch
,
use_cvm_
,
&
feature_grads_
[
tid
],
&
push_sparse_status_
,
cur_batch
,
use_cvm_
,
dump_slot_
,
&
sparse_push_keys_
[
tid
],
no_cvm_
);
dump_slot_
,
&
sparse_push_keys_
[
tid
],
no_cvm_
,
scale_sparse_gradient_with_batch_size_
);
}
}
}
}
...
...
paddle/fluid/framework/fleet/fleet_wrapper.cc
浏览文件 @
d028214d
...
@@ -870,7 +870,8 @@ void FleetWrapper::PushSparseVarsWithLabelAsync(
...
@@ -870,7 +870,8 @@ void FleetWrapper::PushSparseVarsWithLabelAsync(
std
::
vector
<
std
::
vector
<
float
>>*
push_values
,
std
::
vector
<
std
::
vector
<
float
>>*
push_values
,
std
::
vector
<::
std
::
future
<
int32_t
>>*
push_sparse_status
,
std
::
vector
<::
std
::
future
<
int32_t
>>*
push_sparse_status
,
const
int
batch_size
,
const
bool
use_cvm
,
const
bool
dump_slot
,
const
int
batch_size
,
const
bool
use_cvm
,
const
bool
dump_slot
,
std
::
vector
<
uint64_t
>*
sparse_push_keys
,
const
bool
no_cvm
)
{
std
::
vector
<
uint64_t
>*
sparse_push_keys
,
const
bool
no_cvm
,
const
bool
scale_sparse_gradient_with_batch_size
)
{
#ifdef PADDLE_WITH_PSLIB
#ifdef PADDLE_WITH_PSLIB
int
offset
=
2
;
int
offset
=
2
;
int
slot_offset
=
0
;
int
slot_offset
=
0
;
...
@@ -939,7 +940,7 @@ void FleetWrapper::PushSparseVarsWithLabelAsync(
...
@@ -939,7 +940,7 @@ void FleetWrapper::PushSparseVarsWithLabelAsync(
}
}
float
*
g
=
g_tensor
->
data
<
float
>
();
float
*
g
=
g_tensor
->
data
<
float
>
();
if
(
scale_sparse_gradient_with_batch_size
_
&&
grad_dim
>
0
)
{
if
(
scale_sparse_gradient_with_batch_size
&&
grad_dim
>
0
)
{
int
dim
=
emb_dim
;
int
dim
=
emb_dim
;
Eigen
::
Map
<
Eigen
::
Map
<
Eigen
::
Matrix
<
float
,
Eigen
::
Dynamic
,
Eigen
::
Dynamic
,
Eigen
::
RowMajor
>>
Eigen
::
Matrix
<
float
,
Eigen
::
Dynamic
,
Eigen
::
Dynamic
,
Eigen
::
RowMajor
>>
...
...
paddle/fluid/framework/fleet/fleet_wrapper.h
浏览文件 @
d028214d
...
@@ -209,7 +209,8 @@ class FleetWrapper {
...
@@ -209,7 +209,8 @@ class FleetWrapper {
std
::
vector
<
std
::
vector
<
float
>>*
push_values
,
std
::
vector
<
std
::
vector
<
float
>>*
push_values
,
std
::
vector
<::
std
::
future
<
int32_t
>>*
push_sparse_status
,
std
::
vector
<::
std
::
future
<
int32_t
>>*
push_sparse_status
,
const
int
batch_size
,
const
bool
use_cvm
,
const
bool
dump_slot
,
const
int
batch_size
,
const
bool
use_cvm
,
const
bool
dump_slot
,
std
::
vector
<
uint64_t
>*
sparse_push_keys
,
const
bool
no_cvm
);
std
::
vector
<
uint64_t
>*
sparse_push_keys
,
const
bool
no_cvm
,
const
bool
scale_sparse_gradient_with_batch_size
);
// Push sparse variables to server in async mode
// Push sparse variables to server in async mode
void
PushSparseFromTensorWithLabelAsync
(
void
PushSparseFromTensorWithLabelAsync
(
...
...
paddle/fluid/framework/trainer_desc.proto
浏览文件 @
d028214d
...
@@ -61,6 +61,7 @@ message TrainerDesc {
...
@@ -61,6 +61,7 @@ message TrainerDesc {
optional
bool
use_ps_gpu
=
32
[
default
=
false
];
optional
bool
use_ps_gpu
=
32
[
default
=
false
];
optional
string
user_define_dump_filename
=
33
;
optional
string
user_define_dump_filename
=
33
;
optional
bool
scale_sparse_gradient_with_batch_size
=
34
[
default
=
true
];
// device worker parameters
// device worker parameters
optional
HogwildWorkerParameter
hogwild_param
=
101
;
optional
HogwildWorkerParameter
hogwild_param
=
101
;
...
...
python/paddle/fluid/incubate/fleet/parameter_server/pslib/optimizer_factory.py
浏览文件 @
d028214d
...
@@ -825,6 +825,8 @@ class DistributedAdam(DistributedOptimizerImplBase):
...
@@ -825,6 +825,8 @@ class DistributedAdam(DistributedOptimizerImplBase):
opt_info
[
"worker_skipped_ops"
]
=
worker_skipped_ops
opt_info
[
"worker_skipped_ops"
]
=
worker_skipped_ops
opt_info
[
"use_cvm"
]
=
strategy
.
get
(
"use_cvm"
,
False
)
opt_info
[
"use_cvm"
]
=
strategy
.
get
(
"use_cvm"
,
False
)
opt_info
[
"no_cvm"
]
=
strategy
.
get
(
"no_cvm"
,
False
)
opt_info
[
"no_cvm"
]
=
strategy
.
get
(
"no_cvm"
,
False
)
opt_info
[
"scale_sparse_gradient_with_batch_size"
]
=
strategy
.
get
(
"scale_sparse_gradient_with_batch_size"
,
True
)
opt_info
[
"worker_class"
]
=
strategy
.
get
(
"worker_class"
,
opt_info
[
"worker_class"
]
=
strategy
.
get
(
"worker_class"
,
"DownpourWorker"
)
"DownpourWorker"
)
opt_info
[
"stat_var_names"
]
=
strategy
.
get
(
"stat_var_names"
,
[])
opt_info
[
"stat_var_names"
]
=
strategy
.
get
(
"stat_var_names"
,
[])
...
...
python/paddle/fluid/trainer_desc.py
浏览文件 @
d028214d
...
@@ -124,6 +124,10 @@ class TrainerDesc(object):
...
@@ -124,6 +124,10 @@ class TrainerDesc(object):
def
_set_no_cvm
(
self
,
no_cvm
=
False
):
def
_set_no_cvm
(
self
,
no_cvm
=
False
):
self
.
proto_desc
.
no_cvm
=
no_cvm
self
.
proto_desc
.
no_cvm
=
no_cvm
def
_set_scale_sparse_grad_with_batch_size
(
self
,
scale_sparse_gradient_with_batch_size
=
True
):
self
.
proto_desc
.
scale_sparse_gradient_with_batch_size
=
scale_sparse_gradient_with_batch_size
def
_set_scale_datanorm
(
self
,
scale_datanorm
=-
1
):
def
_set_scale_datanorm
(
self
,
scale_datanorm
=-
1
):
self
.
proto_desc
.
scale_datanorm
=
scale_datanorm
self
.
proto_desc
.
scale_datanorm
=
scale_datanorm
...
...
python/paddle/fluid/trainer_factory.py
浏览文件 @
d028214d
...
@@ -95,6 +95,10 @@ class TrainerFactory(object):
...
@@ -95,6 +95,10 @@ class TrainerFactory(object):
trainer
.
_set_use_cvm
(
opt_info
[
"use_cvm"
])
trainer
.
_set_use_cvm
(
opt_info
[
"use_cvm"
])
if
opt_info
.
get
(
"no_cvm"
)
is
not
None
:
if
opt_info
.
get
(
"no_cvm"
)
is
not
None
:
trainer
.
_set_no_cvm
(
opt_info
[
"no_cvm"
])
trainer
.
_set_no_cvm
(
opt_info
[
"no_cvm"
])
if
opt_info
.
get
(
"scale_sparse_gradient_with_batch_size"
)
is
not
None
:
trainer
.
_set_scale_sparse_grad_with_batch_size
(
opt_info
[
"scale_sparse_gradient_with_batch_size"
])
if
opt_info
.
get
(
"scale_datanorm"
)
is
not
None
:
if
opt_info
.
get
(
"scale_datanorm"
)
is
not
None
:
trainer
.
_set_scale_datanorm
(
opt_info
[
"scale_datanorm"
])
trainer
.
_set_scale_datanorm
(
opt_info
[
"scale_datanorm"
])
if
opt_info
.
get
(
"adjust_ins_weight"
)
is
not
None
:
if
opt_info
.
get
(
"adjust_ins_weight"
)
is
not
None
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录