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

Remove NumPy <2 pin #33

Merged
merged 1 commit into from
Sep 24, 2024
Merged

Conversation

seberg
Copy link
Contributor

@seberg seberg commented Aug 23, 2024

This PR removes the NumPy<2 pin which is expected to work for
RAPIDS projects once CuPy 13.3.0 is released (CuPy 13.2.0 had
some issues preventing the use with NumPy 2).

@seberg seberg added non-breaking Introduces a non-breaking change improvement Improves an existing functionality labels Aug 23, 2024
Copy link
Contributor

@linhu-nv linhu-nv left a comment

Choose a reason for hiding this comment

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

Good to me

@jakirkham jakirkham marked this pull request as ready for review September 24, 2024 19:28
@jakirkham jakirkham requested a review from a team as a code owner September 24, 2024 19:28
@jakirkham jakirkham requested review from jameslamb and removed request for a team September 24, 2024 19:28
Copy link
Member

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

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

It's tough to be confident in this without any CI. But since @linhu-nv was ok merging this I'm ok with it. If this doesn't actually work, we'll find out when CI is eventually added here.

I did at least try the ruff NumPy 2 rule, and saw some deprecations but no uses of fully-removed APIs.

ruff check --select NPY .

Just 10 variations of this:

python/cugraph-dgl/cugraph_dgl/tests/test_graph.py:35:11: NPY002 Replace legacy `np.random.random` call with `np.random.Generator`
full logs (click me)
python/cugraph-dgl/cugraph_dgl/tests/test_graph.py:35:11: NPY002 Replace legacy `np.random.random` call with `np.random.Generator`
   |
33 |     df.src = df.src.astype("int64")
34 |     df.dst = df.dst.astype("int64")
35 |     wgt = np.random.random((len(df),))
   |           ^^^^^^^^^^^^^^^^ NPY002
36 | 
37 |     graph = cugraph_dgl.Graph()
   |

python/cugraph-dgl/cugraph_dgl/tests/test_graph.py:39:14: NPY002 Replace legacy `np.random.random` call with `np.random.Generator`
   |
37 |     graph = cugraph_dgl.Graph()
38 |     num_nodes = max(df.src.max(), df.dst.max()) + 1
39 |     node_x = np.random.random((num_nodes,))
   |              ^^^^^^^^^^^^^^^^ NPY002
40 | 
41 |     graph.add_nodes(
   |

python/cugraph-dgl/cugraph_dgl/tests/test_graph.py:112:16: NPY002 Replace legacy `np.random.random` call with `np.random.Generator`
    |
110 |     num_nodes_group_2 = total_num_nodes - num_nodes_group_1
111 | 
112 |     node_x_1 = np.random.random((num_nodes_group_1,))
    |                ^^^^^^^^^^^^^^^^ NPY002
113 |     node_x_2 = np.random.random((num_nodes_group_2,))
    |

python/cugraph-dgl/cugraph_dgl/tests/test_graph.py:113:16: NPY002 Replace legacy `np.random.random` call with `np.random.Generator`
    |
112 |     node_x_1 = np.random.random((num_nodes_group_1,))
113 |     node_x_2 = np.random.random((num_nodes_group_2,))
    |                ^^^^^^^^^^^^^^^^ NPY002
114 | 
115 |     graph.add_nodes(num_nodes_group_1, {"x": node_x_1}, "type1")
    |

python/cugraph-dgl/cugraph_dgl/tests/test_graph_mg.py:46:11: NPY002 Replace legacy `np.random.random` call with `np.random.Generator`
   |
44 |     df.src = df.src.astype("int64")
45 |     df.dst = df.dst.astype("int64")
46 |     wgt = np.random.random((len(df),))
   |           ^^^^^^^^^^^^^^^^ NPY002
47 | 
48 |     graph = cugraph_dgl.Graph(
   |

python/cugraph-dgl/cugraph_dgl/tests/test_graph_mg.py:166:31: NPY002 Replace legacy `np.random.random` call with `np.random.Generator`
    |
164 |     num_nodes_group_2 = total_num_nodes - num_nodes_group_1
165 | 
166 |     node_x_1 = np.array_split(np.random.random((num_nodes_group_1,)), world_size)[rank]
    |                               ^^^^^^^^^^^^^^^^ NPY002
167 |     node_x_2 = np.array_split(np.random.random((num_nodes_group_2,)), world_size)[rank]
    |

python/cugraph-dgl/cugraph_dgl/tests/test_graph_mg.py:167:31: NPY002 Replace legacy `np.random.random` call with `np.random.Generator`
    |
166 |     node_x_1 = np.array_split(np.random.random((num_nodes_group_1,)), world_size)[rank]
167 |     node_x_2 = np.array_split(np.random.random((num_nodes_group_2,)), world_size)[rank]
    |                               ^^^^^^^^^^^^^^^^ NPY002
168 | 
169 |     graph.add_nodes(num_nodes_group_1, {"x": node_x_1}, "type1")
    |

python/cugraph-pyg/cugraph_pyg/tests/data/test_dask_graph_store_mg.py:404:9: NPY002 Replace legacy `np.random.randint` call with `np.random.Generator`
    |
402 | def test_cugraph_loader_large_index(dask_client):
403 |     large_index = (
404 |         np.random.randint(0, 1_000_000, (100_000_000,)),
    |         ^^^^^^^^^^^^^^^^^ NPY002
405 |         np.random.randint(0, 1_000_000, (100_000_000,)),
406 |     )
    |

python/cugraph-pyg/cugraph_pyg/tests/data/test_dask_graph_store_mg.py:405:9: NPY002 Replace legacy `np.random.randint` call with `np.random.Generator`
    |
403 |     large_index = (
404 |         np.random.randint(0, 1_000_000, (100_000_000,)),
405 |         np.random.randint(0, 1_000_000, (100_000_000,)),
    |         ^^^^^^^^^^^^^^^^^ NPY002
406 |     )
    |

python/cugraph-pyg/cugraph_pyg/tests/data/test_dask_graph_store_mg.py:408:22: NPY002 Replace legacy `np.random.randint` call with `np.random.Generator`
    |
406 |     )
407 | 
408 |     large_features = np.random.randint(0, 50, (1_000_000,))
    |                      ^^^^^^^^^^^^^^^^^ NPY002
409 |     F = cugraph.gnn.FeatureStore(backend="torch")
410 |     F.add_data(large_features, "N", "f")
    |

Found 10 errors.

Probably worth rolling that out across RAPIDS to get ahead of those things being removed in future NumPy versions. But that doesn't have to block this PR.

@jakirkham
Copy link
Member

Thanks James! 🙏

For NumPy 2 specifically, we have used the NPY201 rule, which this passes

That said, Ruff includes a few NumPy rules (using NPY would include all of them). These look worthwhile to check as well

Agree it is worth adding these across RAPIDS. For planning & discussion, have opened issue: rapidsai/build-planning#103

@jakirkham jakirkham merged commit 6a93e54 into rapidsai:branch-24.10 Sep 24, 2024
@jakirkham
Copy link
Member

Going to go ahead and merge as this has been approved

As James notes, we will only know if there are issues once there is CI. That said, this will make it easier to test NumPy 2 on CI to learn those issues early on (so we will have time to work through them)

@seberg seberg deleted the my_new_branch branch September 25, 2024 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improves an existing functionality non-breaking Introduces a non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants