Fix KNN neighbor buffer layout bugs - #8393
Conversation
Signed-off-by: nethum529 <nethumweerasinghe.nw@gmail.com>
Signed-off-by: nethum529 <nethumweerasinghe.nw@gmail.com>
Signed-off-by: nethum529 <nethumweerasinghe.nw@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe changes normalize callable KNN weights to C-contiguous ChangesNeighbors layout fixes
Estimated code review effort: 3 (Moderate) | ~25 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
viclafargue
left a comment
There was a problem hiding this comment.
LGTM for the most part, but I have one comment.
Signed-off-by: nethum529 <nethumweerasinghe.nw@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@python/cuml/cuml/neighbors/weights.py`:
- Around line 59-61: Update the callable-weights conversion in weights.py to use
an unconditional allocating CuPy conversion, such as cp.array with copy=True,
while preserving float32 dtype and C order so the resulting pointer is aligned
for kneighbors_regressor.pyx. Add coverage using an unaligned C-contiguous
device-array result from the callable and verify the conversion produces a safe
aligned allocation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: e206c94b-e742-476f-ad69-1d3114bec701
📒 Files selected for processing (2)
python/cuml/cuml/neighbors/weights.pypython/cuml/tests/test_kneighbors_regressor.py
💤 Files with no reviewable changes (1)
- python/cuml/tests/test_kneighbors_regressor.py
|
Pushed the simplification and merged latest upstream main. The whole alignment-handling block is replaced by the one-liner as suggested, and the regression tests pass unchanged since they only assert behavior. |
There was a problem hiding this comment.
Thanks! Please update the PR description to remove the claim that unaligned weights are handled. Otherwise, this looks good to me.
It looks like cuPy can successfully convert and reorder unaligned memory. However, if the type and orders are correct the unaligned pointer is preserved throughout.
|
Will do & Happy to help :) |
|
/ok to test d1c8ef1 |
|
/ok to test 6607a3e |
|
/ok to test 565dcf3 |
Summary
int64before the raw kernel while keeping explicit sparse query results asint32.Testing
14 passedfor the KNN weights test selection.ERROR SUMMARY: 0 errorsfor the unaligned callable path.Fixes #8362