Skip to content

Zero the output of out-of-place trmm/trsm when beta is zero - #761

Open
maleadt wants to merge 1 commit into
mainfrom
tb/trsm-variant-output
Open

maleadt wants to merge 1 commit into
mainfrom
tb/trsm-variant-output

Conversation

@maleadt

@maleadt maleadt commented Nov 5, 2026

Copy link
Copy Markdown
Member

Fixes the onemkl failure on the ALCF pipeline seen on #760 (ldiv! into a reversed view, test/onemkl.jl:1154), which is a real bug rather than a flaky tolerance.

Unlike gemm, the oneMKL trmm/trsm "variant" routines (C = alpha * op(A) \ B + beta * C, added in #643) don't document that C is left unread when beta == 0, and trsm does read it: NaN garbage in an uninitialized output leaks into the solution. Reproduced on an Arc A770 with a NaN-filled C: trsm! with beta = 0 returns all NaNs, trmm! happens to be fine. That breaks any ldiv!(C, UpperTriangular(A), B) into a fresh array, and the reversed-view path (blas_output solves into similar(C)), which is what the ALCF run hit when similar handed back memory holding NaNs.

The wrappers now fill! C with zeros before calling the variant with beta = 0, for trsm and, since the contract is the same, trmm. Regression tests cover the wrappers (NaN-filled C, all element types) and the mul!/ldiv! dispatch; without the fix they fail for trsm on the A770, with it the onemkl test suite passes.

Unlike gemm, the oneMKL trmm/trsm variants don't document that C is left
unread when beta is zero, and trsm does read it: NaN garbage in an
uninitialized output leaks into the solution. That broke `ldiv!(C, A, B)`
into a fresh array, and the reversed-view tests on the ALCF pipeline,
where `similar` happened to hand back memory holding NaNs.

Fill C with zeros before calling the variant with beta = 0, for trsm and,
since the contract is the same, trmm.

This branch has not been deployed

No deployments
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