Repository navigation
Clear the output of sparse products when beta is zero - #702
Merged
Merged
Conversation
maleadt
force-pushed
the
tb/sparse-csc-nan
branch
from
October 16, 2026 06:50
21f2859 to
6f90b0d
Compare
`mul!` ignores the output when beta is zero, and its callers pass uninitialized memory from `similar`. oneMKL computes beta * y regardless in some cases: gemv with a transposed CSR matrix on oneMKL 2026.1, and gemm with any op on the older release of the Aurora LTS stack. NaNs from the allocator then end up in the result. This made `oneSparseMatrixCSC * x`, which runs as a transposed product on the CSR handle of the transpose, fail intermittently. Zero the output before every oneMKL call that takes a beta when beta is zero, rather than tracking which op and release get it right.
maleadt
force-pushed
the
tb/sparse-csc-nan
branch
from
October 16, 2026 07:06
6f90b0d to
0e27ce6
Compare
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.
oneMKL computes
beta * yin some sparse products even whenbetais zero, so NaNs in the output buffer end up in the result: gemv with a transposed CSR matrix (op'T'or'C') on oneMKL 2026.1, and gemm with any op on the older oneMKL of the Aurora LTS stack.mul!has to ignore the output whenbetais zero, and*passes it uninitialized memory fromsimilar.oneSparseMatrixCSCis stored as the CSR handle of its transpose, sooneSparseMatrixCSC * xruns exactly this transposed product. Depending on what the allocator hands out, it returns NaN in rows that should be 0. This is the intermittentoneMKL.oneSparseMatrixCSCfailure in GPUArrays.jl's downstream CI (e.g.onemkl.jl:1289,:1321, varying from run to run).transpose(::oneSparseMatrixCSR) * xand complexadjoint(::oneSparseMatrixCSR) * xare affected too.Minimal reproducer (oneMKL 2026.1, Iris Xe): a 4x3 CSR matrix with an empty row and column,
alpha = 1,beta = 0, op'T'. Withyprefilled with NaN the result is all NaN; prefilled with 42 it is correct, soyis scaled bybeta, not skipped. On 2026.1, non-transposed CSR gemv, COO gemv and sparse gemm handlebeta = 0correctly, but the first CI run of this PR showed gemm getting it wrong on the LTS stack.This PR zeroes the output before every oneMKL call that takes a
beta(gemv, gemm, symv, trmv) whenbetais zero, rather than tracking which op and release get it right, and adds a regression test that multiplies into NaN-filled outputs for CSR and CSC with identity, transpose and adjoint. The test fails on main (2 of 12 cases for Float32, 3 of 12 for ComplexF32) and passes with the fix. The full SPARSE testset passes as well. Float64 is untested because the test GPU has no fp64.Upstream bug: #703.