<div dir="ltr"><div dir="ltr">On Thu, May 4, 2023 at 8:31 AM Mark Lohry <<a href="mailto:mlohry@gmail.com">mlohry@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div> Please send the output of -snes_view. <br></div></blockquote><div>pasted below. anything stand out?</div></div></blockquote><div><br></div><div>Try -pc_type none. If the first KSP residual is different, then it is something in the MatMFFD, and then I would</div><div>guess it is something variable in the residual evaluation routine. That should be easy to check by printing norms</div><div>of the residual each time it is evaluated.</div><div><br></div><div>  Thanks,</div><div><br></div><div>    Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>SNES Object: 1 MPI process</div>  type: newtonls<br>  maximum iterations=1, maximum function evaluations=-1<br>  tolerances: relative=0.1, absolute=1e-15, solution=1e-15<br>  total number of linear solver iterations=20<br>  total number of function evaluations=22<br>  norm schedule ALWAYS<br>  Jacobian is never rebuilt<br>  Jacobian is applied matrix-free with differencing<br>  Preconditioning Jacobian is built using finite differences with coloring<br>  SNESLineSearch Object: 1 MPI process<br>    type: basic<br>    maxstep=1.000000e+08, minlambda=1.000000e-12<br>    tolerances: relative=1.000000e-08, absolute=1.000000e-15, lambda=1.000000e-08<br>    maximum iterations=40<br>  KSP Object: 1 MPI process<br>    type: gmres<br>      restart=30, using Classical (unmodified) Gram-Schmidt Orthogonalization with no iterative refinement<br>      happy breakdown tolerance 1e-30<br>    maximum iterations=20, initial guess is zero<br>    tolerances:  relative=0.1, absolute=1e-15, divergence=10.<br>    left preconditioning<br>    using PRECONDITIONED norm type for convergence test<br>  PC Object: 1 MPI process<br>    type: asm<br>      total subdomain blocks = 1, amount of overlap = 0<br>      restriction/interpolation type - RESTRICT<br>      Local solver information for first block is in the following KSP and PC objects on rank 0:<br>      Use -ksp_view ::ascii_info_detail to display information for all blocks<br>    KSP Object: (sub_) 1 MPI process<br>      type: preonly<br>      maximum iterations=10000, initial guess is zero<br>      tolerances:  relative=1e-05, absolute=1e-50, divergence=10000.<br>      left preconditioning<br>      using NONE norm type for convergence test<br>    PC Object: (sub_) 1 MPI process<br>      type: ilu<br>        out-of-place factorization<br>        0 levels of fill<br>        tolerance for zero pivot 2.22045e-14<br>        matrix ordering: natural<br>        factor fill ratio given 1., needed 1.<br>          Factored matrix follows:<br>            Mat Object: (sub_) 1 MPI process<br>              type: seqbaij<br>              rows=16384, cols=16384, bs=16<br>              package used to perform factorization: petsc<br>              total: nonzeros=1277952, allocated nonzeros=1277952<br>                  block size is 16<br>      linear system matrix = precond matrix:<br>      Mat Object: (sub_) 1 MPI process<br>        type: seqbaij<br>        rows=16384, cols=16384, bs=16<br>        total: nonzeros=1277952, allocated nonzeros=1277952<br>        total number of mallocs used during MatSetValues calls=0<br>            block size is 16<br>    linear system matrix followed by preconditioner matrix:<br>    Mat Object: 1 MPI process<br>      type: mffd<br>      rows=16384, cols=16384<br>        Matrix-free approximation:<br>          err=1.49012e-08 (relative error in function evaluation)<br>          Using wp compute h routine<br>              Does not compute normU<br>    Mat Object: 1 MPI process<br>      type: seqbaij<br>      rows=16384, cols=16384, bs=16<br>      total: nonzeros=1277952, allocated nonzeros=1277952<br>      total number of mallocs used during MatSetValues calls=0<br>          block size is 16<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, May 4, 2023 at 8:30 AM Mark Adams <<a href="mailto:mfadams@lbl.gov" target="_blank">mfadams@lbl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">If you are using MG what is the coarse grid solver?<br><div>-snes_view might give you that.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, May 4, 2023 at 8:25 AM Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">On Thu, May 4, 2023 at 8:21 AM Mark Lohry <<a href="mailto:mlohry@gmail.com" target="_blank">mlohry@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Do they start very similarly and then slowly drift further apart? </blockquote><div><br></div><div>Yes, this. I take it this sounds familiar?<br></div><div><br></div><div>See these two examples with 20 fixed iterations pasted at the end. The difference for one solve is slight (final SNES norm is identical to 5 digits), but in the context I'm using it in (repeated applications to solve a steady state multigrid problem, though here just one level) the differences add up such that I might reach global convergence in 35 iterations or 38. It's not the end of the world, but I was expecting that with -np 1 these would be identical and I'm not sure where the root cause would be.</div></div></div></div></blockquote><div><br></div><div>The initial KSP residual is different, so its the PC. Please send the output of -snes_view. If your ASM is using direct factorization, then it</div><div>could be randomness in whatever LU you are using.</div><div><br></div><div>  Thanks,</div><div><br></div><div>    Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>   0 SNES Function norm 2.801842107848e+04 <br>    0 KSP Residual norm 4.045639499595e+01 <br>    1 KSP Residual norm 1.917999809040e+01 <br>    2 KSP Residual norm 1.616048521958e+01 <br></div><div>[...]</div><div>   19 KSP Residual norm 8.788043518111e-01 <br>   20 KSP Residual norm 6.570851270214e-01 <br>  Linear solve converged due to CONVERGED_ITS iterations 20<br>  1 SNES Function norm 1.801309983345e+03 <br>Nonlinear solve converged due to CONVERGED_ITS iterations 1</div><div><br></div><div><br></div><div>Same system, identical initial 0 SNES norm, 0 KSP is slightly different<br></div><div></div><div><br></div><div>  0 SNES Function norm 2.801842107848e+04 <br>    0 KSP Residual norm 4.045639473002e+01 <br>    1 KSP Residual norm 1.917999883034e+01 <br>    2 KSP Residual norm 1.616048572016e+01 <br></div><div>[...]</div><div>   19 KSP Residual norm 8.788046348957e-01 <br>   20 KSP Residual norm 6.570859588610e-01 <br>  Linear solve converged due to CONVERGED_ITS iterations 20<br>  1 SNES Function norm 1.801311320322e+03 <br>Nonlinear solve converged due to CONVERGED_ITS iterations 1</div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, May 3, 2023 at 11:05 PM Barry Smith <<a href="mailto:bsmith@petsc.dev" target="_blank">bsmith@petsc.dev</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><br></div>  Do they start very similarly and then slowly drift further apart? That is the first couple of KSP iterations they are almost identical but then for each iteration get a bit further. Similar for the SNES iterations, starting close and then for more iterations and more solves they start moving apart. Or do they suddenly jump to be very different? You can run with -snes_monitor -ksp_monitor <br><div><br><blockquote type="cite"><div>On May 3, 2023, at 9:07 PM, Mark Lohry <<a href="mailto:mlohry@gmail.com" target="_blank">mlohry@gmail.com</a>> wrote:</div><br><div><div dir="auto"><div>This is on a single MPI rank. I haven't checked the coloring, was just guessing there. But the solutions/residuals are slightly different from run to run.</div><div dir="auto"><br></div><div dir="auto">Fair to say that for serial JFNK/asm ilu0/gmres we should expect bitwise identical results?</div><div dir="auto"><br></div><div dir="auto"><br><div class="gmail_quote" dir="auto"><div dir="ltr" class="gmail_attr">On Wed, May 3, 2023, 8:50 PM Barry Smith <<a href="mailto:bsmith@petsc.dev" target="_blank">bsmith@petsc.dev</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
  No, the coloring should be identical every time. Do you see differences with 1 MPI rank? (Or much smaller ones?).<br>
<br>
<br>
<br>
> On May 3, 2023, at 8:42 PM, Mark Lohry <<a href="mailto:mlohry@gmail.com" rel="noreferrer" target="_blank">mlohry@gmail.com</a>> wrote:<br>
> <br>
> I'm running multiple iterations of newtonls with an MFFD/JFNK nonlinear solver where I give it the sparsity. PC asm, KSP gmres, with SNESSetLagJacobian -2 (compute once and then frozen jacobian).<br>
> <br>
> I'm seeing slight (<1%) but nonzero differences in residuals from run to run. I'm wondering where randomness might enter here -- does the jacobian coloring use a random seed?<br>
<br>
</blockquote></div></div></div>
</div></blockquote></div><br></div></blockquote></div>
</blockquote></div><br clear="all"><div><br></div><span>-- </span><br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>
</blockquote></div>
</blockquote></div>
</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>