Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BiCGStab Fails Silently #298

Closed
packquickly opened this issue May 3, 2023 · 2 comments · Fixed by #334
Closed

BiCGStab Fails Silently #298

packquickly opened this issue May 3, 2023 · 2 comments · Fixed by #334

Comments

@packquickly
Copy link

In #297 I mentioned that GMRES was failing silently from stagnation. Turns out BiCGStab is also failing silently from (some form of) breakdown.

Not so surprising that this fails given how I'm (mis)using the algorithm, but the failure should not be silent. Indeed, in Krylov.jl it is not silent, as Krylov.jl returns extra information which indicates the algorithm did not converge. But when called from LinearSolve.jl this information is lost and the failure becomes silent. This is also an issue in IterativeSolvers.jl where the failure is silent (see: JuliaLinearAlgebra/IterativeSolvers.jl#338).

Reproducing code for Krylov:

import LinearSolve: KrylovJL_BICGSTAB, LinearProblem, solve 
import LinearAlgebra: cond, norm

for problem_dim in [25, 100]
    succeeded = 0
    for i = 1:100 
        condition_number = Inf
        matrix = nothing
        while condition_number > 1000
            matrix = randn(Float64, (problem_dim, problem_dim))
            condition_number = cond(matrix)
        end

        true_vec = randn(Float64, (problem_dim,))
        b = matrix * true_vec

        prob = LinearProblem(matrix, b)

        julia_soln = solve(prob, KrylovJL_BICGSTAB())

        residual_norm = norm(julia_soln - true_vec)

        succeeded += (residual_norm < 1)  # very loose tolerance!
    end
    println("problem dim: $problem_dim. succeeded: $succeeded")
end
@ChrisRackauckas
Copy link
Member

Thanks for pointing this out. Are you following this up with PR?

@packquickly
Copy link
Author

No, I don't plan to.

ChrisRackauckas added a commit that referenced this issue Jun 18, 2023
This solves #297. KrylovKit.jl already throws `ReturnCode.Failure` if it doesn't converge, IterativeSolvers.jl doesn't have it possible, and now Krylov.jl is using retcodes. So now nothing is silent on non-convergence when it's possible to be known from the solver. This also fixes #298
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 a pull request may close this issue.

2 participants