-
Notifications
You must be signed in to change notification settings - Fork 449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feat] Implement the pipeline for loading vineyard graph as graphlearn_torch dataset and training on a single machine #3156
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6de2fb4
[build(learning)] Integrate graphlearn-for-pytorch in graphscope libr…
Zhanghyi 8d6fa0c
[Feat] Implement the pipeline for loading vineyard graph as graphlear…
Zhanghyi df5c4ee
[Feat] support random_node_split for graphlearn_torch
Zhanghyi 38c61ab
[Feat] add parameter check for graphlearn_torch
Zhanghyi fef14d6
fix
Zhanghyi a0d1ac7
update
Zhanghyi 86986cb
[build(learning)] Integrate graphlearn-for-pytorch in graphscope libr…
Zhanghyi b868a76
Merge branch 'gltorch' into gltorch
Zhanghyi 734e17b
update
Zhanghyi d4e7d11
update
Zhanghyi be16b4d
update glt
Zhanghyi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,88 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright 2020 Alibaba Group Holding Limited. All Rights Reserved. | ||
# | ||
# 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 base64 | ||
import logging | ||
import os.path as osp | ||
import pickle | ||
import sys | ||
|
||
import graphscope.learning.graphlearn_torch as glt | ||
import torch | ||
|
||
logger = logging.getLogger("graphscope") | ||
|
||
|
||
def decode_arg(arg): | ||
if isinstance(arg, dict): | ||
return arg | ||
return pickle.loads(base64.b64decode(arg)) | ||
|
||
|
||
def run_server_proc(proc_rank, handle, config, server_rank, dataset): | ||
glt.distributed.init_server( | ||
num_servers=handle["num_servers"], | ||
num_clients=handle["num_clients"], | ||
server_rank=server_rank, | ||
dataset=dataset, | ||
master_addr=handle["master_addr"], | ||
master_port=handle["server_client_master_port"], | ||
num_rpc_threads=16, | ||
# server_group_name="dist_train_supervised_sage_server", | ||
) | ||
logger.info(f"-- [Server {server_rank}] Waiting for exit ...") | ||
glt.distributed.wait_and_shutdown_server() | ||
logger.info(f"-- [Server {server_rank}] Exited ...") | ||
|
||
|
||
def launch_graphlearn_torch_server(handle, config, server_rank): | ||
logger.info(f"-- [Server {server_rank}] Initializing server ...") | ||
|
||
edge_dir = config.pop("edge_dir") | ||
random_node_split = config.pop("random_node_split") | ||
dataset = glt.distributed.DistDataset(edge_dir=edge_dir) | ||
dataset.load_vineyard( | ||
vineyard_id=str(handle["vineyard_id"]), | ||
vineyard_socket=handle["vineyard_socket"], | ||
**config, | ||
) | ||
if random_node_split is not None: | ||
dataset.random_node_split(**random_node_split) | ||
logger.info(f"-- [Server {server_rank}] Initializing server ...") | ||
|
||
torch.multiprocessing.spawn( | ||
fn=run_server_proc, args=(handle, config, server_rank, dataset), nprocs=1 | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) < 3: | ||
logger.info( | ||
"Usage: ./launch_graphlearn_torch.py <handle> <config> <server_index>", | ||
file=sys.stderr, | ||
) | ||
sys.exit(-1) | ||
|
||
handle = decode_arg(sys.argv[1]) | ||
config = decode_arg(sys.argv[2]) | ||
server_index = int(sys.argv[3]) | ||
|
||
logger.info( | ||
f"launch_graphlearn_torch_server handle: {handle} config: {config} server_index: {server_index}" | ||
) | ||
launch_graphlearn_torch_server(handle, config, server_index) |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get ports for train, test and val