pyscf-ipu icon indicating copy to clipboard operation
pyscf-ipu copied to clipboard

nanoDFT fails with OOM with IPU backend

Open hatemhelal opened this issue 1 year ago • 7 comments

The default choice of 6-31G for the basis set results in nanoDFT failing with OOM when targeting the IPU backend.

repro:

python nanoDFT.py --backend ipu --float32 True

possible workaround:

python nanoDFT.py --backend ipu --float32 True --basis sto-3g

but it would be a better overall experience if the defaults worked out of the box for the IPU.

cc: @ajwilkinson

hatemhelal avatar Aug 09 '23 09:08 hatemhelal

@AlexanderMath is there any reason to prefer using the 6-31G basis by default? I'd like to make sto-3g the default.

hatemhelal avatar Aug 09 '23 09:08 hatemhelal

The nanoDFT notebook already implements the suggested workaround

opts, _ = nanoDFT_options(backend="ipu", float32=True, basis="sto-3g")

hatemhelal avatar Aug 09 '23 10:08 hatemhelal

No reason, sto3g default sounds reasonable for initial playing around with code. We probably removed a few memory optimizations from nanoDFT in favor of simplicity, hence the OOM. Did anyone reproduce bug for density_functional_theory.py ?

AlexanderMath avatar Aug 09 '23 11:08 AlexanderMath

Fixed the default in nanoDFT in 90dc61c

Did anyone reproduce bug for density_functional_theory.py ?

Haven't tried this yet.

hatemhelal avatar Aug 09 '23 11:08 hatemhelal

Ok so it now does work on a classic with sto-3g... one observation though is that it compiles every time - is that me being some sort of noob and not configuring something in the poplar environment to cache a previous compilation?

ajwilkinson avatar Aug 09 '23 13:08 ajwilkinson

Documentation is spread over quite a few resources. The notebooks both use the executable cache from the env var:

# JAX/XLA IPU compilation cache.
os.environ['TF_POPLAR_FLAGS'] = """
  --executable_cache_path=/tmp/ipu-ef-cache
"""

Can you try this out if you aren't using it already?

That said, I would expect to see recompilation if you are changing the molecular structure (e.g. adding/removing atoms) or the basis set.

hatemhelal avatar Aug 09 '23 13:08 hatemhelal

Added the following to both density_functional_theory.py and nanoDFT.py so it caches by default.

os.environ['TF_POPLAR_FLAGS'] = """--executable_cache_path=/tmp/ipu-pyscf-cache/"""

Note: The computational graph shouldn't change between molecules with the same number of atomic orbitals, so changing from [C, O] to [N, F] should not cause a recompilation.

AlexanderMath avatar Aug 09 '23 14:08 AlexanderMath