🐛[BUG]: Darcy2D permeability: all Fourier coefficients of a sample share one random value (bare wp.tid() in rand_init)
Maintainers usually reply within 2 days
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- data, machine-learning
Research direction
Start in physicsnemo/datapipes/benchmarks/kernels/initialization.py, reading init_uniform_random_4d and init_uniform_random_2d, then inspect how Darcy2D uses the generated coefficients. Run the provided Darcy2D reproducer on CPU and verify the coefficient and permeability-field uniqueness counts. Done means each sample has distinct Fourier coefficients and the expected permeability fields are no longer duplicated.
Written by the indexing model from the issue text.
Description
Version
2.1.1, and current main (eb8f9589)
Describe the bug
init_uniform_random_4d in physicsnemo/datapipes/benchmarks/kernels/initialization.py seeds each thread with
b, i, j, k = wp.tid()
state = wp.rand_init(external_seed, wp.tid())
In a multi-dimensional launch, the bare wp.tid() inside rand_init gives only the first index, b. Every thread of a sample therefore gets the same random state. As a result, all 4 * nr_permeability_freq**2 Fourier coefficients of a sample have the same value. Darcy2D uses this kernel for its permeability, so each sample is built from a single random scalar instead of a random Fourier series. init_uniform_random_2d has the same pattern.
Minimum reproducible example
import numpy as np
from physicsnemo.datapipes.benchmarks.darcy import Darcy2D
np.random.seed(0)
dp = Darcy2D(resolution=32, batch_size=4, nr_permeability_freq=5, max_iterations=2000,
iterations_per_convergence_check=1000, device="cpu")
fields = []
for _ in range(8):
dp.initialize_batch()
f = dp.rand_fourier.numpy()
print([len(np.unique(f[b])) for b in range(len(f))]) # [1, 1, 1, 1]: one value per sample
fields += [k.tobytes() for k in dp.permeability.numpy()]
print(len(set(fields)), "distinct permeability fields of", len(fields)) # 8 of 32
Expected: 100 distinct coefficients per sample, and 32 distinct permeability fields.
(Warp 1.16.0, CPU. A plain kernel that writes wp.tid() into a 4-D array also shows the value depends only on b.)
Suggested fix
Give each element its own offset, for example:
b, i, j, k = wp.tid()
offset = ((b * array.shape[1] + i) * array.shape[2] + j) * array.shape[3] + k
state = wp.rand_init(external_seed, offset)
The same applies to init_uniform_random_2d, using i * array.shape[1] + j. I'm happy to open a PR.
Impact
Examples that train on Darcy2D (darcy_fno, darcy_nested_fnos, mhd_pino, darcy_transolver) see a much less varied permeability distribution than the docstring describes. This came up while checking generated operator-learning data against the Darcy equation (with duplicate and outlier checks).
- Dominant language
- Python
- Stars
- 3.4k
- Forks
- 824
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 70
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from NVIDIA/physicsnemo
-
Wasserstein CDF distance uses the first width for every binPossibly taken @sylvesterkaczmarek claimed this 22 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
NVIDIA/physicsnemo#2042 ·
Maintainers usually reply within 2 days
-
🐛[BUG]: Darcy2D Jacobi kernel divides grad(k)·grad(u) by 2dx instead of 4dx², so the data doesn't solve the Darcy equationPossibly taken @coreyjadams claimed this 20 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
NVIDIA/physicsnemo#2036 · 2 comments · 1 assignee ·
Maintainers usually reply within 2 days
-
🐛[BUG]: MHD_PDE equation "B_grad_u" uses v * Bx.diff(y) instead of By * u.diff(y)Possibly taken @aaguadob claimed this 28 days ago. Open? - Needs Triage bug
Difficulty 1/5 Under an hour Newbie friendliness 92/100
NVIDIA/physicsnemo#2021 ·
Maintainers usually reply within 2 days
-
🐛[BUG]: Diffusion(time=True) in darcy_physics_informed/utils.py silently drops the time-derivative termPossibly taken @aaguadob claimed this 28 days ago. Open? - Needs Triage bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
NVIDIA/physicsnemo#2020 ·
Maintainers usually reply within 2 days
-
🐛[BUG]: DistributedManager's SLURM setup connects to the srun launch node, not to rank 0's nodePossibly taken @peterdsharpe claimed this 1 day ago. Open? - Needs Triage bug
Difficulty 3/5 1-2 days Newbie friendliness 35/100
NVIDIA/physicsnemo#2168 ·
Maintainers usually reply within 2 days
All issues in NVIDIA/physicsnemo
Similar issues
-
link-rot
Difficulty 1/5 Under an hour Newbie friendliness 67/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
developmentseed/titiler-cmr#265 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Insecure Brotli version <1.2.1Possibly taken @jamescw19 claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 85/100
stac-utils/stac-fastapi-pgstac#438 · 1 reaction ·
-
bug triage
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day