Skip to content

Commit 864c4f7

Browse files
seemingwangroot
and
root
committed
fix syntax error
test new sample optimize thrust alloc (PaddlePaddle#112) fix deepwalk sample kernel (PaddlePaddle#122) Update graphsage speed(thrust -> cub), fix sample async bug (PaddlePaddle#120) * fix deepwalk sample kernel, fix inplace kernel sync bug * update v2 sample * change kernel name for readability * delete unused kernel support slot_feature with different length (PaddlePaddle#124) Co-authored-by: root <root@yq01-inf-hic-k8s-a100-ab2-0009.yq01.baidu.com> add graphsage slot feature (PaddlePaddle#126) 【graphsage】don't alloc a new d_feature_buf if the old one is enough (PaddlePaddle#128) * add graphsage slot feature * update graphsage slot feature * update graphsage slot feature fix linking use type optimization remove file add type-optimization config fix bug in slot_feature (PaddlePaddle#134) Co-authored-by: root <root@yq01-inf-hic-k8s-a100-ab2-0009.yq01.baidu.com> sage network optimization remove log fix bug in slot_feature (PaddlePaddle#134) Co-authored-by: root <root@yq01-inf-hic-k8s-a100-ab2-0009.yq01.baidu.com>
1 parent 4c52893 commit 864c4f7

17 files changed

+2929
-2269
lines changed

paddle/fluid/distributed/ps/table/common_graph_table.cc

+34-9
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ paddle::framework::GpuPsCommGraphFea GraphTable::make_gpu_ps_graph_fea(
7272
std::vector<uint64_t> node_id_array[task_pool_size_];
7373
std::vector<paddle::framework::GpuPsFeaInfo>
7474
node_fea_info_array[task_pool_size_];
75+
slot_feature_num_map_.resize(slot_num);
76+
for (int k = 0; k < slot_num; ++k) {
77+
slot_feature_num_map_[k] = 0;
78+
}
79+
7580
for (size_t i = 0; i < bags.size(); i++) {
7681
if (bags[i].size() > 0) {
7782
tasks.push_back(_shards_task_pool[i]->enqueue([&, i, this]() -> int {
@@ -92,13 +97,17 @@ paddle::framework::GpuPsCommGraphFea GraphTable::make_gpu_ps_graph_fea(
9297
int total_feature_size = 0;
9398
for (int k = 0; k < slot_num; ++k) {
9499
v->get_feature_ids(k, &feature_ids);
95-
total_feature_size += feature_ids.size();
100+
int feature_ids_size = feature_ids.size();
101+
if (slot_feature_num_map_[k] < feature_ids_size) {
102+
slot_feature_num_map_[k] = feature_ids_size;
103+
}
104+
total_feature_size += feature_ids_size;
96105
if (!feature_ids.empty()) {
97106
feature_array[i].insert(feature_array[i].end(),
98107
feature_ids.begin(),
99108
feature_ids.end());
100109
slot_id_array[i].insert(
101-
slot_id_array[i].end(), feature_ids.size(), k);
110+
slot_id_array[i].end(), feature_ids_size, k);
102111
}
103112
}
104113
x.feature_size = total_feature_size;
@@ -111,6 +120,13 @@ paddle::framework::GpuPsCommGraphFea GraphTable::make_gpu_ps_graph_fea(
111120
}
112121
}
113122
for (int i = 0; i < (int)tasks.size(); i++) tasks[i].get();
123+
124+
std::stringstream ss;
125+
for (int k = 0; k < slot_num; ++k) {
126+
ss << slot_feature_num_map_[k] << " ";
127+
}
128+
VLOG(0) << "slot_feature_num_map: " << ss.str();
129+
114130
paddle::framework::GpuPsCommGraphFea res;
115131
uint64_t tot_len = 0;
116132
for (int i = 0; i < task_pool_size_; i++) {
@@ -1849,9 +1865,14 @@ int GraphTable::parse_feature(int idx,
18491865
// "")
18501866
thread_local std::vector<paddle::string::str_ptr> fields;
18511867
fields.clear();
1852-
const char c = feature_separator_.at(0);
1868+
char c = slot_feature_separator_.at(0);
18531869
paddle::string::split_string_ptr(feat_str, len, c, &fields);
18541870

1871+
thread_local std::vector<paddle::string::str_ptr> fea_fields;
1872+
fea_fields.clear();
1873+
c = feature_separator_.at(0);
1874+
paddle::string::split_string_ptr(fields[1].ptr, fields[1].len, c, &fea_fields);
1875+
18551876
std::string name = fields[0].to_string();
18561877
auto it = feat_id_map[idx].find(name);
18571878
if (it != feat_id_map[idx].end()) {
@@ -1862,26 +1883,26 @@ int GraphTable::parse_feature(int idx,
18621883
// string_vector_2_string(fields.begin() + 1, fields.end(), ' ',
18631884
// fea_ptr);
18641885
FeatureNode::parse_value_to_bytes<uint64_t>(
1865-
fields.begin() + 1, fields.end(), fea_ptr);
1886+
fea_fields.begin(), fea_fields.end(), fea_ptr);
18661887
return 0;
18671888
} else if (dtype == "string") {
1868-
string_vector_2_string(fields.begin() + 1, fields.end(), ' ', fea_ptr);
1889+
string_vector_2_string(fea_fields.begin(), fea_fields.end(), ' ', fea_ptr);
18691890
return 0;
18701891
} else if (dtype == "float32") {
18711892
FeatureNode::parse_value_to_bytes<float>(
1872-
fields.begin() + 1, fields.end(), fea_ptr);
1893+
fea_fields.begin(), fea_fields.end(), fea_ptr);
18731894
return 0;
18741895
} else if (dtype == "float64") {
18751896
FeatureNode::parse_value_to_bytes<double>(
1876-
fields.begin() + 1, fields.end(), fea_ptr);
1897+
fea_fields.begin(), fea_fields.end(), fea_ptr);
18771898
return 0;
18781899
} else if (dtype == "int32") {
18791900
FeatureNode::parse_value_to_bytes<int32_t>(
1880-
fields.begin() + 1, fields.end(), fea_ptr);
1901+
fea_fields.begin(), fea_fields.end(), fea_ptr);
18811902
return 0;
18821903
} else if (dtype == "int64") {
18831904
FeatureNode::parse_value_to_bytes<uint64_t>(
1884-
fields.begin() + 1, fields.end(), fea_ptr);
1905+
fea_fields.begin(), fea_fields.end(), fea_ptr);
18851906
return 0;
18861907
}
18871908
} else {
@@ -2118,6 +2139,10 @@ void GraphTable::set_feature_separator(const std::string &ch) {
21182139
feature_separator_ = ch;
21192140
}
21202141

2142+
void GraphTable::set_slot_feature_separator(const std::string &ch) {
2143+
slot_feature_separator_ = ch;
2144+
}
2145+
21212146
int32_t GraphTable::get_server_index_by_id(uint64_t id) {
21222147
return id % shard_num / shard_num_per_server;
21232148
}

paddle/fluid/distributed/ps/table/common_graph_table.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,7 @@ class GraphTable : public Table {
681681
int32_t make_complementary_graph(int idx, int64_t byte_size);
682682
int32_t dump_edges_to_ssd(int idx);
683683
int32_t get_partition_num(int idx) { return partitions[idx].size(); }
684+
std::vector<int> slot_feature_num_map() const { return slot_feature_num_map_; }
684685
std::vector<uint64_t> get_partition(int idx, int index) {
685686
if (idx >= (int)partitions.size() || index >= (int)partitions[idx].size())
686687
return std::vector<uint64_t>();
@@ -698,6 +699,7 @@ class GraphTable : public Table {
698699
#endif
699700
virtual int32_t add_comm_edge(int idx, uint64_t src_id, uint64_t dst_id);
700701
virtual int32_t build_sampler(int idx, std::string sample_type = "random");
702+
void set_slot_feature_separator(const std::string &ch);
701703
void set_feature_separator(const std::string &ch);
702704
std::vector<std::vector<GraphShard *>> edge_shards, feature_shards;
703705
size_t shard_start, shard_end, server_num, shard_num_per_server, shard_num;
@@ -728,7 +730,7 @@ class GraphTable : public Table {
728730
mutable std::mutex mutex_;
729731
bool build_sampler_on_cpu;
730732
bool is_load_reverse_edge = false;
731-
std::vetor<std::vector<int>> node_id_to_edge_types, edge_type_outputs;
733+
std::vector<std::vector<int>> node_id_to_edge_types, edge_type_outputs;
732734
std::shared_ptr<pthread_rwlock_t> rw_lock;
733735
#ifdef PADDLE_WITH_HETERPS
734736
// paddle::framework::GpuPsGraphTable gpu_graph_table;
@@ -737,7 +739,9 @@ class GraphTable : public Table {
737739
// std::shared_ptr<GraphSampler> graph_sampler;
738740
// REGISTER_GRAPH_FRIEND_CLASS(2, CompleteGraphSampler, BasicBfsGraphSampler)
739741
#endif
742+
std::string slot_feature_separator_ = std::string(" ");
740743
std::string feature_separator_ = std::string(" ");
744+
std::vector<int> slot_feature_num_map_;
741745
};
742746

743747
/*

0 commit comments

Comments
 (0)