Validate precomputed pairwise kernel shapes - #8441
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
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
Walkthrough
ChangesPrecomputed kernel validation
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Comment |
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/metrics/pairwise_kernels.py`:
- Around line 286-297: Update the pairwise_kernels docstring’s
metric="precomputed" section to document that omitted Y requires square X, while
supplied Y permits X shaped (n_queries, n_indexed) with X.shape[1] equal to
Y.shape[0]. State that validation uses only Y.shape[0], and remove the claim
that Y is ignored.
🪄 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: a671fdde-4a64-44e3-8a30-283d4c5d88b8
📒 Files selected for processing (2)
python/cuml/cuml/metrics/pairwise_kernels.pypython/cuml/tests/test_kernel_ridge.py
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/metrics/pairwise_kernels.py`:
- Around line 209-220: Update the Y parameter documentation in the
pairwise-kernel API to state that the feature-array restriction applies only to
non-precomputed metrics; for metric="precomputed", document that Y is used only
for its first dimension to validate rectangular X inputs, without constraining
its values or second dimension.
🪄 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: c49d188f-692d-4e4b-91e3-0007f2a67d0b
📒 Files selected for processing (1)
python/cuml/cuml/metrics/pairwise_kernels.py
viclafargue
left a comment
There was a problem hiding this comment.
Thanks! Just one non-blocking request. Otherwise looks good to me.
| if X.shape[1] != Y.shape[1]: | ||
| raise ValueError("X and Y have different dimensions.") |
There was a problem hiding this comment.
Could we add a regression test confirming that non-precomputed kernels still reject X and Y with different feature dimensions? This check was moved by the PR and isn’t currently covered.
|
@viclafargue Can you add appropriate labels, please? |
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/tests/test_kernel_ridge.py`:
- Line 139: Update the pytest.raises match pattern in the kernel ridge test to
escape the final period, using a raw regular-expression string so the assertion
matches the literal error message.
🪄 Autofix
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: 9b31ff4c-8857-485b-95c1-f086292a7bf1
📒 Files selected for processing (1)
python/cuml/tests/test_kernel_ridge.py
Summary
The previous validation compared feature widths before recognizing
metric="precomputed", allowing malformed kernel matrices through or rejecting valid cross-kernel shapes with misleading errors.Testing
pre-commit run --files python/cuml/cuml/metrics/pairwise_kernels.py python/cuml/tests/test_kernel_ridge.pypython3 -m py_compile python/cuml/cuml/metrics/pairwise_kernels.py python/cuml/tests/test_kernel_ridge.py