BUG: memory grows with every forward and adjoint evaluation when a mixed space has a Real component
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- python
- 領域
- backend, performance
調査の方向性
Start by tracing the example's mixed-space Function creation and the reported MixedDat.dataset / MixedDataSet cache in PyOP2; the issue does not name source files or tests. Reproduce the serial example and inspect cache growth across forward and adjoint evaluations. Done means memory stays roughly flat for the mixed space with a Real component while the plain Poisson comparison remains flat.
索引モデルが issue の本文から書いたものです。
説明
In adjoint inversions, memory grows with the number of forward and adjoint evaluations whenever the solve is on a mixed space with a Real component. We first saw this on an HPE Cray EX machine with Firedrake 2026.10.0, in a 256-rank inversion that was killed by the OOM killer after 10 optimisation iterations. The example below shows it in serial on a MacBook (Apple silicon) with Firedrake main at ef9e4b1e2.
The cause seems to be the MixedDataSet cache in PyOP2. MixedDat.dataset builds a MixedDataSet from the datasets of its components, and caches it on the Set of the first component with the tuple of datasets as the key. A Real component is a Global with its own GlobalDataSet, so every new Function on the mixed space gives a new key. The new entry stays in the cache for as long as the mesh lives. pyadjoint makes new Functions at every replay and adjoint step, so the cache grows with every evaluation.
import gc
import psutil
from firedrake import *
from firedrake.adjoint import *
continue_annotation()
mesh = UnitSquareMesh(128, 128)
V = FunctionSpace(mesh, "CG", 1)
Z = V * FunctionSpace(mesh, "R", 0)
x, y = SpatialCoordinate(mesh)
f = Function(V).interpolate(cos(pi * x) * cos(pi * y))
# Poisson problem with an extra uniform source c, chosen so that the mean of u is zero.
z = Function(Z)
u, c = TrialFunctions(Z)
v, d = TestFunctions(Z)
solve(inner(grad(u), grad(v)) * dx + c * v * dx + u * d * dx == f * v * dx, z,
DirichletBC(Z.sub(0), 0, "on_boundary"))
J = assemble(z.subfunctions[0] ** 2 * dx)
rf = ReducedFunctional(J, Control(f))
pause_annotation()
for i in range(1, 201):
rf(f)
rf.derivative()
if i % 50 == 0:
gc.collect()
print(f"after {i} evaluations: {psutil.Process().memory_info().rss / 2**20:.0f} MB")
Output:
after 50 evaluations: 503 MB
after 100 evaluations: 566 MB
after 150 evaluations: 655 MB
after 200 evaluations: 741 MB
The same script without the Real unknown (a plain Dirichlet Poisson problem on V) stays flat at 332 to 339 MB.
I used Claude Code to reproduce this and to write the example.
- 主要言語
- Python
- スター
- 684
- フォーク
- 204
- 平均マージ
- 4日 14時間
- マージ済み PR(30日)
- 46
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
firedrakeproject/firedrake のほかの issue
-
BUG: NonlinearVariationalSolver errors with adj_kwargs対応中かも @dham が 151 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
firedrakeproject/firedrake#5186 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
firedrakeproject/firedrake#5091 ·
メンテナーはふだん 1 日以内に返信
-
documentation
難易度 1/5 1〜3時間 初心者へのやさしさ 82/100
firedrakeproject/firedrake#3556 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 22/100
firedrakeproject/firedrake#5644 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Function.assign on a subset fails with a Constant, a Real Function or abs in the expression対応中かも @connorjward が 2 日前に担当しました。 オープン
firedrakeproject/firedrake#5643 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
firedrakeproject/firedrake の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
alltheplaces/alltheplaces#20570 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
area:ci bug
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
catincloud-labs/dagster-dex#206 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
number_to_words raises ValueError with threshold= for ordinals ("12th") and comma-grouped strings ("1,000")対応中かも @hemtilva が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
providers security
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
agentbreeder/agentbreeder#1031 ·
メンテナーはふだん 1 日以内に返信