Skip to content

cuSOLVER potrf is not CUDA-graph capturable on CUDA.jl 6.5: no graph replay with vendor dense fronts (T34 step 6, PLAN §2.5) #174

Closed

Description

@michel2323

Found while working on: the chores PR #173 (#164, bench/fact_split.jl), not a task

What: cuSOLVER potrf cannot be captured into a CUDA graph on CUDA.jl 6.5.0 (CUDA runtime 13.4, H200). SDS.vendor_potrf_info! (ext/SparseDirectSolverCUDAExt.jl, device-side info, no host read: the library's regime-C / wide-front path) raises CUSOLVER_STATUS_INTERNAL_ERROR inside CUDA.capture(); cuSOLVER.potrf! raises CaptureError: cannot copy to host memory while capturing a graph. The same calls factor correctly outside capture (info = 0, relative error 2.5e-16 on a 256×256 SPD matrix). Consequence: a refactorization that includes a vendor dense front — the stock DirectSolver regime C with impl = :vendor/:auto, and the fused Cholesky with wides = :host (the default_tuning on sm_70/80/90) — is not graph-capturable; bench/fact_split.jl's graph replay now prints graph capture failed: CUSOLVERError ... CUSOLVER_STATUS_INTERNAL_ERROR on every run (PR #107 had recorded that replay as bit-identical and timing-neutral, on CUDA.jl 5.x). LDLᵀ is unaffected since #170 factors its wide fronts in-kernel on every part.

Reproducer (one process, julia --project=bench):

using CUDA, LinearAlgebra, SparseDirectSolver; const SDS = SparseDirectSolver
n = 256; A0 = (M = randn(n, n); M * M' + n * I); A = CuArray(A0); info = CUDA.zeros(Cint, 2)
SDS.vendor_potrf_info!('L', A, info, 1); CUDA.synchronize()      # fine
copyto!(A, A0); g = CUDA.capture() do; SDS.vendor_potrf_info!('L', A, info, 1); end   # CUSOLVER_STATUS_INTERNAL_ERROR

Why it is out of scope: a property of cuSOLVER under CUDA.jl 6.5 / CUDA 13, found through a bench script; no task owns it. It constrains T34 step 6 and PLAN §2.5 (CUDA-graph replay of refactorize + inverse for n ≲ 1e5): replay is only possible with in-kernel wide fronts (wides = :merged, or the :ka dense fallbacks of T32) or by excluding the vendor calls from the captured range. It does not block T25.

Suggested fix or plan change: before T34 step 6, test whether the cuSOLVER 64-bit API (cusolverDnXpotrf with a user workspace) is capture-safe; if not, make graph replay require in-kernel wides (and document it in bench/ARCH-TUNING.md), and note in bench/fact_split.jl that the graph column needs regime_c_rows large enough that no front takes the vendor path.

Activity

  1. added
    found-by-agent
    performance
    upstream
    on Oct 30, 2026
  2. michel2323 commented on Oct 30, 2026

    @michel2323
    MemberAuthor

    Root cause found with a CUDA.jl-only MWE (H200, CUDA.jl 6.5.0, runtime 13.4, cuSOLVER 12.3.5):

    • Upstream: cuSOLVER 12.3.5 (CUDA 13.4) invalidates a stream capture when cusolverDnSetStream(handle, s) is called while s is being captured: the call returns SUCCESS, cuStreamEndCapture then returns CUDA_ERROR_STREAM_CAPTURE_INVALIDATED (driver log: 900 CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED from cuStreamGetDevResource). Reproduced with raw driver + cuSOLVER calls, no CUDA.capture. cuSOLVER 12.0.4 (CUDA 13.0) and 12.2.0 (CUDA 13.2) do not invalidate; 13.3 untested. cuBLAS is unaffected.
    • Why CUDA.jl 6.x hits it on every cuSOLVER call: CUDA.capture() now captures on a pooled dedicated stream that becomes the task's stream; the first cuSOLVER.dense_handle() inside the capture sees the new stream and calls cusolverDnSetStream during it. CUDA.jl 5.x captured on the task's own stream (already bound), hence PR Performance prototypes: partitioned-inverse solve, split/fused factorization, ordering study (experiments 0/5/6) #107's working replay. Not with_workspace, not potrf: raw cusolverDnDpotrf with everything preallocated, cusolverDnXpotrf, and every capture mode fail alike.
    • Workaround that works (raw potrf, Xpotrf and the vendor_potrf_info!-style path all capture and replay with info = 0, residual ~2.5e-16):
      s = CuStream(; flags = CUDA.STREAM_NON_BLOCKING)
      CUDA.stream!(CUDA.CUSOLVER.dense_handle, s)      # bind the task's handle before the capture
      g = CUDA.capture(f; stream = s)
      Pinning the runtime to 13.2 also works.

    So T34 step 6 / PLAN §2.5 is not blocked by vendor fronts: the CUDA extension's graph replay must bind the cuSOLVER (and for symmetry cuBLAS) handles to the capture stream before capture, until CUDA.jl does that itself or cuSOLVER is fixed. A CUDA.jl issue with the MWE is being filed by the owner.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    found-by-agentperformanceupstream

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions