Repository navigation
Fix intermittent NaNs from ldiv! with a transposed right-hand side on CUDA 12.0-12.2 - #3392
Merged
Merged
Conversation
With a transposed right-hand side, `cusparseSpSM_solve` from cuSPARSE 12.0 and 12.1 (CUDA 12.0-12.2) reads parts of the workspace that the analysis doesn't write. A fresh workspace from the memory pool can hold stale data, and when that contains NaNs, so does the solution: out-of-place `ldiv!(C, triangular(A), transpose(B))` intermittently returned NaN on the CUDA 12.0 CI job. Zero the workspace on those versions. The same bug is why Float32 and ComplexF32 out-of-place solves were skipped on CUDA 12.0-12.2, so run those again.
The test compared the untouched B and dB, instead of the D and dD that ldiv! solves into.
Contributor
CUDA.jl BenchmarksDetails
This comment was automatically generated by workflow using github-action-benchmark. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3392 +/- ##
==========================================
- Coverage 86.36% 84.97% -1.39%
==========================================
Files 192 191 -1
Lines 19525 19243 -282
==========================================
- Hits 16862 16352 -510
- Misses 2663 2891 +228 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cuSPARSE 12.0 and 12.1 (CUDA 12.0-12.2) have a bug in
cusparseSpSM_solvewith a transposed B: it reads part of the workspace thatcusparseSpSM_analysisnever writes (compute-sanitizer initcheck flagsspsm_v1_kernel). If the pooled workspace holds stale NaNs, the solution comes out NaN. That is the intermittentlib/cusparse/test/interfaces/ldiv.jl:70failure on the CUDA 12.0 job since #3314, which only changed what the pool happened to contain. With the workspace filled with 0x00 the result is always correct, and with 0xff it is always NaN. cuSPARSE 12.2.0 (CUDA 12.3) and later aren't affected.On the affected versions,
sm!now zeroes the workspace before the analysis. The same bug explains the "library bug" skip of Float32/ComplexF32 out-of-place solves on CUDA 12.0-12.2, so that skip is removed. A new test frees NaN-filled buffers to the pool before solving, and fails reliably without the fix on CUDA 12.0.Separately, the in-place
ldiv! -- CuMatrixtest compared the untouchedBanddB. It now checks the solvedDanddD.