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

BUG: interpolating to VOM produces two blocks on the adjoint tape #2954

Closed
colinjcotter opened this issue Jun 1, 2023 · 3 comments · Fixed by #2959
Closed

BUG: interpolating to VOM produces two blocks on the adjoint tape #2954

colinjcotter opened this issue Jun 1, 2023 · 3 comments · Fixed by #2959

Comments

@colinjcotter
Copy link
Contributor

Describe the bug

The attached code does one interpolation to a vertex only mesh function. The resulting tape has two interpolate blocks.
I obtained this whilst trying to debug a more substantial issue where there is only one interpolate block but it is unconnected
to my functional on the tape graph. I couldn't find an MFE for it so I'm hoping this is related and exposes the same issue.

Steps to Reproduce
Steps to reproduce the behavior:

run the code below and view the tape graph output as pdf.

from firedrake import *
from firedrake_adjoint import *

mesh = UnitSquareMesh(10,10)

V = FunctionSpace(mesh, "CG", 1)

W = V * V

x, y = SpatialCoordinate(mesh)

w0 = Function(W).assign(1.0)

w1 = Function(W)

v0, v1 = w1.subfunctions
w1.project(w0)

VOM = VertexOnlyMesh(mesh, [[0.51,0.51]])
VVOM = FunctionSpace(VOM, "DG", 0)
y = Function(VVOM)

y.interpolate(v0)

J = assemble(y*y*dx)
Jhat = ReducedFunctional(J, (Control(w0)))

tape = pyadjoint.get_working_tape()
tape.visualise_pdf("testtape.pdf")

Expected behavior

I expect to only see one interpolate block on the grpah.

Error message
N/A

Environment:

  • OS: Linux
  • Python version: Python 3.10.6
  • Output of firedrake-status
    Firedrake Configuration:
    package_manager: True
    minimal_petsc: False
    mpicc: None
    mpicxx: None
    mpif90: None
    mpiexec: None
    disable_ssh: False
    honour_petsc_dir: False
    with_parmetis: False
    slepc: False
    packages: []
    honour_pythonpath: False
    opencascade: False
    tinyasm: False
    torch: False
    petsc_int_type: int32
    cache_dir: /home/cjc1/firedrake/.cache
    complex: False
    remove_build_files: False
    with_blas: None
    netgen: False
    Additions:
    None
    Environment:
    PYTHONPATH: None
    PETSC_ARCH: None
    PETSC_DIR: None
    Status of components:

|Package |Branch |Revision |Modified |

|FInAT |master |47f6c37 |False |
|PyOP2 |master |edae2884 |False |
|fiat |master |8c66270 |False |
|firedrake |master |dd124559f |False |
|h5py |firedrake |6cc4c912 |False |
|libspatialindex |master |4768bf3 |True |
|libsupermesh |master |69012e5 |False |
|loopy |main |cd388f74 |False |
|petsc |firedrake |9364cb008b|False |
|pyadjoint |reduced_functional_parameters |05f3e18 |False |
|pytest-mpi |main |a478bc8 |False |
|tsfc |master |ef39f72 |False |
|ufl |ufl2unicode_vom |f4d7d915 |False |

  • Any relevant environment variables or modifications [eg: PYOP2_DEBUG=1]
    N/A
@stephankramer
Copy link
Contributor

I suspect this is completely harmless. It's just recording the interpolate it does inside the creation of the VertexOnlyMesh: firedrake/mesh.py:3156
Should probably be excluded from the tape, but doubt it does any harm at the moment.

@colinjcotter
Copy link
Contributor Author

colinjcotter commented Jun 2, 2023 via email

@dham
Copy link
Member

dham commented Jun 2, 2023

I am unable to reproduce this difference between subfunctions and split(). If I replace:

v0, v1 = w1.subfunctions

with

v0, v1 = w1.split()

Then I see the deprecation warning, but I produce exactly the same tape visualisation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants