Skip to content

Commit a50d129

Browse files
authored
add delta score, scale show (#33492)
1 parent 72d3697 commit a50d129

File tree

7 files changed

+20
-59
lines changed

7 files changed

+20
-59
lines changed

paddle/fluid/framework/fleet/heter_ps/feature_value.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -52,25 +52,6 @@ struct FeaturePushValue {
5252
float lr_g;
5353
float mf_g[MF_DIM];
5454
};
55-
// class DownpourFixedFeatureValue {
56-
// public:
57-
// DownpourFixedFeatureValue() {}
58-
// ~DownpourFixedFeatureValue() {}
59-
// float* data() {
60-
// return _data.data();
61-
// }
62-
// size_t size() {
63-
// return _data.size();
64-
// }
65-
// void resize(size_t size) {
66-
// _data.resize(size);
67-
// }
68-
// void shrink_to_fit() {
69-
// _data.shrink_to_fit();
70-
// }
71-
// private:
72-
// std::vector<float> _data;
73-
// };
7455

7556
} // end namespace framework
7657
} // end namespace paddle

paddle/fluid/framework/fleet/heter_ps/optimizer.cuh.h

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,6 @@ limitations under the License. */
2323
namespace paddle {
2424
namespace framework {
2525

26-
__device__ double cuda_double_random(unsigned long long seed) {
27-
// copy from MurmurHash3
28-
seed ^= seed >> 33;
29-
seed *= 0xff51afd7ed558ccd;
30-
seed ^= seed >> 33;
31-
seed *= 0xc4ceb9fe1a85ec53;
32-
seed ^= seed >> 33;
33-
return ((double)seed / 18446744073709551615.0);
34-
}
35-
36-
__device__ float cuda_normal_random(unsigned long long idx) {
37-
static double pi = 3.1415926897932384;
38-
unsigned long long x = clock64() + idx;
39-
double x1, x2, res;
40-
while (1) {
41-
x1 = cuda_double_random(x);
42-
x2 = cuda_double_random(x + 33);
43-
res = sqrt(-2.0 * log(x1)) * cos(2.0 * pi * x2);
44-
if (-10 < res && res < 10) break;
45-
x += 207;
46-
}
47-
return res;
48-
}
49-
5026
template <typename ValType, typename GradType>
5127
class Optimizer {
5228
public:
@@ -95,11 +71,12 @@ class Optimizer {
9571
}
9672
__device__ void update_value(ValType& val, const GradType& grad) {
9773
val.slot = grad.slot;
98-
;
9974
val.show += grad.show;
10075
val.clk += grad.clk;
76+
val.delta_score += optimizer_config::nonclk_coeff * (grad.show - grad.clk) +
77+
optimizer_config::clk_coeff * grad.clk;
10178

102-
update_lr(val.lr, val.lr_g2sum, grad.lr_g, 1.0);
79+
update_lr(val.lr, val.lr_g2sum, grad.lr_g, grad.show);
10380

10481
if (val.mf_size == 0) {
10582
if (optimizer_config::mf_create_thresholds <=
@@ -116,7 +93,7 @@ class Optimizer {
11693
}
11794
}
11895
} else {
119-
update_mf(MF_DIM, &val.mf[1], val.mf[0], grad.mf_g, 1.0);
96+
update_mf(MF_DIM, &val.mf[1], val.mf[0], grad.mf_g, grad.show);
12097
}
12198
}
12299
};

paddle/fluid/framework/fleet/heter_ps/optimizer_conf.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@ limitations under the License. */
1616

1717
namespace optimizer_config {
1818

19-
__constant__ float mf_create_thresholds = 0;
2019
__constant__ float nonclk_coeff = 0.1;
2120
__constant__ float clk_coeff = 1;
21+
2222
__constant__ float min_bound = -10;
2323
__constant__ float max_bound = 10;
2424
__constant__ float learning_rate = 0.05;
2525
__constant__ float initial_g2sum = 3.0;
26-
__constant__ float initial_range = 1e-4;
26+
__constant__ float initial_range = 0;
2727

28+
__constant__ float mf_create_thresholds = 10;
2829
__constant__ float mf_learning_rate = 0.05;
2930
__constant__ float mf_initial_g2sum = 3.0;
3031
__constant__ float mf_initial_range = 1e-4;

paddle/fluid/framework/io/fs.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -240,16 +240,16 @@ void set_download_command(const std::string& x) {
240240

241241
std::shared_ptr<FILE> hdfs_open_read(std::string path, int* err_no,
242242
const std::string& converter) {
243-
if (fs_end_with_internal(path, ".gz")) {
244-
path = string::format_string("%s -text \"%s\"", hdfs_command().c_str(),
243+
if (download_cmd() != "") { // use customized download command
244+
path = string::format_string("%s \"%s\"", download_cmd().c_str(),
245245
path.c_str());
246246
} else {
247-
const std::string file_path = path;
248-
path = string::format_string("%s -cat \"%s\"", hdfs_command().c_str(),
249-
file_path.c_str());
250-
if (download_cmd() != "") { // use customized download command
251-
path = string::format_string("%s \"%s\"", download_cmd().c_str(),
252-
file_path.c_str());
247+
if (fs_end_with_internal(path, ".gz")) {
248+
path = string::format_string("%s -text \"%s\"", hdfs_command().c_str(),
249+
path.c_str());
250+
} else {
251+
path = string::format_string("%s -cat \"%s\"", hdfs_command().c_str(),
252+
path.c_str());
253253
}
254254
}
255255

python/paddle/fluid/incubate/fleet/parameter_server/pslib/optimizer_factory.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import copy
2525
from .node import DownpourWorker, DownpourServer
2626
from . import ps_pb2 as pslib
27+
import os
2728

2829
OpRole = core.op_proto_and_checker_maker.OpRole
2930
# this dict is for store info about pull/push sparse ops.
@@ -765,7 +766,8 @@ def _minimize(self,
765766
"user_define_dump_filename", "")
766767
opt_info["dump_fields_path"] = strategy.get("dump_fields_path", "")
767768
opt_info["dump_param"] = strategy.get("dump_param", [])
768-
opt_info["worker_places"] = strategy.get("worker_places", [])
769+
gpus_env = os.getenv("FLAGS_selected_gpus")
770+
opt_info["worker_places"] = [int(s) for s in gpus_env.split(",")]
769771
opt_info["use_ps_gpu"] = strategy.get("use_ps_gpu", False)
770772
if server._server.downpour_server_param.downpour_table_param[
771773
0].accessor.accessor_class in [

python/paddle/fluid/incubate/fleet/utils/fleet_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
__all__ = ["FleetUtil"]
3333

3434
_logger = get_logger(
35-
__name__, logging.INFO, fmt='%(asctime)s-%(levelname)s: %(message)s')
35+
__name__, logging.INFO, fmt='%(asctime)s %(levelname)s: %(message)s')
3636

3737
fleet = None
3838

python/paddle/fluid/log_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def get_logger(name, level, fmt=None):
4545
handler = logging.StreamHandler()
4646

4747
if fmt:
48-
formatter = logging.Formatter(fmt=fmt)
48+
formatter = logging.Formatter(fmt=fmt, datefmt='%a %b %d %H:%M:%S')
4949
handler.setFormatter(formatter)
5050

5151
logger.addHandler(handler)

0 commit comments

Comments
 (0)