BUG: NonlinearVariationalSolver errors with adj_kwargs
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 75/100
Hướng nghiên cứu
Bắt đầu với adjoint_utils/variational_solver.py quanh wrapper ở dòng 47, sau đó chạy ví dụ Firedrake tối thiểu được cung cấp để tái hiện lỗi constructor. Xác nhận rằng NonlinearVariationalSolver chấp nhận adj_kwargs và ví dụ hoạt động mà không phụ thuộc vào workaround tại thời điểm solve.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
Passing adj_kwargs to NonlinearVariationalSolver in order to have different solver_parameters for the adjoint problem errors.
Steps to Reproduce
Here is an MFE:
from firedrake import *
from firedrake.adjoint import *
continue_annotation()
mesh = UnitSquareMesh(20,20)
U = FunctionSpace(mesh, "CG", 1)
u = Function(U)
v = TestFunction(U)
f = Function(U)
F = inner(grad(u),grad(v))*dx - inner(f,v)*dx
bcs = [DirichletBC(U, Constant(1), (4,)),
DirichletBC(U, Constant(0), (1, 2, 3))]
sp_lu = {
"snes_monitor": None,
"pc_type": "lu",
"pc_factor_mat_solver_type": "mumps",}
# This works
solve(F==0, u, bcs=bcs, solver_parameters=sp_lu, adj_kwargs={"solver_parameters": sp_lu})
nvp = NonlinearVariationalProblem(F, u, bcs=bcs)
# This errors
nvs = NonlinearVariationalSolver(nvp, solver_parameters=sp_lu,
adj_kwargs={"solver_parameters": sp_lu})
Expected behavior
I expect the NonlinearVariationalSolver to accept the adj_kwargs argument.
Error message
Traceback (most recent call last):
File "/home/user/Documents/Code/codex/debug_adjoint_nvs_2.py", line 36, in <module>
nvs = NonlinearVariationalSolver(nvp, solver_parameters=sp_lu,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "petsc4py/PETSc/Log.pyx", line 250, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "petsc4py/PETSc/Log.pyx", line 251, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "/usr/lib/python3.12/contextlib.py", line 81, in inner
return func(*args, **kwds)
^^^^^^^^^^^^^^^^^^^
File "/home/user/firedrake-release-30-05-2026/venv-firedrake/lib/python3.12/site-packages/firedrake/adjoint_utils/variational_solver.py", line 47, in wrapper
init(self, problem, *args, **kwargs)
TypeError: NonlinearVariationalSolver.__init__() got an unexpected keyword argument 'adj_kwargs'
Environment:
- OS: Linux
- Python version: 3.12.3
Additional Info
As pointed out by @dham, the workaround is currently to pass adj_kwargs to the first solve as follows:
nvs = NonlinearVariationalSolver(nvp, solver_parameters=sp_lu)
nvs.solve(adj_kwargs={"solver_parameters": sp_lu})
- Ngôn ngữ chính
- Python
- Star
- 684
- Fork
- 204
- Merge trung bình
- 4 ngày 14 giờ
- Pull request đã merge (30 ngày)
- 46
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của firedrakeproject/firedrake
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
firedrakeproject/firedrake#5091 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 82/100
firedrakeproject/firedrake#3556 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
firedrakeproject/firedrake#5644 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Function.assign on a subset fails with a Constant, a Real Function or abs in the expressionCó thể đã có người làm @connorjward đã nhận 2 ngày trước. Đang mở
firedrakeproject/firedrake#5643 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
firedrakeproject/firedrake#5642 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của firedrakeproject/firedrake
Issue tương tự
-
area:cli area:security bug priority:medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
rtk-ai/rtk#5127 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Broken links found in docsĐang mởdocs pydanty:is-working
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
pydantic/pydantic-ai#13563 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Report to HPO: 32 citations are hasDbXref on HP classes rather than on their definition axiomsĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
NCATSTranslator/Babel#1204 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
alltheplaces/alltheplaces#20570 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
sio2project/oioioi#981 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày