Warning when using NonlinearSolve.jl with LinearSolve.jl and MINRES

I am experimenting with NonlinearSolve.jl to solve a nonlinear system of equations with a symmetric indefinite Jacobian. I am specifically interested in using MINRES to solve this system. In my code, I’ve not specified any preconditioner, yet I’m receiving the warning:

┌ Warning: minres! doesn't support right preconditioning.
└ @ LinearSolve ~/.julia/packages/LinearSolve/B82H3/src/iterative_wrappers.jl:275

The documentation for NonlinearSolve.jl suggests that no preconditioner is the default. Here is a minimal working example that triggers the warning:

using NonlinearSolve
using LinearSolve

# Yes, this is a linear system...
function f(du, u, p)
    du[1] = u[1] - 1
    du[2] = -u[2] + 1
end

function jvp(Jv, v, u, p)
    Jv .= [v[1]; -v[2]]
end

u0 = [0.0, 0.0]
p = nothing

ff = NonlinearFunction(f; jvp=jvp)
prob = NonlinearProblem(ff, u0, p)
sol = solve(prob, NewtonRaphson(linsolve = KrylovJL_MINRES()))

Why I am getting this warning even though I have not explicitly installed a preconditioner?

Thank you!

@Oscar_Smith is this from the latest changes?

Yes. Will fix. It’s still getting the right answer, but the warning shouldn’t be triggering.

Thanks for confirming that the warning is spurious.

Looking into the code, I see that NonlineearSolve.jl uses the internal function __wrapprecs, which is called by LinearSolverCache and installs default explicit identity preconditioners. Although these identity preconditioners mathematically provide no preconditioning, they inadvertently cause MINRES to incur additional overhead. Would it be feasible to redefine these identity preconditioners as type UniformScaling, which does not result in this overhead?

In the meantime, instead of globally disabling all warnings, is there a way to call solve that would execute the following line of code?

        precs, Pl_, Pr_ = nothing, nothing, nothing

Would that solve the problem?

Thanks again!

I’m using NonlinearSolve.jl v3.14.0.

We did this before for this reason in the wrappers. I didn’t catch that @Oscar_Smith 's latest PR removed it, but we should put that part back.

I believe use LinearSolve precs setup by oscardssmith · Pull Request #462 · SciML/NonlinearSolve.jl · GitHub should fix this (although it still isn’t quite done yet)

Thank you @Oscar_Smith for implementing this fix. I’ll apply your PR onto a fork.

Alternatively, is there a workaround for nullifying the default preconditioner that throws the warning?

yeah I can add a fix on the LinearSolve side