Skip to content
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

Fix ParMETIS call so it uses all workers in cluster. #877

Merged
merged 2 commits into from
Jun 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions python/graphstorm/gpartition/metis_partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
import json
import subprocess
import sys
import shutil

from .partition_algo_base import LocalPartitionAlgorithm
from .partition_config import ParMETISConfig


class ParMetisPartitionAlgorithm(LocalPartitionAlgorithm):
Expand All @@ -42,7 +44,7 @@ class ParMetisPartitionAlgorithm(LocalPartitionAlgorithm):
Configuration object for ParMETIS.
"""

def __init__(self, metadata_dict, metis_config):
def __init__(self, metadata_dict: dict, metis_config: ParMETISConfig):
super().__init__(metadata_dict)
self.metis_config = metis_config

Expand All @@ -69,8 +71,20 @@ def _launch_preprocess(self, num_parts, input_path, ip_list, dgl_tool_path, meta
--schema_file {metadata_filename} \
--output_dir {input_path} --num_parts {num_parts}"


thvasilo marked this conversation as resolved.
Show resolved Hide resolved
if self.run_command(command, "preprocess"):
logging.info("Successfully execute parmetis preprocess.")
# parmetis_preprocess.py creates this file, but doesn't put it in the cwd,
# where the parmetis program (pm_dglpart) expects it to be.
# So we copy it here.
thvasilo marked this conversation as resolved.
Show resolved Hide resolved
with open(os.path.join(input_path, metadata_filename), encoding="utf-8") as f:
graph_meta = json.load(f)
graph_name = graph_meta["graph_name"]
shutil.copy(
os.path.join(input_path, f"{graph_name}_stats.txt"),
f"{graph_name}_stats.txt",
)

logging.info("Successfully executed parmetis preprocess.")
return True
else:
logging.info("Failed to execute parmetis preprocess.")
Expand All @@ -93,7 +107,9 @@ def _launch_parmetis(self, num_parts, input_path, ip_list, graph_name):
"""
assert os.path.exists(os.path.expanduser("~/local/bin/pm_dglpart")), \
"pm_dglpart not found in ~/local/bin/"
command = f"mpirun -np 1 --allow-run-as-root \
# TODO: ParMETIS also claims to support num_workers != num_parts, we can test
# if it's possible to speed the process up by using more workers than partitions
command = f"mpirun -np {num_parts} --allow-run-as-root \
--hostfile {ip_list} \
--mca orte_base_help_aggregate 0 -mca btl_tcp_if_include eth0 \
-wdir {input_path} \
Expand Down
Loading