swe_nonlinear_pino: physicsnemo_fdm_swe_nonlin slices batch dim ([1:-1]) -> empty PDE residual / NaN loss_pde with default batchsize=1
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- machine-learning
Research direction
The bug is in physicsnemo_fdm_swe_nonlin in examples/cfd/swe_nonlinear_pino/train_utils/losses.py, where Dh, Du and Dv are sliced with [1:-1] along the batch dimension. Compare it with the reference fdm_swe_nonlin in the same file, which trims the last dimension. Run swe_nonlinear_pino with the default config (batchsize 1) and check that Dh.shape is (0, ...) and that test loss_pde is nan. Done when the residuals keep their full batch shape and loss_pde is finite and decreases.
Written by the indexing model from the issue text.
Description
In examples/cfd/swe_nonlinear_pino/train_utils/losses.py, physicsnemo_fdm_swe_nonlin slices the PDE residuals along the batch dimension:
Dh = pde_Dh["Dh"][1:-1]
Du = pde_Du["Du"][1:-1]
Dv = pde_Dv["Dv"][1:-1]
The reference implementation fdm_swe_nonlin in the same file trims the last dimension ([..., 1:-1]). The time trimming is also already applied to the inputs (1 : nt - 1, nt + 1 : 2 * nt - 1).
With the default batchsize: 1 in config_pino.yaml, the residual tensors become empty, e.g. Dh.shape == (0, 99, 128, 128):
loss_pdeis NaN;- the PDE-term gradient is 0;
- training proceeds without any error, so the physics loss silently has no effect.
With batch size 2 the residuals are also empty. With batch size 3, only 1 of 3 samples is used.
Reproduce (v2.2.2, pip install nvidia-physicsnemo[sym], A100):
- Run
swe_nonlinear_pinowith the default config and the physicsnemo derivative path. - The log shows
test loss_pde = nan.
Fix: remove the slice (Dh = pde_Dh["Dh"], and the same for Du and Dv). After this change loss_pde is finite and decreases (train 0.206 → 0.023, test 0.019 after 2 epochs). It then matches the behaviour of loss.derivative=original.
The lines are unchanged on main as of 2026-11-01.
- Dominant language
- Python
- Stars
- 3.4k
- Forks
- 828
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 81
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 31 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 equationMay be free again @coreyjadams claimed this 29 days ago, and no pull request is open. 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 36 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 36 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
-
Difficulty 5/5 Over a week Newbie friendliness 8/100
NVIDIA/physicsnemo#2216 ·
Maintainers usually reply within 2 days
All issues in NVIDIA/physicsnemo
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
unionai-oss/pandera#2640 ·
Maintainers usually reply within 2 days
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
JdeRobot/RoboticsInfrastructure#843 ·
Maintainers usually reply within 1 day
-
automated endpoint-dead needs-curation
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
almanac-data/climate-almanac#122 ·
Maintainers usually reply within 1 day
-
area:harness enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
evarness-ai/iris-harness#420 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
suitenumerique/find#206 ·
Maintainers usually reply within 2 days