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

[core][compiled graphs] Adjust overlap algorithm #49005

Closed
wants to merge 4 commits into from

Conversation

ruisearch42
Copy link
Contributor

Why are these changes needed?

Adjust gpu communication overlap algorithm to be less conservative, see details in #48953

Related issue number

Closes #48953

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

Signed-off-by: Rui Qiao <[email protected]>
Signed-off-by: Rui Qiao <[email protected]>
@ruisearch42 ruisearch42 added the go add ONLY when ready to merge, run all tests label Dec 11, 2024
Copy link
Contributor

@stephanie-wang stephanie-wang left a comment

Choose a reason for hiding this comment

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

Sorry, I didn't really understand the upstream/downstream NCCL actors change. Can you either clarify with some examples/comments or see if the suggested change could work instead?

Comment on lines +240 to +241
Check if this is a NCCL write operation that writes to an actor
that is also one of its immediate upstream NCCL actors.
Copy link
Contributor

Choose a reason for hiding this comment

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

I found this logic hard to understand. Reading the issue, would it work if we instead modified this to is_nccl_write_to_peer(self, upstream_actor), and make sure the caller passes in the right actor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(There may be more than one upstream_actors, so we need to pass them all in.)
is_nccl_write_to_upstream_actor is a short hand and makes the caller code more concise. We can change it to the following at caller side (dag_node_operation.py:792) if you find it easier to understand:

Original:
overlapped_schedule[j].is_nccl_write_to_upstream_actor
New:
overlapped_schedule[j].is_nccl_write_to_peer(overlapped_schedule[j].upstream_actors)

@@ -1682,11 +1682,17 @@ def _generate_dag_operation_graph_node(
method_name = exec_task.method_name
actor_handle = dag_node._get_actor_handle()
requires_nccl = dag_node.type_hint.requires_nccl()
downstream_nccl_actors = (
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does downstream_nccl_actors check whether the current node requires NCCL while uspstream_nccl_actors checks whether the upstream node requires NCCL?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if I get the underlying question, for a dag_node with NCCL type hint, downstream_nccl_actors means the actors reading from this NCCL channel, and upstream_nccl_actors means the actors writing to NCCL channels which are input for this dag_node. "downstream" and "upstream" are relative to the dag_node.

@ruisearch42
Copy link
Contributor Author

Sorry, I didn't really understand the upstream/downstream NCCL actors change. Can you either clarify with some examples/comments or see if the suggested change could work instead?

Sure, for the test_torch_tensor_dag.py::test_torch_tensor_nccl_overlap2 example, we have the following overlapped schedule:
compiled_graph_schedulex

For the Actor_520f.send method, its downstream_nccl_actors: {Actor_e171}, its upstream_nccl_actors: {} (No actor is writing to this node using NCCL). Therefore we can overlap (see the red ovals).

Signed-off-by: Rui Qiao <[email protected]>
@ruisearch42
Copy link
Contributor Author

The relax algorithm would deadlock for 5d35b71
See #48953 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go add ONLY when ready to merge, run all tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[core][compiled graphs] Overlap Algorithm Adjustment
3 participants