-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'homo-optmization' into homo_gsf
- Loading branch information
Showing
7 changed files
with
288 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{ | ||
"version": "gconstruct-v0.1", | ||
"nodes": [ | ||
{ | ||
"node_id_col": "id", | ||
"node_type": "movie", | ||
"format": {"name": "parquet"}, | ||
"files": "/data/ml-100k/movie.parquet", | ||
"features": [ | ||
{ | ||
"feature_col": "title", | ||
"transform": { | ||
"name": "bert_hf", | ||
"bert_model": "bert-base-uncased", | ||
"max_seq_length": 16 | ||
} | ||
} | ||
], | ||
"labels": [ | ||
{ | ||
"label_col": "label", | ||
"task_type": "classification", | ||
"split_pct": [0.8, 0.1, 0.1] | ||
} | ||
] | ||
}, | ||
{ | ||
"node_type": "movie", | ||
"format": {"name": "parquet"}, | ||
"files": "/data/ml-100k/movie.parquet", | ||
"features": [ | ||
{ | ||
"feature_col": "id" | ||
} | ||
] | ||
} | ||
], | ||
"edges": [ | ||
{ | ||
"source_id_col": "src_id", | ||
"dest_id_col": "dst_id", | ||
"relation": ["movie", "rating", "movie"], | ||
"format": {"name": "parquet"}, | ||
"files": "/data/ml-100k/edges_homogeneous.parquet", | ||
"features": [ | ||
{ | ||
"feature_col": "rate" | ||
}], | ||
"labels": [ | ||
{ | ||
"label_col": "rate", | ||
"task_type": "classification", | ||
"split_pct": [0.1, 0.1, 0.1] | ||
} | ||
] | ||
}, | ||
{ | ||
"relation": ["movie", "rating", "movie"], | ||
"format": {"name": "parquet"}, | ||
"files": "/data/ml-100k/edges_homogeneous.parquet" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
""" | ||
Copyright 2023 Contributors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
""" | ||
import os | ||
import argparse | ||
import dgl | ||
from dgl.distributed.constants import DEFAULT_NTYPE, DEFAULT_ETYPE | ||
from numpy.testing import assert_almost_equal | ||
|
||
|
||
def check_reverse_edge(args): | ||
|
||
g_orig = dgl.load_graphs(os.path.join(args.orig_graph_path, "graph.dgl"))[0][0] | ||
g_rev = dgl.load_graphs(os.path.join(args.rev_graph_path, "graph.dgl"))[0][0] | ||
assert g_orig.ntypes == g_rev.ntypes | ||
assert g_orig.etypes == g_rev.etypes | ||
assert g_orig.number_of_nodes(DEFAULT_NTYPE) == g_rev.number_of_nodes(DEFAULT_NTYPE) | ||
assert 2 * g_orig.number_of_edges(DEFAULT_ETYPE) == g_rev.number_of_edges(DEFAULT_ETYPE) | ||
for ntype in g_orig.ntypes: | ||
assert g_orig.number_of_nodes(ntype) == g_rev.number_of_nodes(ntype) | ||
for name in g_orig.nodes[ntype].data: | ||
# We should skip '*_mask' because data split is split randomly. | ||
if 'mask' not in name: | ||
assert_almost_equal(g_orig.nodes[ntype].data[name].numpy(), | ||
g_rev.nodes[ntype].data[name].numpy()) | ||
|
||
# Check edge feature | ||
g_orig_feat = dgl.data.load_tensors(os.path.join(args.orig_graph_path, "edge_feat.dgl")) | ||
g_rev_feat = dgl.data.load_tensors(os.path.join(args.rev_graph_path, "edge_feat.dgl")) | ||
for feat_type in g_orig_feat.keys(): | ||
if "mask" not in feat_type: | ||
assert_almost_equal(g_orig_feat[feat_type].numpy(), | ||
g_rev_feat[feat_type].numpy()[:g_orig.number_of_edges(DEFAULT_ETYPE)]) | ||
else: | ||
assert_almost_equal(g_rev_feat[feat_type].numpy()[g_orig.number_of_edges(DEFAULT_ETYPE):], | ||
[0] * g_orig.number_of_edges(DEFAULT_ETYPE)) | ||
|
||
if __name__ == '__main__': | ||
argparser = argparse.ArgumentParser("Check edge prediction remapping") | ||
argparser.add_argument("--orig-graph-path", type=str, default="/tmp/movielen_100k_train_val_1p_4t_homogeneous/part0/", | ||
help="Path to save the generated data") | ||
argparser.add_argument("--rev-graph-path", type=str, default="/tmp/movielen_100k_train_val_1p_4t_homogeneous_rev/part0/", | ||
help="Path to save the generated data") | ||
|
||
args = argparser.parse_args() | ||
|
||
check_reverse_edge(args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
|
||
service ssh restart | ||
|
||
GS_HOME=$(pwd) | ||
NUM_TRAINERS=4 | ||
export PYTHONPATH=$GS_HOME/python/ | ||
cd $GS_HOME/training_scripts/gsgnn_np | ||
echo "127.0.0.1" > ip_list.txt | ||
cd $GS_HOME/training_scripts/gsgnn_ep | ||
echo "127.0.0.1" > ip_list.txt | ||
|
||
error_and_exit () { | ||
# check exec status of launch.py | ||
status=$1 | ||
echo $status | ||
|
||
if test $status -ne 0 | ||
then | ||
exit -1 | ||
fi | ||
} | ||
|
||
|
||
echo "********* Test Homogeneous Graph Optimization ********" | ||
python3 -m graphstorm.gconstruct.construct_graph --conf-file $GS_HOME/tests/end2end-tests/data_gen/movielens_homogeneous.json --num-processes 1 --output-dir /tmp/movielen_100k_train_val_1p_4t_homogeneous --graph-name movie-lens-100k | ||
error_and_exit $? | ||
|
||
echo "********* Test Node Classification on GConstruct Homogeneous Graph ********" | ||
python3 -m graphstorm.run.gs_node_classification --workspace $GS_HOME/training_scripts/gsgnn_np/ --num-trainers $NUM_TRAINERS --num-servers 1 --num-samplers 0 --part-config /tmp/movielen_100k_train_val_1p_4t_homogeneous/movie-lens-100k.json --ip-config ip_list.txt --ssh-port 2222 --cf ml_nc.yaml --target-ntype _N | ||
error_and_exit $? | ||
|
||
echo "********* Test Edge Classification on GConstruct Homogeneous Graph ********" | ||
python3 -m graphstorm.run.gs_edge_classification --workspace $GS_HOME/training_scripts/gsgnn_ep/ --num-trainers $NUM_TRAINERS --num-servers 1 --num-samplers 0 --part-config /tmp/movielen_100k_train_val_1p_4t_homogeneous/movie-lens-100k.json --ip-config ip_list.txt --ssh-port 2222 --cf ml_ec.yaml --target-etype _N,_E,_N | ||
error_and_exit $? | ||
|
||
echo "********* Test Homogeneous Graph Optimization on reverse edge********" | ||
python3 -m graphstorm.gconstruct.construct_graph --conf-file $GS_HOME/tests/end2end-tests/data_gen/movielens_homogeneous.json --num-processes 1 --output-dir /tmp/movielen_100k_train_val_1p_4t_homogeneous_rev --graph-name movie-lens-100k --add-reverse-edges | ||
error_and_exit $? | ||
|
||
python3 $GS_HOME/tests/end2end-tests/data_process/check_homogeneous.py | ||
error_and_exit $? | ||
|
||
echo "********* Test Node Classification on GConstruct Homogeneous Graph with reverse edge********" | ||
python3 -m graphstorm.run.gs_node_classification --workspace $GS_HOME/training_scripts/gsgnn_np/ --num-trainers $NUM_TRAINERS --num-servers 1 --num-samplers 0 --part-config /tmp/movielen_100k_train_val_1p_4t_homogeneous_rev/movie-lens-100k.json --ip-config ip_list.txt --ssh-port 2222 --cf ml_nc.yaml --target-ntype _N | ||
error_and_exit $? | ||
|
||
echo "********* Test Edge Classification on GConstruct Homogeneous Graph with reverse edge ********" | ||
python3 -m graphstorm.run.gs_edge_classification --workspace $GS_HOME/training_scripts/gsgnn_ep/ --num-trainers $NUM_TRAINERS --num-servers 1 --num-samplers 0 --part-config /tmp/movielen_100k_train_val_1p_4t_homogeneous_rev/movie-lens-100k.json --ip-config ip_list.txt --ssh-port 2222 --cf ml_ec.yaml --target-etype _N,_E,_N | ||
error_and_exit $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters