NSan: a floating-point numerical sanitizer
dl.acm.org
dl.acm.org
If you want something that does not require modifying your source code, I would recommend Verrou [1], a Valgrind-based tool using stochastic arithmetic.
For those interested in the subject, my PhD [1] (which is written in English despite the French title) gives further information on all those methods, their pros and cons.
[0]: https://gitlab.com/numerical_shaman/shaman [1]: https://github.com/edf-hpc/verrou [2]: https://tel.archives-ouvertes.fr/tel-03116750
Here's the PR for my Haskell implementation: https://github.com/noinia/hgeometry/pull/120
Here's the documentation: https://noinia.github.io/hgeometry/doc/hgeometry-combinatori...
The specific faults we were taught about back then, would seem to be accumulated, loop embedded rounding error. Is there some other calls of merit it can handle? I took (40 years ago) a message that precision and repetition went hand in hand in this problem. I could see that eg incorrect precision handling across function call boundaries could promote ints to speciously accurate floats maybe, but that's a trivially detected type problem surely?
Not saying this isn't good work. Seeking clue about its scale and applicability.
In general you can be taking textbook accurate math based on rock solid proofs and then when you turn it into code it's busted, so nsan seems like it could be really valuable for flushing out some of those problems.
Then consider that some linear algebra and simple functions like softmax and softplus have to be implemented for fast execution in float16 and bfloat16 supporting hardware.
You can iterate over the entire fp16 space quite quickly but the initial version isn't usually so thoroughly tested.. performance is king anyway in NNs. Then a couple months later someone ports an old model to V100 and it turns out your softplus underflows.
Guess how many weeks it takes to figure out why your model quality went to s**?
I remain in awe. All those jokes about real programmers are wrong. Real programmers take great care.
Most people doing triangulation by ear clipping are trying to rasterize shapes. In the past, cairo (the 2d graphics library) had a bug that would cause crashes/hangs in Firefox because a VPN driver was changing the floating point state on random threads... which would cause one of those geometric algorithms to break.
Linear algebra routines usually have a severe trade-off between speed and accounting for those sorts of errors (such accounting is usually implemented as some kind of search for the best order to do a set of operations), when they can even be handled.
If your inputs are nice enough (which is often the case) then it could very well be that none of the above matters and you can go full speed ahead with the fastest and most error prone solutions, but feasibly I could see something like this allowing you to detect early on which snippets might need extra attention due to the nature of typical inputs in those locations.
1. The problem of small denominators. This is analogous to the subtraction issue, but it was observed and well-studied in the 19th century itself, in the context of celestial mechanics. It is fundamentally difficult to implement these numerically [1].
2. Whenever there are algorithms which depend on a "discontinuous" choice of a pivot in order to proceed, numerical instability may follow. This is why Gaussian elimination and Gram-Schmidt orthonormalization are numerically unstable, and other algorithms like Householder transformation are preferred instead [2].
A very detailed reference on stability issues is the book by Higham [3]. Some of these are floating point issues.
[1] http://www.mathnet.ru/php/archive.phtml?wshow=paper&jrnid=rm...
[2] https://en.wikipedia.org/wiki/Householder_transformation
[3] https://epubs.siam.org/doi/book/10.1137/1.9780898718027?mobi...
They detect local errors but also take propagation (amplification and dampening of error) into account to evaluate the numerical accuracy of the final result.
EDIT: Though it does note that it is for publication in March, so it might not be intended to be generally available yet.
[0]: https://cdn.remexre.xyz/screenshots/842f6f91029e6d956cb287d6...
I don't think the journal is actually published yet.