Add urban_flow_diffusion_3d example: 3D diffusion prior for unconditional sampling in a simplified turbulent urban environment#1823
Conversation
…onal sampling in a simplified turbulent urban environment Ports a research training pipeline (previously developed against an older physicsnemo fork with SongUNet3D/EDMPrecond3D) onto the current physicsnemo.diffusion stack: DiffusionUNet3D + EDMPreconditioner + EDMNoiseScheduler + MSEDSMLoss. The denoising backbone architecture is based on Diff-SPORT (arXiv:2506.00214); this example implements only the unconditional generative-prior training and sampling stage of that pipeline, not sensor-placement optimization or conditional/posterior reconstruction. Includes Hydra-based train/generate scripts, dataset loaders supporting both combined and separate U/V/W HDF5 layouts, and Reynolds-stress evaluation plotting. Signed-off-by: Abhijeet Vishwasrao <abvish@lh-login2.arc-ts.umich.edu>
Greptile SummaryThis PR adds a new Several concrete bugs were found:
Important Files Changed
|
| import numpy as np | ||
| import torch | ||
| import h5py | ||
| from typing import Optional, Union |
There was a problem hiding this comment.
torch.nn.functional is never imported as F in this module, so calling F.pad(...) will raise a NameError at runtime whenever the padding branch is taken.
| import numpy as np | |
| import torch | |
| import h5py | |
| from typing import Optional, Union | |
| import numpy as np | |
| import torch | |
| import torch.nn.functional as F | |
| import h5py | |
| from typing import Optional, Union |
| preds_np = rescale_and_crop_ds4(preds, min_scaler, max_scaler, sample_shape[2:]) | ||
|
|
||
| save_uncond_samples(filename_h5, preds_np, batch_seeds.cpu().numpy()) | ||
|
|
||
| if dist.world_size > 1: | ||
| torch.distributed.barrier() | ||
| logger0.info("Generation complete.") |
There was a problem hiding this comment.
| return F.pad(x, pad=pad, mode="constant", value=pad_value) | ||
| else: | ||
| pad_width = [(0, 0)] * x.ndim | ||
| pad_width[-2] = (pad_top, pad_bottom) |
There was a problem hiding this comment.
Debug
print with emoji in library-level utility
These prints fire on every dataset construction and will clutter distributed-training logs across all ranks. Use the logger infrastructure already present in the training scripts, or remove them.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
This file seems to contain numerical values specific to the dataset. I think it should not be there and instead should be part of the dataset hosted on HuggingFace.
There was a problem hiding this comment.
These numbers are used by the code to normalise the batches frequently each epoch. I can add a copy of this file on HF, but we will still need them here, right?
There was a problem hiding this comment.
For all the numerical values, image resolutions, etc... I think they can be packaged directly with the dataset. The only thing to retain in the example yaml is the path of the dataset (where it is downloaded from HF).
There was a problem hiding this comment.
Yes, It was just done this way to be flexible during development, but now it makes sense to add these values in h5 directly.
Signed-off-by: Charlelie Laurent <claurent@nvidia.com>
…rban_flow_diffusion_3d Signed-off-by: Charlelie Laurent <claurent@nvidia.com>
…p32 inputs, default fp32 Signed-off-by: Charlelie Laurent <claurent@nvidia.com>
…_flow_diffusion_3d Signed-off-by: Charlelie Laurent <claurent@nvidia.com>
…fusion_3d Signed-off-by: Charlelie Laurent <claurent@nvidia.com>
…s on-device, drop redundant barriers Signed-off-by: Charlelie Laurent <claurent@nvidia.com>
62123f0 to
3643b0f
Compare
#Add urban_flow_diffusion_3d example: 3D diffusion prior for unconditional sampling in a simplified turbulent urban environment
Description
Ports a research training pipeline (previously developed against an older
physicsnemo fork with
SongUNet3D/EDMPrecond3D) onto the currentphysicsnemo.diffusionstack:DiffusionUNet3D+EDMPreconditioner+EDMNoiseScheduler+MSEDSMLoss. The denoising backbone architecture isbased on Diff-SPORT (arXiv:2506.00214); this example implements only the
unconditional generative-prior training and sampling stage of that
pipeline -- not Diff-SPORT's sensor-placement optimization or its
conditional/posterior reconstruction from sparse observations. Includes
Hydra-based train/generate scripts, dataset loaders supporting both
combined and separate U/V/W HDF5 layouts, and Reynolds-stress evaluation
plotting.
Dataset used for development/smoke-testing:
https://huggingface.co/datasets/abvish/UrbanFlow-oneObstacle-NoTrip
Checklist
Dependencies
None beyond what's already in
examples/cfd/urban_flow_diffusion_3d/requirements.txt(h5py, hydra-core, matplotlib, omegaconf, psutil, tqdm, wandb).Review Process
All PRs are reviewed by the PhysicsNeMo team before merging.
Depending on which files are changed, GitHub may automatically assign a maintainer for review.
We are also testing AI-based code review tools (e.g., Greptile), which may add automated comments with a confidence score.
This score reflects the AI’s assessment of merge readiness and is not a qualitative judgment of your work, nor is
it an indication that the PR will be accepted / rejected.
AI-generated feedback should be reviewed critically for usefulness.
You are not required to respond to every AI comment, but they are intended to help both authors and reviewers.
Please react to Greptile comments with 👍 or 👎 to provide feedback on their accuracy.