Repository navigation
Conversation
A ray that left a subdomain between two bins of a source region mesh was moved to that point, and the receiving rank started a new ray trace from inside the cell. That trace is not the one made when the ray entered the cell: the first segment lost TINY_BIT of length, so results depended on where the subdomain boundaries were (which load balancing sets from measured wall time), and the restart point could be invalid for the geometry (lost rays). The ray is now buffered in the state it had on entry to the cell, with the number of segments it has been attenuated over since. The receiving rank traces the cell again from that state and skips those segments, so every segment is the same as without domain decomposition. This replaces the partial-length bookkeeping and the decomposed-only rule that skipped segments shorter than TINY_BIT.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Suark94
left a comment
There was a problem hiding this comment.
Avoiding having to mess around with the TINY_BITs seems like a good way to ensure consistency of results regardless of where the subdomain boundaries fall, even though this means some ray tracing work has to be repeated. Thanks @jtramm !
A ray with zero inactive length starts active before its angular flux has been initialized. Mark sampling handoffs explicitly so the receiver initializes flux from the source region and the sender records neighbors from transport handoffs only.
paulromano
left a comment
There was a problem hiding this comment.
Thanks @jtramm! The changes look fine to me. I also had GPT-6.2-Sol max review and it spotted one subtle (pre-existing) bug: in an MPI job where the inactive distance is set to zero, a newly sampled ray that was sent to another rank would mistake the zero-filled buffer for a valid flux. The commit I pushed should address this by adding a flag indicating whether to initialized a sampled ray's angular flux from its starting region. Let me know if that looks OK to you and if so, I'll go ahead and merge.
Summary
This PR makes a small change to how rays are passed across subdomain boundaries in the random ray domain decomposed MPI solver. The current
developbranch results in inconsistent floating point rounding which I've noticed occasionally causes one of the CI tests to fail. This PR ensures much stronger floating point consistency (by ensuring the exact same ray tracing operations are performed regardless of where subdomain boundaries are) so the CI test should pass cleanly now.The Problem
In random ray domain decomposition, a ray that leaves a rank's subdomain between two bins of a source region mesh is moved to that point, and the receiving rank starts a new ray trace from inside the cell. That trace is not the one made when the ray entered the cell (its first segment is
TINY_BITshorter), so results depend on where the subdomain boundaries are. Load balancing sets those from measured wall time, so results change from run to run, which makes tests with a source region mesh potentially subject to different roundoffs under MPI.The Fix
The ray is no longer moved. It is buffered in the state it had on entry to the cell, with the number of segments it has been attenuated over since. The receiving rank traces the cell again from that state and skips those segments, so every segment is the same as without domain decomposition. This replaces the partial-length bookkeeping and the decomposed-only rule that skipped segments shorter than
TINY_BIT. Results without MPI are unchanged.I also considered just trying to correct for the differences with
TINY_BITetc, but I've found it is generally just not a great idea to "interfere" with OpenMC's default cell-to-cell ray tracer (as we are currently doing indevelop) by stopping the ray part way between cell surfaces and then doing another shorter length ray trace, as this will inevitably result in different numbers and rounding compared to the serial case with no subdomain boundaries.Testing
weightwindows_fw_cadis_meshmodel on 2 to 8 ranks, largest relative difference of the weight windows compared to a serial run without MPI:As you can see above, the floating point difference vs serial is reduced by many orders of magnitude, which makes CI testing much easier and reliable. Random ray and FW-CADIS regression tests give the same results as develop without MPI and on 2 ranks.
Note that on 4 ranks
developcan also abort on this model with a lost ray. That is a separate issue already fixed in #4247, so it is not a motivation for this PR.Potential for Runtime Cost Increases
There is going to be some amount of repeated ray tracing work that gets performed here. While OpenMC top level ray tracing (from one material filled cell instance surface to the next) isn't going to ever be redone, cell-under-voxel ray tracing operations inside of a material filled cell instance will be performed again. Typically this is not very expensive (especially if a structured mesh is used), but we might imagine a worst case where a very large cell (maybe a shield wall) is subdivided finely by an unstructured mesh into millions of regions. In this case, retracing hundreds or thousands of mesh cell crossings might be quite expensive to repeat.
I don't see a great way of guaranteeing both full reproducibility and guaranteeing that no ray tracing work is performed twice. As CI reproducibility is immediately quite valuable to us, I think we should go the route this PR takes. If someone down the line hits a real world use case where this choice becomes very expensive for performance, we could always add in a user option to enable "fast non-reproducible cell under voxel ray tracing" or something like that.
AI Assistance
Checklist
Summary by CodeRabbit