Details
-
Type:
RFC
-
Status: Retired
-
Resolution: Done
-
Component/s: Sims
-
Labels:None
-
Location:#sims-operations
Description
While simulating the scheduler, we've encountered an issue with cross-platform repeatability. It would seem that different OS and/or hardware setups can store python floats to different precisions. For the scheduler, we have a huge number of float comparisons throughout the code, e.g., "was this point within 1.75 degrees of a pointing", "is this point currently above the airmass limit", "is this point below the zenith limit", "is the time until twilight more than a block time", etc.
Right now, we are seeing simulations on different machines diverge after about 90 days. Previously, I was able to fix the issue by wrapping floats in an "int_rounded" class whenever there was a comparison being made. So
if point < airmass_limit
became
if int_rounded(point) < int_rounded(airmass_limit)
This way we ensured values would evaluate at identical precision on different platforms. The problem of course is that this is rather cumbersome and difficult to maintain, everyone working on the code has to remember to wrap their floats when doing comparisons. It's also difficult to ensure all the comparisons are being wrapped, right now we can only tell that we've wrapped enough that simulations do not diverge after 10 years.
What I'd like to know:
1) Does it matter if the scheduler is (slightly) non-platform reproducible? This could become an issue if we want to check why the scheduler observed a certain pointing, and are debugging on a machine different from what the scheduler is running on.
2) If 1 is yes, what is the best way to enforce identical precision comparison on floats in python? Should we keep plowing ahead with wrapping floats in a special class? Maybe make a new function that does comparison at a fixed precision, e.g., float_compare(f1, <, f2, precision=1e-5)?
Consider https://docs.python.org/3.7/library/decimal.html ?