Circuitscape.jl icon indicating copy to clipboard operation
Circuitscape.jl copied to clipboard

Single precision issues?

Open glaroc opened this issue 4 years ago • 7 comments

Hi, with the most recent version of Circuitscape and Julia 1.4.1 and using tiff files as inputs and outputs, I'm getting bad results when using precision = single. This is a pair-to-pair approach with rasters defining the pairs. Everything works with precision = double, but current maps with single precision contain mostly zeros and are have only a few values around the edge. Is anyone else experiencing the same issue? I can supply example files if needed.

glaroc avatar Aug 19 '20 14:08 glaroc

Definitely supply the example files. Is the single precision valuable in general? Which solver is being used?

ViralBShah avatar Aug 19 '20 20:08 ViralBShah

What do you mean by "Is the single precision valuable in general" ? I'm using the default cg+amg

glaroc avatar Aug 19 '20 20:08 glaroc

Here are test files.

https://www.dropbox.com/s/x060pn4ow6vhyxf/test_single_precision.zip?dl=0

glaroc avatar Aug 19 '20 20:08 glaroc

What I meant is - does single precision result in substantial enough savings in time or memory? If it is 10-20% or so, it may be best to remove the support - if it causes trouble. Assuming the problems are not too big, is it possible to try with cholmod? That might help understand where the issues might be.

@vlandau Would you be able to look into this?

ViralBShah avatar Aug 19 '20 20:08 ViralBShah

The time and memory (RAM) savings are in the order of 20-25%, so it's not a huge deal, but we do have to run this at least 10,000 times so it would make a difference in the end. I cannot run cholmod since the problem is quite big (resistance map has 13981977 nodes)

glaroc avatar Aug 19 '20 20:08 glaroc

Yes, those savings would add up. If it is an obvious bug of some kind, we should be lucky. This could be a deeper numerical solver thing, where the problem is ill-conditioned for Float32.

ViralBShah avatar Aug 19 '20 22:08 ViralBShah

My hunch is that it could be a numerical underflow issue during some part of the solver (or would Julia give a warning about that?)? If it is a numerical issue, something as simple as rescaling resistance (to be smaller) might work. I had a similar problem with Single precision long ago but didn't pursue it. I'm playing catch up with a bunch of things this week so I might not have time to get into it until next week.

@glaroc it would be super valuable if you could test the problem for a subset of your study area (to enable faster run time for debugging and to allow the possibility of running CHOLMOD to see if that helps).

vlandau avatar Aug 24 '20 16:08 vlandau

FWIW, Julia now has 32-bit support for sparse Cholesky.

ViralBShah avatar Feb 02 '24 00:02 ViralBShah