Skip to content

Fix lanczos launch grid - #3109

Merged
rapids-bot[bot] merged 2 commits into
NVIDIA:mainfrom
achirkin:fix-lanczos-kernel-grid
Aug 12, 2026
Merged

Fix lanczos launch grid#3109
rapids-bot[bot] merged 2 commits into
NVIDIA:mainfrom
achirkin:fix-lanczos-kernel-grid

Conversation

@achirkin

Copy link
Copy Markdown
Contributor

Fix accidentally swapped block size and grid size arguments.

#3104 (comment)

@achirkin achirkin self-assigned this Aug 11, 2026
@achirkin achirkin added the bug Something isn't working label Aug 11, 2026
@achirkin
achirkin requested a review from a team as a code owner August 11, 2026 11:32
@achirkin achirkin added the non-breaking Non-breaking change label Aug 11, 2026
@achirkin achirkin moved this to In Progress in Unstructured Data Processing Aug 11, 2026
@achirkin
achirkin requested a review from lowener August 11, 2026 11:33
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Corrected GPU processing dimensions for sparse matrix operations.
    • Improved kernel launch configuration to ensure reliable triangular-matrix population and beta-column updates.
  • Chores

    • Updated copyright attribution to include NVIDIA Corporation and affiliates.

Walkthrough

The patch updates the SPDX attribution and corrects CUDA grid-dimension calculations and kernel launch argument ordering in the Lanczos solver.

Changes

Lanczos CUDA corrections

Layer / File(s) Summary
Correct CUDA grid and launch configuration
cpp/include/raft/sparse/solver/detail/lanczos.cuh
The code uses raft::div_rounding_up_safe for grid calculations. The triangular population kernel now receives grid size before block size. The optional beta-kernel launch uses the same safe calculation. The SPDX attribution includes NVIDIA Corporation and affiliates.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: lowener

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely identifies the main change: fixing the Lanczos kernel launch grid.
Description check ✅ Passed The description directly explains that the pull request corrects swapped block size and grid size arguments.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
cpp/include/raft/sparse/solver/detail/lanczos.cuh (1)

160-166: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Include raft/util/integer_utils.hpp directly.

lanczos.cuh uses raft::div_rounding_up_safe but does not include its defining header. Add the direct include.

🤖 Prompt for 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.

In `@cpp/include/raft/sparse/solver/detail/lanczos.cuh` around lines 160 - 166,
Add a direct include of raft/util/integer_utils.hpp in lanczos.cuh so the
visible uses of raft::div_rounding_up_safe are backed by their defining header;
leave the surrounding kernel launch and block calculations unchanged.
🤖 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 `@cpp/include/raft/sparse/solver/detail/lanczos.cuh`:
- Around line 160-166: Before the kernel launches in the Lanczos setup path, add
RAFT_EXPECTS validation that enforces n_components + 1 < ncv and rejects k >=
ncv, ensuring invalid dimensions cannot produce zero-block launches or
out-of-bounds writes in kernel_triangular_beta_k.
- Around line 162-168: Add immediate CUDA error checks after both visible kernel
launches in the surrounding Lanczos flow: insert
RAFT_CUDA_TRY(cudaGetLastError()) directly after the triangular beta kernel
launch and the preceding kernel launch, preserving the existing conditional
structure and launch behavior.

---

Nitpick comments:
In `@cpp/include/raft/sparse/solver/detail/lanczos.cuh`:
- Around line 160-166: Add a direct include of raft/util/integer_utils.hpp in
lanczos.cuh so the visible uses of raft::div_rounding_up_safe are backed by
their defining header; leave the surrounding kernel launch and block
calculations unchanged.
🪄 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: 7a885499-e115-4b9c-8dfd-55f2cd9dd8d9

📥 Commits

Reviewing files that changed from the base of the PR and between d254b0e and 8ad66c7.

📒 Files selected for processing (1)
  • cpp/include/raft/sparse/solver/detail/lanczos.cuh

Comment thread cpp/include/raft/sparse/solver/detail/lanczos.cuh Outdated
Comment thread cpp/include/raft/sparse/solver/detail/lanczos.cuh

@divyegala divyegala left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you please add a regression test?

@achirkin

Copy link
Copy Markdown
Contributor Author

I did want to add it, but apparently any possible configuration is valid - just slow (low residency)

@aamijar aamijar changed the title Fix lancsoz launch grid Fix lanczos launch grid Aug 11, 2026

@aamijar aamijar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good catch!

@achirkin

Copy link
Copy Markdown
Contributor Author

/merge

@rapids-bot
rapids-bot Bot merged commit 0960271 into NVIDIA:main Aug 12, 2026
81 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working non-breaking Non-breaking change

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants