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

[ADAG] Add visualization of compiled graphs #47958

Merged
merged 16 commits into from
Oct 24, 2024

Conversation

Bye-legumes
Copy link
Contributor

@Bye-legumes Bye-legumes commented Oct 9, 2024

Why are these changes needed?

#47945

My test case

import ray
import time
import random
from ray.dag.input_node import InputNode
from ray.dag.output_node import MultiOutputNode
ray.init(address = "10.218.163.33:6274")
import os
@ray.remote
class Actor:
    def __init__(self, init_value, fail_after=None, sys_exit=False):
        self.i = init_value
        self.fail_after = fail_after
        self.sys_exit = sys_exit

        self.count = 0


    def echo(self, x):
        self.count += 1
        return x



    def sleep(self, x):
        time.sleep(x)
        return x

    @ray.method(num_returns=2)
    def return_two(self, x):
        return x, x + 1

    def read_input(self, x):
        return x




a = Actor.remote(0)
b = Actor.remote(0)
single_fetch = True
with InputNode() as i:
    o1, o2 = a.return_two.bind(i)
    o3 = b.echo.bind(o1)
    o4 = b.echo.bind(o2)
    dag = MultiOutputNode([o3, o4])

compiled_dag = dag.experimental_compile()
for _ in range(3):
    refs = compiled_dag.execute(1)
    if single_fetch:
        for i, ref in enumerate(refs):
            res = ray.get(ref)
            assert res == i + 1
    else:
        res = ray.get(refs)
        assert res == [1, 2]
compiled_dag.visualize()
compiled_dag.teardown()

plot
image

Related issue number

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: zhilong <zhilong.chen@mail.mcgill.ca>
@Bye-legumes Bye-legumes changed the title add [ADAG] Add visualization of compiled graphs Oct 9, 2024
Signed-off-by: zhilong <zhilong.chen@mail.mcgill.ca>
Signed-off-by: zhilong <zhilong.chen@mail.mcgill.ca>
@rkooo567
Copy link
Contributor

rkooo567 commented Oct 9, 2024

cc @kevin85421 can you take a look?

Copy link
Contributor

@ruisearch42 ruisearch42 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 contribution.

python/ray/dag/compiled_dag_node.py Outdated Show resolved Hide resolved
python/ray/dag/compiled_dag_node.py Outdated Show resolved Hide resolved
python/ray/dag/compiled_dag_node.py Outdated Show resolved Hide resolved
python/ray/dag/compiled_dag_node.py Outdated Show resolved Hide resolved
@kevin85421
Copy link
Member

@ruisearch42 is this different from the visualization function in your overlap PR?

Copy link
Contributor

@ruisearch42 ruisearch42 left a comment

Choose a reason for hiding this comment

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

After addressing these comments, I think we are good to merge!

Over time we can always improve and add more features. This will be very useful.

python/ray/dag/compiled_dag_node.py Outdated Show resolved Hide resolved
python/ray/dag/compiled_dag_node.py Outdated Show resolved Hide resolved
python/ray/dag/compiled_dag_node.py Outdated Show resolved Hide resolved
@ruisearch42
Copy link
Contributor

@ruisearch42 is this different from the visualization function in your overlap PR?

This is to visualize the DAG itself, the overlap PR visualizes the schedule. Both will be useful.

Copy link
Member

@kevin85421 kevin85421 left a comment

Choose a reason for hiding this comment

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

DAG (non-compiled) seems to have visualization support: https://github.com/ray-project/ray/blob/master/python/ray/dag/vis_utils.py.

What's the difference between the existing one and this PR?

python/ray/dag/compiled_dag_node.py Outdated Show resolved Hide resolved
python/ray/dag/compiled_dag_node.py Outdated Show resolved Hide resolved
Signed-off-by: zhilong <zhilong.chen@mail.mcgill.ca>
Signed-off-by: zhilong <zhilong.chen@mail.mcgill.ca>
Signed-off-by: zhilong <zhilong.chen@mail.mcgill.ca>
Signed-off-by: zhilong <zhilong.chen@mail.mcgill.ca>
@Bye-legumes
Copy link
Contributor Author

Hi, @ruisearch42 , I just update it and solved you comments. The new plots is above with different color and shape for different node. The tests are also included.

Signed-off-by: zhilong <zhilong.chen@mail.mcgill.ca>
@Bye-legumes
Copy link
Contributor Author

I suspect that graphviz is not available on the test environment so we need to pip install graphviz and sudo apt-get install graphviz for visualization test. Do you know how we can achieve that? I need to add dependency to which file for pip and apt-get? @ruisearch42

@kevin85421
Copy link
Member

I suspect that graphviz is not available on the test environment so we need to pip install graphviz and sudo apt-get install graphviz for visualization test.

@Bye-legumes maybe you can try to use runtime environment.

Btw, would you mind answering my question here: #47958 (review)? Thanks!

@Bye-legumes
Copy link
Contributor Author

I suspect that graphviz is not available on the test environment so we need to pip install graphviz and sudo apt-get install graphviz for visualization test.

@Bye-legumes maybe you can try to use runtime environment.

Btw, would you mind answering my question here: #47958 (review)? Thanks!

This is for the complied graph with different nodes that we have different node handling for different node for complied graph. Also the data transport method is also included as we have hint. This is the result of that plot.
image

How I can set runtime environment for this test case? Should install packages in the test.py with pip install graphviz and sudo apt-get install graphviz

python/ray/dag/tests/experimental/test_accelerated_dag.py Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

There are test failures for this file. Please fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suspect that graphviz is not available on the test environment so we need to pip install graphviz and sudo apt-get install graphviz for visualization test. Do you know how we can achieve that in the test environments? I need to add dependency to which file for pip and apt-get? @ruisearch42

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can introduce something like a test requirement.txt , something like python/requirements/ml/data-test-requirements.txt
If that is too complex, we can skip the test for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just skip these tests and I think it's OK now.

python/ray/dag/compiled_dag_node.py Outdated Show resolved Hide resolved
python/ray/dag/compiled_dag_node.py Outdated Show resolved Hide resolved
python/ray/dag/compiled_dag_node.py Outdated Show resolved Hide resolved
python/ray/dag/compiled_dag_node.py Outdated Show resolved Hide resolved
Signed-off-by: zhilong <zhilong.chen@mail.mcgill.ca>
Signed-off-by: zhilong <zhilong.chen@mail.mcgill.ca>
@anyscalesam anyscalesam added triage Needs triage (eg: priority, bug/not-bug, and owning component) core Issues that should be addressed in Ray Core compiled-graphs labels Oct 16, 2024
Bye-legumes and others added 3 commits October 22, 2024 14:36
Signed-off-by: zhilong <zhilong.chen@mail.mcgill.ca>
Signed-off-by: zhilong <zhilong.chen@mail.mcgill.ca>
Bye-legumes and others added 2 commits October 23, 2024 11:57
Signed-off-by: zhilong <zhilong.chen@mail.mcgill.ca>
Copy link
Contributor

@ruisearch42 ruisearch42 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 change!

@rkooo567 rkooo567 enabled auto-merge (squash) October 24, 2024 16:03
@github-actions github-actions bot added the go add ONLY when ready to merge, run all tests label Oct 24, 2024
@ruisearch42
Copy link
Contributor

@Bye-legumes Auto merge is enabled, but tests are failing, please fix

@Bye-legumes
Copy link
Contributor Author

@Bye-legumes Auto merge is enabled, but tests are failing, please fix

I see, thx you keep the eye on this! I think this tests failed is not related as other PR also failed on same test. Let me merge the master and check if it will recurs!

@Bye-legumes
Copy link
Contributor Author

@ruisearch42 Hi, I just merged the master and it's OK now!

@ruisearch42
Copy link
Contributor

@rkooo567 to merge

@rkooo567 rkooo567 merged commit adcdfe8 into ray-project:master Oct 24, 2024
5 checks passed
Jay-ju pushed a commit to Jay-ju/ray that referenced this pull request Nov 5, 2024
rkooo567 pushed a commit that referenced this pull request Nov 8, 2024
In #47958 , visualization unit tests were introduced but would not run if CI environment does not have graphvis installed (which was the case).

This PR adds the dependency in test-requirements.txt and always run the visualization tests. It also moves visualization tests to a separate file since test_accelerated_dag.py is too large.
JP-sDEV pushed a commit to JP-sDEV/ray that referenced this pull request Nov 14, 2024
Signed-off-by: JP-sDEV <jon.pablo80@gmail.com>
JP-sDEV pushed a commit to JP-sDEV/ray that referenced this pull request Nov 14, 2024
In ray-project#47958 , visualization unit tests were introduced but would not run if CI environment does not have graphvis installed (which was the case).

This PR adds the dependency in test-requirements.txt and always run the visualization tests. It also moves visualization tests to a separate file since test_accelerated_dag.py is too large.
Signed-off-by: JP-sDEV <jon.pablo80@gmail.com>
mohitjain2504 pushed a commit to mohitjain2504/ray that referenced this pull request Nov 15, 2024
Signed-off-by: mohitjain2504 <mohit.jain@dream11.com>
mohitjain2504 pushed a commit to mohitjain2504/ray that referenced this pull request Nov 15, 2024
In ray-project#47958 , visualization unit tests were introduced but would not run if CI environment does not have graphvis installed (which was the case).

This PR adds the dependency in test-requirements.txt and always run the visualization tests. It also moves visualization tests to a separate file since test_accelerated_dag.py is too large.

Signed-off-by: mohitjain2504 <mohit.jain@dream11.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiled-graphs core Issues that should be addressed in Ray Core go add ONLY when ready to merge, run all tests triage Needs triage (eg: priority, bug/not-bug, and owning component)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants