<div dir="ltr"><div dir="ltr">On Tue, Sep 15, 2020 at 3:05 PM Pierre Jolivet <<a href="mailto:pierre.jolivet@enseeiht.fr">pierre.jolivet@enseeiht.fr</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 style="overflow-wrap: break-word;">Thank you Barry for the very comprehensive answer, this gives me hope that I’ll indeed be able to help our Ipopt users transition to Tao when this is in place/if this gets done!<div>Shri, my Hessian and my x are currently distributed (really standard distribution, nothing fancy) using the same layout.</div><div>I _need_ to centralize the Jacobian on rank 0, because there is currently no way to distribute a matrix with a single row on more than one rank.</div><div><div>So in this scenario, PDIPM is indeed not usable, cf. the previous trace.</div><div>When you say: "The column layout of the equality/inequality Jacobian is same as that for x”, this is currently not achievable with a distributed x and a single equality/inequality Jacobian.</div><div>The two fixes I see:</div><div>1) provide the transpose of the Jacobian (of dimension N x 1, so can be split row-wise no problem, but this may have side effect I’m not anticipating)</div><div></div></div></div></blockquote><div><br></div><div>This sounds like the easiest and most natural thing.</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 style="overflow-wrap: break-word;"><div><div>2) provide the Jacobian as a Mat_MPIColumn (for lack of a better name, to quote Barry) </div><div><br></div><div>Thanks,</div><div>Pierre</div><div><br><blockquote type="cite"><div>On 15 Sep 2020, at 8:18 PM, Barry Smith <<a href="mailto:bsmith@petsc.dev" target="_blank">bsmith@petsc.dev</a>> wrote:</div><br><div><div style="overflow-wrap: break-word;"><div><br></div>  Pierre,<div><br></div><div>    Based on my previous mail I am hoping that the <font face="Times New Roman, serif" size="3">PDIPM algorithm itself won't need a major refactorization to be scalable, only a custom matrix type is needed to store and compute with the  Hessian in a scalable way.</font></div><div><font face="Times New Roman, serif" size="3"><br></font></div><div><font face="Times New Roman, serif" size="3">   Barry</font></div><div><font face="Times New Roman, serif" size="3"><br></font></div><div><div><br><blockquote type="cite"><div>On Sep 15, 2020, at 12:50 PM, Pierre Jolivet <<a href="mailto:pierre.jolivet@enseeiht.fr" target="_blank">pierre.jolivet@enseeiht.fr</a>> wrote:</div><br><div><div style="overflow-wrap: break-word;"><br><div><br><blockquote type="cite"><div>On 15 Sep 2020, at 5:40 PM, Abhyankar, Shrirang G <<a href="mailto:shrirang.abhyankar@pnnl.gov" target="_blank">shrirang.abhyankar@pnnl.gov</a>> wrote:</div><br><div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div style="margin:0in;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:"Times New Roman",serif">Pierre,<u></u><u></u></span></div><div style="margin:0in;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:"Times New Roman",serif">   You are right. There are a few MatMultTransposeAdd that may need conforming layouts for the equality/inequality constraint vectors and equality/inequality constraint Jacobian matrices. I need to check if that’s the case. We only have ex1 example currently, we need to add more examples. We are currently working on making PDIPM robust and while doing it will work on adding another example.<u></u><u></u></span></div><div style="margin:0in;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:"Times New Roman",serif"><u></u> <u></u></span></div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">Very naive question, but given that I have a single constraint, how do I split a 1 x N matrix column-wise? I thought it was not possible.<u></u><u></u></div><div style="margin:0in;font-size:11pt;font-family:Calibri,sans-serif"><i><span style="font-size:12pt;font-family:"Times New Roman",serif"><u></u> <u></u></span></i></div><div style="margin:0in;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:"Times New Roman",serif">When setting the size of the constraint vector, you need to set the local size on one rank to 1 and all others to zero. For the Jacobian, the local row size on that rank will be 1 and all others to zero. The column layout for the Jacobian should follow the layout for vector x. So each rank will set the local column size of the Jacobian to local size of x.</span></div></div></div></blockquote><div><br></div><div>That is assuming I don’t want x to follow the distribution of the Hessian, which is not my case.</div><div>Is there some plan to make PDIPM handle different layouts?</div><div>I hope I’m not the only one thinking that having a centralized Hessian when there is a single constraint is not scalable?</div><div><br></div><div>Thanks,</div><div>Pierre</div><div><br></div><blockquote type="cite"><div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div style="margin:0in;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:"Times New Roman",serif">Shri<u></u><u></u></span></div><div style="margin:0in;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:"Times New Roman",serif"><u></u> <u></u></span></div><div><blockquote style="margin-top:5pt;margin-bottom:5pt" type="cite"><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">On 15 Sep 2020, at 2:21 AM, Abhyankar, Shrirang G <<a href="mailto:shrirang.abhyankar@pnnl.gov" style="color:blue;text-decoration:underline" target="_blank">shrirang.abhyankar@pnnl.gov</a>> wrote:<u></u><u></u></div></div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div><div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:"Times New Roman",serif">Hello Pierre,</span><u></u><u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:"Times New Roman",serif">   PDIPM works in parallel so you can have distributed Hessian, Jacobians, constraints, variables, gradients in any layout you want.  If you are using a DM then you can have it generate the Hessian.<span> </span></span><u></u><u></u></div></div></div></blockquote><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">Could you please show an example where this is the case?<u></u><u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">pdipm->x, which I’m assuming is a working vector, is both used as input for Hessian and Jacobian functions, e.g., <a href="https://gitlab.com/petsc/petsc/-/blob/master/src/tao/constrained/impls/ipm/pdipm.c#L369" style="color:blue;text-decoration:underline" target="_blank">https://gitlab.com/petsc/petsc/-/blob/master/src/tao/constrained/impls/ipm/pdipm.c#L369</a> (Hessian) + <a href="https://gitlab.com/petsc/petsc/-/blob/master/src/tao/constrained/impls/ipm/pdipm.c#L473" style="color:blue;text-decoration:underline" target="_blank">https://gitlab.com/petsc/petsc/-/blob/master/src/tao/constrained/impls/ipm/pdipm.c#L473</a> (Jacobian)<u></u><u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">I thus doubt that it is possible to have different layouts?<u></u><u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">In practice, I end up with the following error when I try this (2 processes, distributed Hessian with centralized Jacobian):<u></u><u></u></div></div><div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">[1]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------<u></u><u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">[1]PETSC ERROR: Nonconforming object sizes<u></u><u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">[1]PETSC ERROR: Vector wrong size 14172 for scatter 0 (scatter reverse and vector to != ctx from size)<u></u><u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">[1]PETSC ERROR: #1 VecScatterBegin() line 96 in /Users/jolivet/Documents/repositories/petsc/src/vec/vscat/interface/vscatfce.c<u></u><u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">[1]PETSC ERROR: #2 MatMultTransposeAdd_MPIAIJ() line 1223 in /Users/jolivet/Documents/repositories/petsc/src/mat/impls/aij/mpi/mpiaij.c<u></u><u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">[1]PETSC ERROR: #3 MatMultTransposeAdd() line 2648 in /Users/jolivet/Documents/repositories/petsc/src/mat/interface/matrix.c<u></u><u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">[0]PETSC ERROR: Nonconforming object sizes<u></u><u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">[0]PETSC ERROR: Vector wrong size 13790 for scatter 27962 (scatter reverse and vector to != ctx from size)<u></u><u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">[1]PETSC ERROR: #4 TaoSNESFunction_PDIPM() line 510 in /Users/jolivet/Documents/repositories/petsc/src/tao/constrained/impls/ipm/pdipm.c<u></u><u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">[0]PETSC ERROR: #5 TaoSolve_PDIPM() line 712 in /Users/jolivet/Documents/repositories/petsc/src/tao/constrained/impls/ipm/pdipm.c<u></u><u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">[1]PETSC ERROR: #6 TaoSolve() line 222 in /Users/jolivet/Documents/repositories/petsc/src/tao/interface/taosolver.c<u></u><u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">[0]PETSC ERROR: #1 VecScatterBegin() line 96 in /Users/jolivet/Documents/repositories/petsc/src/vec/vscat/interface/vscatfce.c<u></u><u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">[0]PETSC ERROR: #2 MatMultTransposeAdd_MPIAIJ() line 1223 in /Users/jolivet/Documents/repositories/petsc/src/mat/impls/aij/mpi/mpiaij.c<u></u><u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">[0]PETSC ERROR: #3 MatMultTransposeAdd() line 2648 in /Users/jolivet/Documents/repositories/petsc/src/mat/interface/matrix.c<u></u><u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">[0]PETSC ERROR: #4 TaoSNESFunction_PDIPM() line 510 in /Users/jolivet/Documents/repositories/petsc/src/tao/constrained/impls/ipm/pdipm.c<u></u><u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">[0]PETSC ERROR: #5 TaoSolve_PDIPM() line 712 in /Users/jolivet/Documents/repositories/petsc/src/tao/constrained/impls/ipm/pdipm.c<u></u><u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">[0]PETSC ERROR: #6 TaoSolve() line 222 in /Users/jolivet/Documents/repositories/petsc/src/tao/interface/taosolver.c<u></u><u></u></div></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">I think this can be reproduced by ex1.c by just distributing the Hessian instead of having it centralized on rank 0.<u></u><u></u></div></div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif"><br><br><u></u><u></u></div><blockquote style="margin-top:5pt;margin-bottom:5pt" type="cite"><div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:"Times New Roman",serif">Ideally, you want to have the layout below to minimize movement of matrix/vector elements across ranks.</span><u></u><u></u></div></div><p style="margin-right:0in;margin-left:1in;font-size:11pt;font-family:Calibri,sans-serif;margin-bottom:0in"><span style="font-size:10pt;font-family:Symbol"><span>·<span style="font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:7pt;line-height:normal;font-family:"Times New Roman"">        <span> </span></span></span></span><span style="font-size:12pt;font-family:"Times New Roman",serif">The layout of vectors x, bounds on x, and gradient is same.</span><u></u><u></u></p><p style="margin-right:0in;margin-left:1in;font-size:11pt;font-family:Calibri,sans-serif;margin-bottom:0in"><span style="font-size:10pt;font-family:Symbol"><span>·<span style="font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:7pt;line-height:normal;font-family:"Times New Roman"">        <span> </span></span></span></span><span style="font-size:12pt;font-family:"Times New Roman",serif">The row layout of the equality/inequality Jacobian is same as the equality/inequality constraint vector layout.</span><u></u><u></u></p><p style="margin-right:0in;margin-left:1in;font-size:11pt;font-family:Calibri,sans-serif;margin-bottom:0in"><span style="font-size:10pt;font-family:Symbol"><span>·<span style="font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:7pt;line-height:normal;font-family:"Times New Roman"">        <span> </span></span></span></span><span style="font-size:12pt;font-family:"Times New Roman",serif">The column layout of the equality/inequality Jacobian is same as that for x.</span><u></u><u></u></p></div></blockquote><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">Very naive question, but given that I have a single constraint, how do I split a 1 x N matrix column-wise? I thought it was not possible.<u></u><u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">Thanks,<u></u><u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">Pierre<u></u><u></u></div></div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif"><br><br><u></u><u></u></div><blockquote style="margin-top:5pt;margin-bottom:5pt" type="cite"><div><p style="margin-right:0in;margin-left:1in;font-size:11pt;font-family:Calibri,sans-serif;margin-bottom:0in"><span style="font-size:10pt;font-family:Symbol"><span>·<span style="font-style:normal;font-variant-caps:normal;font-weight:normal;font-stretch:normal;font-size:7pt;line-height:normal;font-family:"Times New Roman"">        <span> </span></span></span></span><span style="font-size:12pt;font-family:"Times New Roman",serif">The row and column layout for the Hessian is same as x.</span><u></u><u></u></p><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:"Times New Roman",serif"> </span><u></u><u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:"Times New Roman",serif">The tutorial example ex1 is extremely small (only 2 variables) so its implementation is very simplistic. I think, in parallel, it ships off constraints etc. to rank 0. It’s not an ideal example w.r.t demonstrating a parallel implementation. We aim to add more examples as we develop PDIPM. If you have an example to contribute then we would most welcome it and provide help on adding it.</span><u></u><u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:"Times New Roman",serif"> </span><u></u><u></u></div></div><div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:"Times New Roman",serif">Thanks,</span><u></u><u></u></div></div><div><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:12pt;font-family:"Times New Roman",serif">Shri</span><u></u><u></u></div></div></div><div style="border-style:solid none none;border-top-width:1pt;border-top-color:rgb(181,196,223);padding:3pt 0in 0in"><div style="margin-left:0.5in"><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif"><b><span style="font-size:12pt">From:<span> </span></span></b><span style="font-size:12pt">petsc-dev <<a href="mailto:petsc-dev-bounces@mcs.anl.gov" style="color:blue;text-decoration:underline" target="_blank">petsc-dev-bounces@mcs.anl.gov</a>> on behalf of Pierre Jolivet <<a href="mailto:pierre.jolivet@enseeiht.fr" style="color:blue;text-decoration:underline" target="_blank">pierre.jolivet@enseeiht.fr</a>><br><b>Date:<span> </span></b>Monday, September 14, 2020 at 1:52 PM<br><b>To:<span> </span></b>PETSc Development <<a href="mailto:petsc-dev@mcs.anl.gov" style="color:blue;text-decoration:underline" target="_blank">petsc-dev@mcs.anl.gov</a>><br><b>Subject:<span> </span></b>[petsc-dev] PDIPDM questions</span><u></u><u></u></div></div></div><div><div style="margin-left:0.5in"><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif"> <u></u><u></u></div></div></div><div><div style="margin-left:0.5in"><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">Hello,<u></u><u></u></div></div></div><div><div style="margin-left:0.5in"><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">In my quest to help users migrate from Ipopt to Tao, I’ve a new question.<u></u><u></u></div></div></div><div><div style="margin-left:0.5in"><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">When looking at src/tao/constrained/tutorials/ex1.c, it seems that almost everything is centralized on rank 0 (local sizes are 0 but on rank 0).<u></u><u></u></div></div></div><div><div style="margin-left:0.5in"><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">I’d like to have my Hessian distributed more naturally, as in (almost?) all other SNES/TS examples, but still keep the Jacobian of my equality constraint, which is of dimension 1 x N (N >> 1), centralized on rank 0.<u></u><u></u></div></div></div><div><div style="margin-left:0.5in"><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">Is this possible?<u></u><u></u></div></div></div><div><div style="margin-left:0.5in"><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">If not, is it possible to supply the transpose of the Jacobian, of dimension N x 1, which could then be distributed row-wise like the Hessian?<u></u><u></u></div></div></div><div><div style="margin-left:0.5in"><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">Or maybe use some trick to distribute a MatAIJ/MatDense of dimension 1 x N column-wise? Use a MatNest with as many blocks as processes?<u></u><u></u></div></div></div><div><div style="margin-left:0.5in"><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif"> <u></u><u></u></div></div></div><div><div style="margin-left:0.5in"><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">So, just to sum up, how can I have a distributed Hessian with a Jacobian with a single row?<u></u><u></u></div></div></div><div><div style="margin-left:0.5in"><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif"> <u></u><u></u></div></div></div><div><div style="margin-left:0.5in"><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">Thanks in advance for your help,<u></u><u></u></div></div></div><div><div style="margin-left:0.5in"><div style="margin:0in 0in 0in 0.5in;font-size:11pt;font-family:Calibri,sans-serif">Pierre</div></div></div></div></blockquote></div></div></div></blockquote></div><br></div></div></blockquote></div><br></div></div></div></blockquote></div><br></div></div></blockquote></div><br clear="all"><div><br></div>-- <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>