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

[REVIEW] Adapt to changes in cudf.core.buffer.Buffer #5154

Merged
merged 11 commits into from
Jan 26, 2023

Conversation

galipremsagar
Copy link
Contributor

This PR adapts to the breaking changes being introduced in: rapidsai/cudf#12587

@galipremsagar galipremsagar requested a review from a team as a code owner January 24, 2023 17:18
@github-actions github-actions bot added the Cython / Python Cython or Python issue label Jan 24, 2023
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.

Looks right to me.

@@ -255,7 +255,7 @@ def __init__(self,
self._mem_type = GlobalSettings().memory_type

try:
data = data.ptr
data = data.get_ptr()
Copy link
Contributor

Choose a reason for hiding this comment

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

This is correct (cuml is taking ownership of the buffer, so we can't do anything), but I think this is an impossible branch? How could we get here given that if data is a Buffer that exposes get_ptr then it also has a __cuda_array_interface__ property so we'll never end up in this branch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, we will never branch for a Buffer to this part of the code. Reverted the change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can a cuml-ite cast some light on what is meant to be going on in this function? I think that this patch:

diff --git a/python/cuml/internals/array.py b/python/cuml/internals/array.py
index 808b92fe3..f9386ee8a 100644
--- a/python/cuml/internals/array.py
+++ b/python/cuml/internals/array.py
@@ -242,9 +242,7 @@ class CumlArray():
                             'Must specify dtype when data is passed as a'
                             ' {}'.format(type(data))
                         )
-                if isinstance(data, (CudfBuffer, DeviceBuffer)):
-                    self._mem_type = MemoryType.device
-                elif mem_type is None:
+                if mem_type is None:
                     if GlobalSettings().memory_type in (
                         None, MemoryType.mirror
                     ):
@@ -254,13 +252,6 @@ class CumlArray():
                         )
                     self._mem_type = GlobalSettings().memory_type
 
-                try:
-                    data = data.ptr
-                    if shape is None:
-                        shape = (data.size,)
-                    self._owner = data
-                except AttributeError:  # Not a buffer object
-                    pass
                 if isinstance(data, int):
                     self._owner = owner
                 else:

Just deletes unreachable code:

  • Both CudfBuffer and DeviceBuffer advertise a __cuda_array_interface__ property
  • Only CudfBuffer and DeviceBuffer have a .ptr property

So if data is either a CudfBuffer or a DeviceBuffer then we will never fall through the initial

try:
    data.__cuda_array_interface__
except AttributeError:
   ...

check.

@wphicks can you comment?

Copy link
Contributor

Choose a reason for hiding this comment

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

@wence- Yep, that patch looks right to me. This code was based on an earlier version that did not take advantage of __cuda_array_interface__ at all. To answer the question about what this function is meant to, it helps construct a unified interface for all the data types cuML accepts. This function harvests all the data necessary for the CumlArray to populate a __cuda_array_interface__ or __array_interface__ of its own, even if the original object does not have an array interface.

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks, I'll submit something as a followup, in the interests of keeping Prem's change as small as possible

Copy link
Contributor

Choose a reason for hiding this comment

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

@galipremsagar galipremsagar added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Jan 24, 2023
@galipremsagar galipremsagar requested a review from a team as a code owner January 24, 2023 21:52
@github-actions github-actions bot added the ci label Jan 24, 2023
@galipremsagar galipremsagar added the 5 - DO NOT MERGE Hold off on merging; see PR for details label Jan 25, 2023
Copy link
Member

@dantegd dantegd left a comment

Choose a reason for hiding this comment

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

Code changes look good, just had the comment about the temporary changes

ci/build_cpp.sh Outdated
Comment on lines 10 to 18
LIBCUDF_CHANNEL=$(rapids-get-artifact ci/cudf/pull-request/12587/046025a/cudf_conda_cpp_cuda11_$(arch).tar.gz)

rapids-print-env

rapids-logger "Begin cpp build"

rapids-mamba-retry mambabuild conda/recipes/libcuml
rapids-mamba-retry mambabuild \
--channel "${LIBCUDF_CHANNEL}" \
conda/recipes/libcuml
Copy link
Member

Choose a reason for hiding this comment

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

libcudf is not a depencency of libcuml just for context. These chanes are just temporary to test things, right?

Copy link
Contributor Author

@galipremsagar galipremsagar Jan 25, 2023

Choose a reason for hiding this comment

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

Yup, all the .sh file changes will be reverted before merging this PR. Hence tagged it DO NOT MERGE for now.

Comment on lines 15 to 17
PY_VER=${RAPIDS_PY_VERSION//./}
LIBCUDF_CHANNEL=$(rapids-get-artifact ci/cudf/pull-request/12587/046025a/cudf_conda_cpp_cuda11_$(arch).tar.gz)
CUDF_CHANNEL=$(rapids-get-artifact ci/cudf/pull-request/12587/046025a/cudf_conda_python_cuda11_${PY_VER}_$(arch).tar.gz)
Copy link
Member

Choose a reason for hiding this comment

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

Same question as above. Python cuml does use cudf so it makes more sense, but these seem like temporary changes for testing, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, same as above

Comment on lines 24 to 26
PY_VER=${RAPIDS_PY_VERSION//./}
LIBCUDF_CHANNEL=$(rapids-get-artifact ci/cudf/pull-request/12587/046025a/cudf_conda_cpp_cuda11_$(arch).tar.gz)
CUDF_CHANNEL=$(rapids-get-artifact ci/cudf/pull-request/12587/046025a/cudf_conda_python_cuda11_${PY_VER}_$(arch).tar.gz)
Copy link
Member

Choose a reason for hiding this comment

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

same

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ditto as above

@github-actions github-actions bot removed the ci label Jan 26, 2023
@galipremsagar galipremsagar removed the 5 - DO NOT MERGE Hold off on merging; see PR for details label Jan 26, 2023
@codecov-commenter
Copy link

Codecov Report

Base: 69.26% // Head: 69.07% // Decreases project coverage by -0.20% ⚠️

Coverage data is based on head (ac49d6a) compared to base (de32125).
Patch coverage: 91.11% of modified lines in pull request are covered.

Additional details and impacted files
@@               Coverage Diff                @@
##           branch-23.02    #5154      +/-   ##
================================================
- Coverage         69.26%   69.07%   -0.20%     
================================================
  Files               192      192              
  Lines             12333    12370      +37     
================================================
+ Hits               8543     8544       +1     
- Misses             3790     3826      +36     
Impacted Files Coverage Δ
python/cuml/testing/strategies.py 92.20% <90.47%> (-1.87%) ⬇️
...ing/text/stem/porter_stemmer_utils/suffix_utils.py 91.11% <100.00%> (+0.20%) ⬆️
python/cuml/internals/available_devices.py 64.28% <0.00%> (-21.43%) ⬇️
python/cuml/neighbors/kernel_density.py 72.07% <0.00%> (-15.59%) ⬇️
python/cuml/testing/utils.py 88.13% <0.00%> (-0.90%) ⬇️
python/cuml/internals/array.py 87.94% <0.00%> (-0.20%) ⬇️

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.

@wence- wence- mentioned this pull request Jan 26, 2023
Copy link
Contributor

@wphicks wphicks left a comment

Choose a reason for hiding this comment

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

We should probably investigate the test failure we're seeing here rather than just doing a rerun. It looks like we're getting an incorrect array shape for that test, which could certainly be caused by a change to the CumlArray logic. Could we check to see if this is a regression using the Hypothesis reproducer instructions before merge?

@ajschmidt8
Copy link
Member

(i deleted my /merge comment to un-queue this PR from being merged since it seems like it's still in progress)

@ajschmidt8
Copy link
Member

Admin merging with permission from @dantegd since these failures are unrelated.

@ajschmidt8 ajschmidt8 merged commit f6d72fc into rapidsai:branch-23.02 Jan 26, 2023
jakirkham pushed a commit to jakirkham/cuml that referenced this pull request Feb 27, 2023
This PR adapts to the breaking changes being introduced in: rapidsai/cudf#12587

Authors:
   - GALI PREM SAGAR (https://github.com/galipremsagar)

Approvers:
   - Lawrence Mitchell (https://github.com/wence-)
   - AJ Schmidt (https://github.com/ajschmidt8)
   - Dante Gama Dessavre (https://github.com/dantegd)
rapids-bot bot pushed a commit that referenced this pull request Jul 27, 2024
Noticed while reviewing #5154.

Plus an extra (probably benign) typo-bug while I'm here.

cc @wphicks

Authors:
  - Lawrence Mitchell (https://github.com/wence-)
  - Vyas Ramasubramani (https://github.com/vyasr)

Approvers:
  - William Hicks (https://github.com/wphicks)

URL: #5166
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cython / Python Cython or Python issue improvement Improvement / enhancement to an existing function non-breaking Non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants