Skip to content

Commit

Permalink
Add changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nv-rliu committed Mar 25, 2024
1 parent fc89f9d commit 3e20748
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
6 changes: 5 additions & 1 deletion python/cugraph/cugraph/dask/common/part_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019-2023, NVIDIA CORPORATION.
# Copyright (c) 2019-2024, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -116,6 +116,10 @@ def persist_dask_df_equal_parts_per_worker(

ddf_keys = dask_df.to_delayed()
workers = client.scheduler_info()["workers"].keys()
worker_to_rank = Comms.rank_to_worker(client)
# assure rank-worker mappings are in ascending order
workers = dict(sorted(worker_to_rank.items())).values()

ddf_keys_ls = _chunk_lst(ddf_keys, len(workers))
persisted_keys_d = {}
for w, ddf_k in zip(workers, ddf_keys_ls):
Expand Down
15 changes: 14 additions & 1 deletion python/cugraph/cugraph/dask/comms/comms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2018-2023, NVIDIA CORPORATION.
# Copyright (c) 2018-2024, NVIDIA CORPORATION.
# 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
Expand Down Expand Up @@ -265,3 +265,16 @@ def get_n_workers(sID=None, dask_worker=None):
dask_worker = get_worker()
sessionstate = get_raft_comm_state(sID, dask_worker)
return sessionstate["nworkers"]


def rank_to_worker(client):
"""
Return a mapping of dask workers to ranks.
"""
workers = client.scheduler_info()["workers"].keys()
worker_info = __instance.worker_info(workers)
rank_to_worker = {}
for w in worker_info:
rank_to_worker[worker_info[w]["rank"]] = w

return rank_to_worker

0 comments on commit 3e20748

Please sign in to comment.