Radiation transport example#1647
Conversation
Greptile SummaryThis PR adds a new end-to-end example under
Important Files Changed
|
| case_type = cfg.case.type | ||
| use_amp, amp_dtype = _parse_amp(cfg) | ||
| accum_steps = cfg.train.get("gradient_accumulation_steps", 1) | ||
| max_grad_norm = 10.0 |
There was a problem hiding this comment.
max_grad_norm = 10.0 is hardcoded inside the training loop with no way to override it from config. Other training hyperparameters are all configurable via cfg.train, but gradient clipping is silently fixed at 10.
| max_grad_norm = 10.0 | |
| max_grad_norm = cfg.train.get("max_grad_norm", 10.0) |
| pretrain_checkpoint: null | ||
| resume_checkpoint: null | ||
|
|
||
| # objective = mse_weight * regression_mse + physics_loss.weight * (regression_mse + qoi_loss); region_weighted swaps regression_mse for the weighted variant. |
There was a problem hiding this comment.
The comment claims objective = mse_weight * regression_mse + physics_loss.weight * (regression_mse + qoi_loss), but trainer.compute_losses (line 286 in src/trainer.py) actually computes loss = mse_w * loss_mse + physics_w * loss_qoi — i.e., physics_loss.weight multiplies only qoi_loss, not regression_mse + qoi_loss. Consider updating the comment.
| directly (skipping ``self._load``), so we override here too. Thread | ||
| pool + CUDA-stream wiring is inherited from the base class. | ||
| """ | ||
| from physicsnemo.datapipes.protocols import _PrefetchResult |
There was a problem hiding this comment.
This is a private API import. Unrelated to this PR, but if this method is useful in custom datapipes, should we consider making it a public API?
There was a problem hiding this comment.
This is a good catch, and is the result of packing in some non-tensor fields into the custom dataset. This can be resolved by updating the dataset.
There was a problem hiding this comment.
I went ahead and updated this - would have been a maintenance burden and confusing for anyone reading the code. The HuggingFace dataset has also been updated to make wiring in the dataset keys smoother. 23c889e
| `physicsnemo.mesh.Mesh.save(...)`. The loader uses the first and final | ||
| `scalar_flux` snapshots and ignores intermediate snapshots. The fields are: | ||
|
|
||
| `Mesh.points` — `(N, 2)` float32 cell-center coordinates. |
There was a problem hiding this comment.
Updated in 5bbd56e. Missed this initially as a result of updating the dataset structure
There was a problem hiding this comment.
It would be really nice to add an image for what problem is being solved and how the predictions would look like.
|
|
||
| The dataset is available on Hugging Face: | ||
| [Linear Radiation Transport][hf-rte]. Alternatively, raw simulation data | ||
| may be curated from the [KiT-RT repositories](https://github.com/KiT-RT). |
There was a problem hiding this comment.
I could not find any information about how this curation should be done.
There was a problem hiding this comment.
Curation from KiT-RT repo will be left as an exercise for the reader at this point, scripts my be added to that repo in the future.
mnabian
left a comment
There was a problem hiding this comment.
LGTM! Left a few minor comments.
| `physicsnemo.mesh.Mesh.save(...)`. The loader uses the first and final | ||
| `scalar_flux` snapshots and ignores intermediate snapshots. The fields are: | ||
|
|
||
| `Mesh.points` — `(N, 2)` float32 cell-center coordinates. |
There was a problem hiding this comment.
Updated in 5bbd56e. Missed this initially as a result of updating the dataset structure
…ivate classes/methods
…-example # Conflicts: # CHANGELOG.md
PhysicsNeMo Pull Request
Description
Radiation Transport Surrogate Model with Transolver
This PR adds a new PhysicsNeMo example under
examples/nuclear_engineering/radiation_transport/that trains a Transolver surrogate for the 2-D linear radiation transport equation on two benchmark problems relevant for nuclear reactor assembly design and inertial confinement fusion — the Lattice and Hohlraum benchmarks from Kusch et al. 2025, with data generated by the KiT-RT simulation code. The example is built end-to-end on PhysicsNeMo's:Meshdatapipes,DataLoader/Compose/Normalizetransforms, theTransolvermodel, theCombinedOptimizer(Muon + AdamW), andphysicsnemo.utils.checkpoint. It supports distributed training, well-defined quantities of interest, a differentiable physics loss, and reusable modules for extending to other archetectures.Why
As with many other scientific and engineering pipelines, running simulations is the bottleneck. This workflow demonstrates how PhysicsNeMo, and models traditionally used in CFD, CAE, and other domains, can be reused for radiation transport. Because the KiT-RT code is "benchmark-style," it is a natural interface for validating scientific ML and surrogate models.
Key Changes
New example tree
Data layout
Each simulation is one
<name>.pmsh/directory (written byphysicsnemo.mesh.Mesh.save) next to a<name>.attrs.jsonsidecar.RTEBaseDataset._loadusesphysicsnemo.mesh.Mesh.loadfor the memmap tensors and readsraw_attrsfrom the sidecar, exposing it as aNonTensorDatametadataentry on the returnedTensorDict. Splits are basename arrays; the reader appends.pmshwhen opening stores.Training
torchrun --nproc_per_node=N src/train.py; single-processworks via plain
python(no DDP-specific code is gated on launchdetection beyond what
DistributedManagerprovides).torch.amp.autocast+GradScaler(fp16) / direct autocast (bf16).train.optimizer.type=muonreturns aCombinedOptimizerwithtorch.optim.Muonfor 2-D weight matricesSequentialLR([LinearLR, CosineAnnealingLR])for warmupcheckpoints/best_model/.Known Limitations
not used as a model input in this example.
Checklist
Dependencies
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.