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

Re-implement shuffle using staging #1030

Merged
merged 16 commits into from
Nov 23, 2022

Conversation

madsbk
Copy link
Member

@madsbk madsbk commented Nov 2, 2022

Introduce staging in explicit-comms. The idea is to "stage" the keys of the input on the workers so that a later explicit-comms task can access and free the data associated with the keys.

Notice, explicit-comms and this new staging approach is still experimental. If or when it gets to a state where it provides a significant performance improvements over a range of workflows, the plan is to tighten up the API.

@madsbk madsbk added 2 - In Progress Currently a work in progress improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Nov 2, 2022
@github-actions github-actions bot added the python python code needed label Nov 2, 2022
@codecov-commenter
Copy link

codecov-commenter commented Nov 2, 2022

Codecov Report

❗ No coverage uploaded for pull request base (branch-22.12@f11abe3). Click here to learn what that means.
Patch has no changes to coverable lines.

❗ Current head a721cc6 differs from pull request most recent head 6464eb6. Consider uploading reports for the commit 6464eb6 to get more accurate results

Additional details and impacted files
@@              Coverage Diff               @@
##             branch-22.12   #1030   +/-   ##
==============================================
  Coverage                ?   0.00%           
==============================================
  Files                   ?      18           
  Lines                   ?    2252           
  Branches                ?       0           
==============================================
  Hits                    ?       0           
  Misses                  ?    2252           
  Partials                ?       0           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@wence- wence- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor comments, but no need to act if you feel it doesn't really make sense to.

dask_cuda/explicit_comms/comms.py Outdated Show resolved Hide resolved
dask_cuda/explicit_comms/dataframe/shuffle.py Outdated Show resolved Hide resolved
dask_cuda/explicit_comms/dataframe/shuffle.py Outdated Show resolved Hide resolved
dask_cuda/explicit_comms/dataframe/shuffle.py Outdated Show resolved Hide resolved
dask_cuda/explicit_comms/dataframe/shuffle.py Outdated Show resolved Hide resolved
@madsbk madsbk force-pushed the xcomm_shuffle_staging branch 3 times, most recently from ab2a437 to 169931a Compare November 3, 2022 12:55
@madsbk madsbk changed the title [WIP] Re-implement shuffle using staging Re-implement shuffle using staging Nov 18, 2022
@madsbk madsbk removed the 2 - In Progress Currently a work in progress label Nov 18, 2022
@madsbk madsbk marked this pull request as ready for review November 18, 2022 14:23
@madsbk madsbk requested a review from a team as a code owner November 18, 2022 14:23
Copy link
Contributor

@wence- wence- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly just some queries for understanding, with some relatively minor issues.

TBH: This code is quite hard to follow at this point, though that may be my unfamiliarity with it, especially to do with what is executing where.

@@ -147,6 +148,20 @@ async def _stop_ucp_listeners(session_state):
del session_state["lf"]


async def _stage_keys(session_state: dict, name: str, keys: set):
worker: Worker = session_state["worker"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a docstring here?

dask_cuda/explicit_comms/comms.py Show resolved Hide resolved
dask_cuda/explicit_comms/comms.py Show resolved Hide resolved
Comment on lines +34 to +40
for rank, out_part_ids in rank_to_out_part_ids.items():
if rank != myrank:
msg = {
i: to_serialize(out_part_id_to_dataframe.pop(i))
for i in (out_part_ids & out_part_id_to_dataframe.keys())
}
futures.append(eps[rank].write(msg))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, loop over people we need to communicate with, rather than all endpoints.

dask_cuda/explicit_comms/dataframe/shuffle.py Show resolved Hide resolved
dask_cuda/explicit_comms/dataframe/shuffle.py Show resolved Hide resolved
dask_cuda/explicit_comms/dataframe/shuffle.py Show resolved Hide resolved
Comment on lines +218 to +219
recv(eps, myrank, rank_to_out_part_ids, out_part_id_to_dataframe_list, proxify),
send(eps, myrank, rank_to_out_part_ids, out_part_id_to_dataframe),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A change here is that you don't collect all the futures for all the tasks and gather them at once, but wrap them up in nested asyncio.gather calls. I don't expect this will really change anything substantive about the performance, but just to note.


# Finally, we concatenate the output dataframes into the final output partitions
ret: List[DataFrame] = []
for out_part_id, dataframe_list in out_part_id_to_dataframe_list.items():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for out_part_id, dataframe_list in out_part_id_to_dataframe_list.items():
for dataframe_list in out_part_id_to_dataframe_list.values():

You never needed the id.

So probably a list comprehension here would be simpler:

ret = [
proxify(dd_concat(dfs, ignore_index=ignore_index)) for dfs in out_part_id_to_dataframe_list.values()
]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, fixed in 6464eb6

Comment on lines 310 to 311
rank_to_inkeys = c.stage_keys(name=name, keys=df.__dask_keys__())
c.client.cancel(df) # Notice, since `df` has been staged, nothing is freed here.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This I do not understand. We just copy some keys around here as far as I can tell (and don't persist anything), so I'm not sure what this even does.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added more doc in 7ea9f6f

@madsbk
Copy link
Member Author

madsbk commented Nov 23, 2022

Thanks for the review @wence- !
I think I addressed all of your comments?

Copy link
Contributor

@wence- wence- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the doc updates!

@madsbk
Copy link
Member Author

madsbk commented Nov 23, 2022

rerun tests

@madsbk
Copy link
Member Author

madsbk commented Nov 23, 2022

@gpucibot merge

@rapids-bot rapids-bot bot merged commit 4d725e3 into rapidsai:branch-22.12 Nov 23, 2022
@madsbk madsbk deleted the xcomm_shuffle_staging branch November 24, 2022 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improvement / enhancement to an existing function non-breaking Non-breaking change python python code needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants