Skip to content

Use cuda::std::numeric_limits in LAP kernels instead of passing infinity - #3094

Merged
rapids-bot[bot] merged 2 commits into
NVIDIA:mainfrom
says1117:fix-lap-kernel-numeric-limits
Jul 29, 2026
Merged

Use cuda::std::numeric_limits in LAP kernels instead of passing infinity#3094
rapids-bot[bot] merged 2 commits into
NVIDIA:mainfrom
says1117:fix-lap-kernel-numeric-limits

Conversation

@says1117

Copy link
Copy Markdown
Contributor

Description

The LAP (Linear Assignment Problem) Hungarian-algorithm kernels took the sentinel
"infinity" value — std::numeric_limits<weight_t>::max() — as a host-computed
kernel argument. This was guarded by FIXME comments noting it should switch to
cuda::std::numeric_limits<weight_t>::max() once CUDA 10.2 was the baseline.

That baseline has long been met, so this PR resolves the FIXMEs by computing the
limit on-device instead of threading it through as a parameter.

Changes

  • Drop the weight_t infinity parameter from kernel_rowReduction,
    kernel_columnReduction, kernel_dualUpdate_1, and kernel_dualUpdate_2.
  • Use cuda::std::numeric_limits<weight_t>::max() directly inside those kernels
    (for the running-minimum initializers and the d_sp_min[spid] < infinity guard).
  • Remove the corresponding host-side std::numeric_limits<weight_t>::max()
    arguments at the call sites in lap_functions.cuh.
  • Add #include <cuda/std/limits> and delete the four resolved FIXME comments.

No functional or numerical behavior change — the sentinel value is identical; it is
now sourced on the device rather than passed from the host.

Testing

No new tests are required; this is a non-functional refactor covered by the existing
suite. Verified locally:

  • SOLVERS_TEST builds clean.
  • All 6 Raft.Hungarian* LAP tests pass (IntFloat, IntDouble, IntLong,
    LongFloat, LongDouble, LongLong).

The LAP Hungarian-algorithm kernels took the sentinel infinity (std::numeric_limits<weight_t>::max()) as a host-computed kernel argument, guarded by FIXMEs to switch to cuda::std::numeric_limits once CUDA 10.2 was the baseline. That baseline is long met, so this computes the limit on-device instead.

Drops the infinity parameter from kernel_rowReduction, kernel_columnReduction, kernel_dualUpdate_1 and kernel_dualUpdate_2 and their call sites in lap_functions.cuh, and includes cuda/std/limits.

Verified: SOLVERS_TEST builds clean; all 6 Hungarian LAP tests pass.
@copy-pr-bot

copy-pr-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: ee8b27b8-7e2c-4b29-aca5-6d339dc094f5

📥 Commits

Reviewing files that changed from the base of the PR and between aa9a6d5 and f28f810.

📒 Files selected for processing (2)
  • cpp/include/raft/solver/detail/lap_functions.cuh
  • cpp/include/raft/solver/detail/lap_kernels.cuh

📝 Walkthrough

Summary by CodeRabbit

  • Refactor

    • Improved internal numerical handling in GPU-based assignment solving.
    • Simplified kernel interfaces while preserving existing solver behavior.
  • Chores

    • Updated copyright information to include 2026.
    • Improved portability by using standard CUDA numeric-limit utilities.

Walkthrough

Changes

LAP sentinel cleanup

Layer / File(s) Summary
Kernel sentinel logic
cpp/include/raft/solver/detail/lap_kernels.cuh
Reduction and dual-update kernels remove explicit infinity parameters and use cuda::std::numeric_limits<weight_t>::max() internally.
Kernel launch updates
cpp/include/raft/solver/detail/lap_functions.cuh
initialReduction and dualUpdate omit the removed infinity arguments when launching the updated kernels.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: vyasr, achirkin, cjnolet

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: moving LAP kernels to use cuda::std::numeric_limits instead of passing infinity.
Description check ✅ Passed The description matches the changeset and objectives, covering the kernel parameter removal, device-side limits, and tests.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@says1117

Copy link
Copy Markdown
Contributor Author

Could a maintainer please add the required labels when you get a chance? This is a non-functional refactor (identical sentinel value, just computed on-device), so improvement + non-breaking. Thanks!

@divyegala divyegala added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Jul 29, 2026
@divyegala

Copy link
Copy Markdown
Contributor

/ok to test 22ac277

@divyegala

Copy link
Copy Markdown
Contributor

/merge

@rapids-bot
rapids-bot Bot merged commit 392ad9b into NVIDIA:main Jul 29, 2026
82 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

2 participants