Skip to content

Make cuBLASLt descriptor wrappers move-safe#3078

Open
fallintoplace wants to merge 1 commit into
NVIDIA:mainfrom
fallintoplace:agent/fix-cublaslt-move-safety
Open

Make cuBLASLt descriptor wrappers move-safe#3078
fallintoplace wants to merge 1 commit into
NVIDIA:mainfrom
fallintoplace:agent/fix-cublaslt-move-safety

Conversation

@fallintoplace

Copy link
Copy Markdown

Summary

  • make the cuBLASLt matrix layout and matmul descriptor wrappers move-safe
  • transfer descriptor ownership explicitly on move construction and move assignment
  • make moved-from wrappers null-safe on destruction
  • add focused tests that verify each wrapper transfers its raw handle and nulls the source on move

Why

These wrappers own raw cublasLt* descriptors and destroy them in their destructors, but their move constructor and move assignment operator were defaulted. That meant moving a wrapper copied the raw handle into the destination without clearing the source, so both objects believed they owned the same descriptor.

Impact

This closes a double-destroy hazard in any path that moves or move-assigns these wrappers, including code that caches or returns compound matmul descriptor objects.

Root cause

The wrapper types were acting like RAII owners while still using raw-pointer default move semantics.

Validation

  • git diff --check
  • attempted PARALLEL_LEVEL=8 ./build.sh tests -n --limit-tests=LINALG_TEST
  • local build is blocked here because nvcc is not installed and CMake cannot resolve CUDAToolkit_ROOT

@copy-pr-bot

copy-pr-bot Bot commented Jul 8, 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 8, 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: 1b39f329-b81e-438b-b803-10495f262fdc

📥 Commits

Reviewing files that changed from the base of the PR and between c515501 and 2b09036.

📒 Files selected for processing (3)
  • cpp/include/raft/linalg/detail/cublaslt_wrappers.hpp
  • cpp/tests/CMakeLists.txt
  • cpp/tests/linalg/cublaslt_wrappers.cpp

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved ownership handling for cuBLASLt wrapper objects during moves, reducing the risk of double-destruction and invalid handle cleanup.
    • Destructors now safely skip cleanup when no handle is present.
  • Tests

    • Added unit coverage for move construction and move assignment of the cuBLASLt matrix layout and matmul descriptor wrappers.
    • Included the new test file in the test build configuration.

Walkthrough

Updates cuBLASLt handle-wrapper structs to use explicit noexcept move constructors and move-assignment operators via std::exchange, with destructors that conditionally destroy only when the handle pointer is non-null. Adds a new gtest test file validating this move behavior and registers it in the CMake test build.

Changes

cuBLASLt RAII Move Semantics

Layer / File(s) Summary
Move semantics and conditional destruction
cpp/include/raft/linalg/detail/cublaslt_wrappers.hpp
Replaces defaulted move constructor/assignment with explicit noexcept implementations using std::exchange for cublastlt_matrix_layout and cublastlt_matmul_desc; destructors now only destroy the handle when non-null.
Move behavior tests and build wiring
cpp/tests/linalg/cublaslt_wrappers.cpp, cpp/tests/CMakeLists.txt
New test file adds four gtest cases validating move construction and move assignment ownership transfer for both wrapper types; CMake test list updated to build the new file under LINALG_TEST.

Estimated code review effort: 2 (Simple) | ~15 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: making the cuBLASLt wrappers move-safe.
Description check ✅ Passed The description matches the patch and explains the move-safety fix, tests, and validation.
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant