You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When solving a symmetric positive definite system using Krylov.jl with Float16 arithmetic, the Conjugate Residual (CR) and Conjugate Gradient (CG) methods exhibit numerical issues. In our tests, the CR solver returns a vector of NaN values after one iteration, while the CG solver completes after five iterations but reports "Inf" in intermediate quantities and a status of "zero curvature detected." This behavior suggests that the solvers may not handle the low precision of Float16 correctly.
When the linesearch is true.
However my main concern is that the behavior should be similar and CR it returns NAN
Steps to Reproduce
Run the following code in a Julia session, if you switch to Float64 it works fine:
# Test CR and CG with Float16
T = Float16
ϵ =eps(T)^T(1/4)
rtol = ϵ
functionsymmetric_definite(n::Int=10; FC = Float64)
α = FC <:Complex?FC(im) :one(FC)
A =spdiagm(-1=> α *ones(FC, n-1), 0=>4*ones(FC, n), 1=>conj(α) *ones(FC, n-1))
b = A * FC[1:n;]
return A, b
end# Create a symmetric, positive definite system using Float16
A, b =symmetric_definite(FC = T)
# Define tolerances (ensure that rtol and ϵ are defined appropriately for Float16)
subtol =max(rtol, min(T(0.1), √T(1.3e+01), T(0.9) *one(T)))
# Test the CR solver
(x, stats) =cr(A, b, atol = ϵ, rtol = subtol, verbose =1, linesearch =true)
println("CR result:")
println(x, stats)
# Test the CG solver
(x, stats_cg) =cg(A, b, atol = ϵ, rtol = subtol, verbose =1, linesearch =true)
println("CG result:")
println(x, stats_cg)
Observed Output
CR Output:
CR: system of 10 equations in 10 variables
k ‖x‖ ‖r‖ quad timer
0 0.0e+00 1.1e+02 0.0e+00 0.00s
1 NaN NaN NaN 0.00s
CR result:
Float16[NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN]SimpleStats
niter: 1
solved: false
inconsistent: false
residuals: []
Aresiduals: []
κ₂(A): []
timer: 1.13ms
status: solver encountered numerical issues
For a symmetric positive definite system, both the CR and CG methods should converge to a valid solution (with finite values) within the specified tolerances. Although Float16 has limited precision, one would still expect a meaningful solution rather than immediate NaN or Inf results.
Environment
Krylov.jl Version: (e.g., v0.9.10)
Julia Version: (e.g., 1.10+)
Operating System: Windows
Data Type: Float16
The text was updated successfully, but these errors were encountered:
Description
When solving a symmetric positive definite system using Krylov.jl with Float16 arithmetic, the Conjugate Residual (CR) and Conjugate Gradient (CG) methods exhibit numerical issues. In our tests, the CR solver returns a vector of NaN values after one iteration, while the CG solver completes after five iterations but reports "Inf" in intermediate quantities and a status of "zero curvature detected." This behavior suggests that the solvers may not handle the low precision of Float16 correctly.
When the linesearch is true.
However my main concern is that the behavior should be similar and CR it returns NAN
Steps to Reproduce
Run the following code in a Julia session, if you switch to Float64 it works fine:
Observed Output
CR Output:
CG Output:
Expected Behavior
For a symmetric positive definite system, both the CR and CG methods should converge to a valid solution (with finite values) within the specified tolerances. Although Float16 has limited precision, one would still expect a meaningful solution rather than immediate NaN or Inf results.
Environment
The text was updated successfully, but these errors were encountered: