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

Compatibility fix for Firedrake 2024-12 Docker image #24

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vojtamolda
Copy link

@vojtamolda vojtamolda commented Dec 5, 2024

This PR removes the (actually unused) import of firedrake_configuration package that is no longer present in recent (2 weeks or so) versions of Firedrake Docker Hub image.

Root cause of the issue is the migration of Firedrake to be pip-installable. There's details about the topic here. Specifically, the problem started with the PR that migrates PyOP2 into the main Firedrake repo.


It seems like the obvious fix, i.e. just remove the import, worked. The firedrake_configuration module wasn't used for anything directly within the firedrake_ts package. Besides this, the PR contains a few small fixes to make the unit tests and examples work.

It seems like PETSc 3.22 upgrage that's bundled in the Firedrake 2024-12 image doesn't set the ts_max_snes_failures option anymore. Somehow the default value causes the inner SNES solver never to retry any linear solves. So the TS solver has no other option but to fail whenever it happens instead of retrying.

I also migrated the adjoint.py example application to use the newer interpolate Firedrake API.


The only thing I'm having trouble with is the Cahn-Hillard example. For reasons that elude me at the moment, it diverges with the message below. Would anyone have suggestions how to fix it?

Cahh-Hillard example stdout log
0 TS dt 5e-06 time 0.
    0 SNES Function norm 1.866410363336e-01
    1 SNES Function norm 7.884916027265e+01
    2 SNES Function norm 2.067058776898e+02
    3 SNES Function norm 9.893998401741e+02
    4 SNES Function norm 5.375500993119e+03
    0 SNES Function norm 1.866410363336e-01
    1 SNES Function norm 1.737760515311e+02
    2 SNES Function norm 3.309335586354e+02
    3 SNES Function norm 4.791373296126e+02
    4 SNES Function norm 6.200836289510e+02
    5 SNES Function norm 7.551903434020e+02
    6 SNES Function norm 8.853688794213e+02
    7 SNES Function norm 1.011284175652e+03
    8 SNES Function norm 1.133437403166e+03
    9 SNES Function norm 1.252221555724e+03
   10 SNES Function norm 1.367953072893e+03
   11 SNES Function norm 1.480892455881e+03
   12 SNES Function norm 1.591257995129e+03
   13 SNES Function norm 1.699235346311e+03
   14 SNES Function norm 1.804984402986e+03
   15 SNES Function norm 1.908644363617e+03
    0 SNES Function norm 1.866410363336e-01
    1 SNES Function norm 5.877037315881e+02
    2 SNES Function norm 1.091972958899e+03
    3 SNES Function norm 1.545338194620e+03
    4 SNES Function norm 1.961739541240e+03
    0 SNES Function norm 1.866410363336e-01
    1 SNES Function norm 1.804679740799e+03
    2 SNES Function norm 3.191273709310e+03
    0 SNES Function norm 1.866410363336e-01
    1 SNES Function norm 4.670644564704e+03
    0 SNES Function norm 1.866410363336e-01
    1 SNES Function norm 9.132681432726e+03
    0 SNES Function norm 1.866410363336e-01
    1 SNES Function norm 1.300520210779e+04
    0 SNES Function norm 1.866410363336e-01
    1 SNES Function norm 1.489496988623e+04
    0 SNES Function norm 1.866410363336e-01
    1 SNES Function norm 1.550966123299e+04
    0 SNES Function norm 1.866410363336e-01
    1 SNES Function norm 1.567597083125e+04
    0 SNES Function norm 1.866410363336e-01
    1 SNES Function norm 1.571842518301e+04
------------------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------------------
[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
[0]PETSC ERROR: TSStep has failed due to DIVERGED_STEP_REJECTED
[0]PETSC ERROR: WARNING! There are unused option(s) set! Could be the program crashed before usage or a spelling mistake, etc!
[0]PETSC ERROR:   Option left: name:-firedrake_0_fieldsplit_0_ksp_max_it value: 1 source: code
[0]PETSC ERROR:   Option left: name:-firedrake_0_fieldsplit_0_ksp_type value: preonly source: code
[0]PETSC ERROR:   Option left: name:-firedrake_0_fieldsplit_0_pc_type value: hypre source: code
[0]PETSC ERROR:   Option left: name:-firedrake_0_fieldsplit_1_ksp_max_it value: 1 source: code
[0]PETSC ERROR:   Option left: name:-firedrake_0_fieldsplit_1_ksp_type value: preonly source: code
[0]PETSC ERROR:   Option left: name:-firedrake_0_fieldsplit_1_pc_type value: mat source: code
[0]PETSC ERROR:   Option left: name:-firedrake_0_ksp_atol value: 1e-15 source: code
[0]PETSC ERROR:   Option left: name:-firedrake_0_ksp_rtol value: 1e-06 source: code
[0]PETSC ERROR:   Option left: name:-firedrake_0_ksp_type value: lgmres source: code
[0]PETSC ERROR:   Option left: name:-firedrake_0_mat_type value: aij source: code
[0]PETSC ERROR:   Option left: name:-firedrake_0_pc_fieldsplit_schur_factorization_type value: lower source: code
[0]PETSC ERROR:   Option left: name:-firedrake_0_pc_fieldsplit_schur_precondition value: user source: code
[0]PETSC ERROR:   Option left: name:-firedrake_0_pc_fieldsplit_type value: schur source: code
[0]PETSC ERROR:   Option left: name:-firedrake_0_pc_type value: lu source: code
[0]PETSC ERROR:   Option left: name:-firedrake_0_snes_atol value: 1e-10 source: code
[0]PETSC ERROR:   Option left: name:-firedrake_0_snes_linesearch_max_it value: 1 source: code
[0]PETSC ERROR:   Option left: name:-firedrake_0_snes_linesearch_type value: basic source: code
[0]PETSC ERROR:   Option left: name:-firedrake_0_snes_monitor (no value) source: code
[0]PETSC ERROR:   Option left: name:-firedrake_0_snes_rtol value: 1e-09 source: code
[0]PETSC ERROR:   Option left: name:-firedrake_0_snes_stol value: 1e-16 source: code
[0]PETSC ERROR:   Option left: name:-firedrake_0_ts_exact_final_time value: stepover source: code
[0]PETSC ERROR:   Option left: name:-firedrake_0_ts_max_snes_failures value: -1 source: code
[0]PETSC ERROR:   Option left: name:-firedrake_0_ts_monitor (no value) source: code
[0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
[0]PETSC ERROR: Petsc Release Version 3.22.1, unknown 
[0]PETSC ERROR: /firedrake-ts/examples/cahn-hilliard.py with 1 MPI process(es) and PETSC_ARCH default on 90659771b98b by Unknown Thu Dec  5 23:37:52 2024
[0]PETSC ERROR: Configure options: --COPTFLAGS=-O3 -march=native -mtune=native --CXXOPTFLAGS=-O3 -march=native -mtune=native --FOPTFLAGS=-O3 -march=native -mtune=native --with-c2html=0 --with-debugging=0 --with-fortran-bindings=0 --with-make-np=12 --with-shared-libraries=1 --with-bison --with-flex --with-zlib --with-fftw-dir=/home/firedrake/petsc/packages --with-hdf5-dir=/home/firedrake/petsc/packages --with-hwloc-dir=/home/firedrake/petsc/packages --with-hypre-dir=/home/firedrake/petsc/packages --with-metis-dir=/home/firedrake/petsc/packages --with-mpi-dir=/home/firedrake/petsc/packages --with-mumps-dir=/home/firedrake/petsc/packages --with-netcdf-dir=/home/firedrake/petsc/packages --with-pastix-dir=/home/firedrake/petsc/packages --with-pnetcdf-dir=/home/firedrake/petsc/packages --with-ptscotch-dir=/home/firedrake/petsc/packages --with-scalapack-dir=/home/firedrake/petsc/packages --with-suitesparse-dir=/home/firedrake/petsc/packages --with-superlu_dist-dir=/home/firedrake/petsc/packages PETSC_ARCH=default
[0]PETSC ERROR: #1 TSStep() at /home/firedrake/petsc/src/ts/interface/ts.c:3440
[0]PETSC ERROR: #2 TSSolve() at /home/firedrake/petsc/src/ts/interface/ts.c:4072
Traceback (most recent call last):
  File "/firedrake-ts/examples/cahn-hilliard.py", line 121, in <module>
    solver.solve()
  File "/firedrake-ts/firedrake_ts/ts_solver.py", line 364, in solve
    self.ts.solve(work)
  File "petsc4py/PETSc/TS.pyx", line 2478, in petsc4py.PETSc.TS.solve
petsc4py.PETSc.Error: error code 91

- Monkey-patch u_restrict property required by newer PETSc TS
- Package is no longer available due to pip install migration
- Migrate adjoint.py to newer interpolate API
- Set max SNES failures to make TS retry steps
@vojtamolda
Copy link
Author

vojtamolda commented Dec 6, 2024

Fixes #23. I also tested the firedrakeproject/firedrake:2024-11 image and everything except the Cahh-Hillard example works there as well.

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 this pull request may close these issues.

1 participant