Skip to content

XTB updates#250

Merged
markuskowa merged 16 commits into
Nix-QChem:masterfrom
sheepforce:xtb
Feb 24, 2023
Merged

XTB updates#250
markuskowa merged 16 commits into
Nix-QChem:masterfrom
sheepforce:xtb

Conversation

@sheepforce
Copy link
Copy Markdown
Member

There is a new major release of the XTB programme. The surrounding infrastructure grew somewhat and XTB depends now on a lot of fortran libraries. The Fortran package manager seems to bring a modern build experience and package management to Fortran, finally ... :) However, I am a little bit worried about all the updates these many packages will require. Maybe we should also look into something like r-ryantm's automatic update bot. 😅

Also nearly all of them did some cmake mistake and require patching of the generated package-config files. At least the fix is quite easy.

@sheepforce sheepforce requested a review from markuskowa February 9, 2023 19:56
@sheepforce
Copy link
Copy Markdown
Member Author

At least one test of pysis is failing now. I will collect them and figure out what to do :)

@ryanswrt
Copy link
Copy Markdown

I just spent half of yesterday packaging these also, good job; one slight concern on my end was that even though everything compiled; generating the python libs ended up failing the checks with

       > Traceback (most recent call last):
       >   File "/build/python/tblite/library.py", line 28, in <module>
       >     from ._libtblite import ffi, lib
       > ImportError: /build/python/tblite/_libtblite.abi3.so: undefined symbol: __dftd3_model_MOD___vtab_dftd3_model_D3_model
       >
       > During handling of the above exception, another exception occurred:
       >
       > Traceback (most recent call last):
       >   File "/nix/store/xcaaly5shfy227ffs8nipxrd49b56iqq-python3-3.10.8/lib/python3.10/unittest/loader.py", line 436, in _find_test_path
       >     module = self._get_module_from_name(name)
       >   File "/nix/store/xcaaly5shfy227ffs8nipxrd49b56iqq-python3-3.10.8/lib/python3.10/unittest/loader.py", line 377, in _get_module_from_name
       >     __import__(name)
       >   File "/build/python/tblite/test_library.py", line 18, in <module>
       >     from tblite.library import get_version
       >   File "/build/python/tblite/library.py", line 30, in <module>
       >     raise ImportError("tblite C extension unimportable, cannot use C-API")
       > ImportError: tblite C extension unimportable, cannot use C-API

which made me doubt their lib-export setup; will try again against your tree

@sheepforce
Copy link
Copy Markdown
Member Author

At least one test of pysis is failing now. I will collect them and figure out what to do :)

There are 4 mismatches between atoms and None type errors now in pysisyphus now. Thus, unfortunately not only numerical deviations. I will talk with @eljost what to do.
Here is the relevant part:

python3.10-pysisyphus> =================================== FAILURES ===================================
python3.10-pysisyphus> ___________________________ test_endopt_total[True] ____________________________
python3.10-pysisyphus> do_hess = True, this_dir = PosixPath('/build/source/tests/test_barriers')
python3.10-pysisyphus>     @using("xtb")
python3.10-pysisyphus>     @pytest.mark.parametrize(
python3.10-pysisyphus>         "do_hess",
python3.10-pysisyphus>         (
python3.10-pysisyphus>             False,
python3.10-pysisyphus>             True,
python3.10-pysisyphus>         ),
python3.10-pysisyphus>     )
python3.10-pysisyphus>     def test_endopt_total(do_hess, this_dir):
python3.10-pysisyphus>         # ed, ts, prod = geom_loader("lib:xtb_rx/07_dacp_eth.trj")
python3.10-pysisyphus>         # print(geoms)
python3.10-pysisyphus>         run_dict = {
python3.10-pysisyphus>             "geom": {"type": "cart", "fn": "lib:xtb_rx/07_dacp_eth.trj[1]"},
python3.10-pysisyphus>             "calc": {
python3.10-pysisyphus>                 "type": "xtb",
python3.10-pysisyphus>                 "pal": 6,
python3.10-pysisyphus>                 "quiet": True,
python3.10-pysisyphus>             },
python3.10-pysisyphus>             "irc": {
python3.10-pysisyphus>                 "type": "eulerpc",
python3.10-pysisyphus>                 "hessian_init": this_dir / "inp_hess_init_irc.h5",
python3.10-pysisyphus>             },
python3.10-pysisyphus>             "endopt": {
python3.10-pysisyphus>                 "fragments": "total",
python3.10-pysisyphus>                 "do_hess": do_hess,
python3.10-pysisyphus>             },
python3.10-pysisyphus>             "barriers": {
python3.10-pysisyphus>                 "solv_calc": {
python3.10-pysisyphus>                     "type": "xtb",
python3.10-pysisyphus>                     "pal": 6,
python3.10-pysisyphus>                     # "quiet": True,
python3.10-pysisyphus>                     "gbsa": "water",
python3.10-pysisyphus>                 },
python3.10-pysisyphus>                 "do_standard_state_corr": True,
python3.10-pysisyphus>             },
python3.10-pysisyphus>         }
python3.10-pysisyphus> >       results = run_from_dict(run_dict)
python3.10-pysisyphus> tests/test_barriers/test_barriers.py:47:
python3.10-pysisyphus> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
python3.10-pysisyphus> pysisyphus/run.py:1991: in run_from_dict
python3.10-pysisyphus>     run_result = main(run_dict, restart, cwd, scheduler)
python3.10-pysisyphus> pysisyphus/run.py:1639: in main
python3.10-pysisyphus>     do_endopt_ts_barriers(
python3.10-pysisyphus> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
python3.10-pysisyphus> ts_geom = Geometry(C₇H₁₀), left_geoms = [Geometry(C₅H₆)]
python3.10-pysisyphus> right_geoms = [Geometry(C₇H₁₀)]
python3.10-pysisyphus> left_fns = ['forward_end_frag01_final_geometry.xyz', 'forward_end_final_geometry.xyz']
python3.10-pysisyphus> right_fns = ['backward_end_frag00_final_geometry.xyz'], do_thermo = False
python3.10-pysisyphus> T = 298.15, p = 101325
python3.10-pysisyphus> calc_getter = <function get_calc_closure.<locals>.calc_getter at 0x7ffeebd025f0>
python3.10-pysisyphus> solv_calc_getter = <function get_calc_closure.<locals>.calc_getter at 0x7ffeebd024d0>
python3.10-pysisyphus> do_standard_state_corr = True
python3.10-pysisyphus>     def do_endopt_ts_barriers(
python3.10-pysisyphus>         ts_geom,
python3.10-pysisyphus>         left_geoms,
python3.10-pysisyphus>         right_geoms=None,
python3.10-pysisyphus>         left_fns=None,
python3.10-pysisyphus>         right_fns=None,
python3.10-pysisyphus>         do_thermo=False,
python3.10-pysisyphus>         T=T_DEFAULT,
python3.10-pysisyphus>         p=p_DEFAULT,
python3.10-pysisyphus>         calc_getter=None,
python3.10-pysisyphus>         solv_calc_getter=None,
python3.10-pysisyphus>         do_standard_state_corr=False,
python3.10-pysisyphus>     ):
python3.10-pysisyphus>         print(highlight_text("Barrier heights after end optimization(s)"))
python3.10-pysisyphus>         print()
python3.10-pysisyphus>         # Only allow standard state correction when solvent calculator is specified.
python3.10-pysisyphus>         do_ssc = do_standard_state_corr and (solv_calc_getter is not None)
python3.10-pysisyphus>         ssc = standard_state_corr(T=T, p=p) if do_ssc else 0.0
python3.10-pysisyphus>         if right_geoms is None:
python3.10-pysisyphus>             right_geoms = []
python3.10-pysisyphus>         def set_fns(fns, geoms):
python3.10-pysisyphus>             if fns is None:
python3.10-pysisyphus>                 fns = ["" for geom in geoms]
python3.10-pysisyphus>             else:
python3.10-pysisyphus>                 fns = [Path(fn).name for fn in fns]
python3.10-pysisyphus>             return fns
python3.10-pysisyphus>         left_fns = set_fns(left_fns, left_geoms)
python3.10-pysisyphus>         right_fns = set_fns(right_fns, left_geoms)
python3.10-pysisyphus>         ts_fn = "TS"
python3.10-pysisyphus>         ts_atom_num = len(ts_geom.atoms)
python3.10-pysisyphus>         def drop_total_geom(geoms):
python3.10-pysisyphus>             atom_nums = [len(geom.atoms) for geom in geoms]
python3.10-pysisyphus>             tot_atom_num = sum(atom_nums)
python3.10-pysisyphus>             total_geom = None
python3.10-pysisyphus>             if tot_atom_num > ts_atom_num:
python3.10-pysisyphus>                 total_ind = atom_nums.index(max(atom_nums))
python3.10-pysisyphus>                 total_geom = geoms[total_ind]
python3.10-pysisyphus>                 geoms = [geom for i, geom in enumerate(geoms) if i != total_ind]
python3.10-pysisyphus>             return geoms, total_geom
python3.10-pysisyphus>         left_geoms, left_total_geom = drop_total_geom(left_geoms)
python3.10-pysisyphus>         right_geoms, right_total_geom = drop_total_geom(right_geoms)
python3.10-pysisyphus>         def tot_atom_num(geoms):
python3.10-pysisyphus>             return sum([len(geom.atoms) for geom in geoms])
python3.10-pysisyphus>         left_atom_num = tot_atom_num(left_geoms)
python3.10-pysisyphus> >       assert left_atom_num == ts_atom_num, (
python3.10-pysisyphus>             f"Atom number mismatch between TS ({ts_atom_num} atoms) and "
python3.10-pysisyphus>             f"left side ({left_atom_num} atoms)! Aborting barrier calculation"
python3.10-pysisyphus>         )
python3.10-pysisyphus> E       AssertionError: Atom number mismatch between TS (17 atoms) and left side (11 atoms)! Aborting barrier calculation
python3.10-pysisyphus> pysisyphus/drivers/barriers.py:65: AssertionError
python3.10-pysisyphus> _________________________ test_gen_guess_hessians[xtb] _________________________
python3.10-pysisyphus> hessian_init = 'xtb'
python3.10-pysisyphus>     @using("pyscf")
python3.10-pysisyphus>     @pytest.mark.parametrize(
python3.10-pysisyphus>         "hessian_init",
python3.10-pysisyphus>         (
python3.10-pysisyphus>             "calc",
python3.10-pysisyphus>             "unit",
python3.10-pysisyphus>             "fischer",
python3.10-pysisyphus>             "lindh",
python3.10-pysisyphus>             "simple",
python3.10-pysisyphus>             "swart",
python3.10-pysisyphus>             pytest.param("xtb", marks=[using("pyscf"), using("xtb")]),
python3.10-pysisyphus>             pytest.param("xtb1", marks=[using("pyscf"), using("xtb")]),
python3.10-pysisyphus>         ),
python3.10-pysisyphus>     )
python3.10-pysisyphus>     def test_gen_guess_hessians(hessian_init):
python3.10-pysisyphus>         geom = geom_loader("lib:h2o2_hf_321g_opt.xyz", coord_type="redund")
python3.10-pysisyphus>         geom.set_calculator(PySCF(basis="def2svp", pal=1))
python3.10-pysisyphus>         opt = RFOptimizer(geom, hessian_init=hessian_init)
python3.10-pysisyphus> >       opt.prepare_opt()
python3.10-pysisyphus> tests/test_guess_hessians/test_guess_hessians.py:72:
python3.10-pysisyphus> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
python3.10-pysisyphus> pysisyphus/optimizers/HessianOptimizer.py:237: in prepare_opt
python3.10-pysisyphus>     self.H, hess_str = get_guess_hessian(self.geometry, hessian_init)
python3.10-pysisyphus> pysisyphus/optimizers/guess_hessians.py:259: in get_guess_hessian
python3.10-pysisyphus>     H, hess_str = hess_funcs[hessian_init]()
python3.10-pysisyphus> pysisyphus/optimizers/guess_hessians.py:252: in <lambda>
python3.10-pysisyphus>     "xtb": lambda: (xtb_hessian(geometry, gfn=2), "GFN2-XTB"),
python3.10-pysisyphus> pysisyphus/optimizers/guess_hessians.py:215: in xtb_hessian
python3.10-pysisyphus>     return geom_.hessian
python3.10-pysisyphus> pysisyphus/Geometry.py:1022: in hessian
python3.10-pysisyphus>     hessian = self.cart_hessian
python3.10-pysisyphus> pysisyphus/Geometry.py:999: in cart_hessian
python3.10-pysisyphus>     results = self.calculator.get_hessian(self.atoms, self._coords)
python3.10-pysisyphus> pysisyphus/calculators/XTB.py:221: in get_hessian
python3.10-pysisyphus>     results = self.run(inp, **kwargs)
python3.10-pysisyphus> pysisyphus/calculators/Calculator.py:479: in run
python3.10-pysisyphus>     raise err
python3.10-pysisyphus> pysisyphus/calculators/Calculator.py:464: in run
python3.10-pysisyphus>     results = self.parser_funcs[calc](path, **parser_kwargs)
python3.10-pysisyphus> pysisyphus/calculators/XTB.py:365: in parse_hessian
python3.10-pysisyphus>     energy = self.parse_energy(path)
python3.10-pysisyphus> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
python3.10-pysisyphus> self = <pysisyphus.calculators.XTB.XTB object at 0x7fffc8f1d990>
python3.10-pysisyphus> path = PosixPath('/build/calculator_000_000_n2qur3ub')
python3.10-pysisyphus>     def parse_energy(self, path):
python3.10-pysisyphus>         with open(path / self.out_fn) as handle:
python3.10-pysisyphus>             text = handle.read()
python3.10-pysisyphus>         energy_re = r"TOTAL ENERGY\s*([-\d\.]+) Eh"
python3.10-pysisyphus> >       energy = float(re.search(energy_re, text)[1])
python3.10-pysisyphus> E       TypeError: 'NoneType' object is not subscriptable
python3.10-pysisyphus> pysisyphus/calculators/XTB.py:353: TypeError
python3.10-pysisyphus> ________________________ test_gen_guess_hessians[xtb1] _________________________
python3.10-pysisyphus> hessian_init = 'xtb1'
python3.10-pysisyphus>     @using("pyscf")
python3.10-pysisyphus>     @pytest.mark.parametrize(
python3.10-pysisyphus>         "hessian_init",
python3.10-pysisyphus>         (
python3.10-pysisyphus>             "calc",
python3.10-pysisyphus>             "unit",
python3.10-pysisyphus>             "fischer",
python3.10-pysisyphus>             "lindh",
python3.10-pysisyphus>             "simple",
python3.10-pysisyphus>             "swart",
python3.10-pysisyphus>             pytest.param("xtb", marks=[using("pyscf"), using("xtb")]),
python3.10-pysisyphus>             pytest.param("xtb1", marks=[using("pyscf"), using("xtb")]),
python3.10-pysisyphus>         ),
python3.10-pysisyphus>     )
python3.10-pysisyphus>     def test_gen_guess_hessians(hessian_init):
python3.10-pysisyphus>         geom = geom_loader("lib:h2o2_hf_321g_opt.xyz", coord_type="redund")
python3.10-pysisyphus>         geom.set_calculator(PySCF(basis="def2svp", pal=1))
python3.10-pysisyphus>         opt = RFOptimizer(geom, hessian_init=hessian_init)
python3.10-pysisyphus> >       opt.prepare_opt()
python3.10-pysisyphus> tests/test_guess_hessians/test_guess_hessians.py:72:
python3.10-pysisyphus> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
python3.10-pysisyphus> pysisyphus/optimizers/HessianOptimizer.py:237: in prepare_opt
python3.10-pysisyphus>     self.H, hess_str = get_guess_hessian(self.geometry, hessian_init)
python3.10-pysisyphus> pysisyphus/optimizers/guess_hessians.py:259: in get_guess_hessian
python3.10-pysisyphus>     H, hess_str = hess_funcs[hessian_init]()
python3.10-pysisyphus> pysisyphus/optimizers/guess_hessians.py:254: in <lambda>
python3.10-pysisyphus>     "xtb1": lambda: (xtb_hessian(geometry, gfn=1), "GFN1-XTB"),
python3.10-pysisyphus> pysisyphus/optimizers/guess_hessians.py:215: in xtb_hessian
python3.10-pysisyphus>     return geom_.hessian
python3.10-pysisyphus> pysisyphus/Geometry.py:1022: in hessian
python3.10-pysisyphus>     hessian = self.cart_hessian
python3.10-pysisyphus> pysisyphus/Geometry.py:999: in cart_hessian
python3.10-pysisyphus>     results = self.calculator.get_hessian(self.atoms, self._coords)
python3.10-pysisyphus> pysisyphus/calculators/XTB.py:221: in get_hessian
python3.10-pysisyphus>     results = self.run(inp, **kwargs)
python3.10-pysisyphus> pysisyphus/calculators/Calculator.py:479: in run
python3.10-pysisyphus>     raise err
python3.10-pysisyphus> pysisyphus/calculators/Calculator.py:464: in run
python3.10-pysisyphus>     results = self.parser_funcs[calc](path, **parser_kwargs)
python3.10-pysisyphus> pysisyphus/calculators/XTB.py:365: in parse_hessian
python3.10-pysisyphus>     energy = self.parse_energy(path)
python3.10-pysisyphus> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
python3.10-pysisyphus> self = <pysisyphus.calculators.XTB.XTB object at 0x7ffeeb789240>
python3.10-pysisyphus> path = PosixPath('/build/calculator_000_000_7v0v1sya')
python3.10-pysisyphus>     def parse_energy(self, path):
python3.10-pysisyphus>         with open(path / self.out_fn) as handle:
python3.10-pysisyphus>             text = handle.read()
python3.10-pysisyphus>         energy_re = r"TOTAL ENERGY\s*([-\d\.]+) Eh"
python3.10-pysisyphus> >       energy = float(re.search(energy_re, text)[1])
python3.10-pysisyphus> E       TypeError: 'NoneType' object is not subscriptable
python3.10-pysisyphus> pysisyphus/calculators/XTB.py:353: TypeError
python3.10-pysisyphus> _______________________________ test_xtb_hessian _______________________________
python3.10-pysisyphus> geom = Geometry(HClO₃S)
python3.10-pysisyphus>     @using("xtb")
python3.10-pysisyphus>     def test_xtb_hessian(geom):
python3.10-pysisyphus> >       Hmw = geom.mw_hessian
python3.10-pysisyphus> tests/test_xtb/test_xtb.py:34:
python3.10-pysisyphus> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
python3.10-pysisyphus> pysisyphus/Geometry.py:1051: in mw_hessian
python3.10-pysisyphus>     return self.mass_weigh_hessian(self.cart_hessian)
python3.10-pysisyphus> pysisyphus/Geometry.py:999: in cart_hessian
python3.10-pysisyphus>     results = self.calculator.get_hessian(self.atoms, self._coords)
python3.10-pysisyphus> pysisyphus/calculators/XTB.py:221: in get_hessian
python3.10-pysisyphus>     results = self.run(inp, **kwargs)
python3.10-pysisyphus> pysisyphus/calculators/Calculator.py:479: in run
python3.10-pysisyphus>     raise err
python3.10-pysisyphus> pysisyphus/calculators/Calculator.py:464: in run
python3.10-pysisyphus>     results = self.parser_funcs[calc](path, **parser_kwargs)
python3.10-pysisyphus> pysisyphus/calculators/XTB.py:365: in parse_hessian
python3.10-pysisyphus>     energy = self.parse_energy(path)
python3.10-pysisyphus> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
python3.10-pysisyphus> self = <pysisyphus.calculators.XTB.XTB object at 0x7ffe8ace90f0>
python3.10-pysisyphus> path = PosixPath('/build/calculator_000_000_j10b2p48')
python3.10-pysisyphus>     def parse_energy(self, path):
python3.10-pysisyphus>         with open(path / self.out_fn) as handle:
python3.10-pysisyphus>             text = handle.read()
python3.10-pysisyphus>         energy_re = r"TOTAL ENERGY\s*([-\d\.]+) Eh"
python3.10-pysisyphus> >       energy = float(re.search(energy_re, text)[1])
python3.10-pysisyphus> E       TypeError: 'NoneType' object is not subscriptable
python3.10-pysisyphus> pysisyphus/calculators/XTB.py:353: TypeError

@ryanswrt cool that you find it useful! 😊 I haven't even attempted to build the tblite python bindings, only xtb-python and this is already not the greatest experience. The previous version (before this MR) needed to copy shared object files manually into the proper places as the meson instructions were broken.
If you can figure this out I would love to have this included.

@sheepforce
Copy link
Copy Markdown
Member Author

@ryanswrt I was able to build the tblite python bindings. Seems to work from a python3 shell.

Comment thread pythonPackages.nix Outdated
@markuskowa
Copy link
Copy Markdown
Collaborator

pysisiphus fails on Hydra:

FAILED tests/test_barriers/test_barriers.py::test_endopt_total[True] - Assert...
FAILED tests/test_guess_hessians/test_guess_hessians.py::test_gen_guess_hessians[xtb]
FAILED tests/test_guess_hessians/test_guess_hessians.py::test_gen_guess_hessians[xtb1]
FAILED tests/test_xtb/test_xtb.py::test_xtb_hessian - TypeError: 'NoneType' o...

@sheepforce
Copy link
Copy Markdown
Member Author

pysisiphus fails on Hydra:

FAILED tests/test_barriers/test_barriers.py::test_endopt_total[True] - Assert...
FAILED tests/test_guess_hessians/test_guess_hessians.py::test_gen_guess_hessians[xtb]
FAILED tests/test_guess_hessians/test_guess_hessians.py::test_gen_guess_hessians[xtb1]
FAILED tests/test_xtb/test_xtb.py::test_xtb_hessian - TypeError: 'NoneType' o...

Yup, these are the exact four errors we also get. (See #250 (comment)). Working on it ...

@sheepforce
Copy link
Copy Markdown
Member Author

The failing tests are quite strange. They are complete numerical nonsense when run as is. Interestingly this does not seem to happen with the statically linked executable from the XTB repo. Now, even more interestingly, the problem only happens when xtb is called with --acc as pysisyphus does. It doesn't even matter which value it is given. The default is 1 and pysisyphus calls it with 1. However, having the parameter on XTB's command line will give nonsense either in the SCF already or latestly in the numerical Hessian calculation upon displacements. The calculation may arbitrarily hang, segfault, or complain about not being able to setup numerical thresholds.
I have tested whether it depends on the BLAS+Lapack implementation and OpenMP threads.
For BLAS, it does not matter. Neither generic BLAS, nor MKL nor OpenBLAS make any difference. Could also not observe anything reproducible for the number of threads. The same calculation may crash, hang or error with any number of threads.

Here is one of the examples that fails in pysisyphus:

xtb xtb.xyz --hess --input xcontrol --chrg 0 --uhf 0 --gfn 2 --acc 1.0

xyb.xyz:

4

  H -0.35738652 -2.42732105  0.01869782
  H -0.55575507  0.31681832  1.27512527
  O -0.71404094 -1.41851105  0.01869782
  O -0.20069873 -0.69255477  1.27610279

xcontrol:

$write
            json=true
        $end

It runs perfectly fine without --acc. The order of arguments does not matter, I've checked. XTB, tblite, ... pass all their tests, including those testing Hessians. I am clueless. Any ideas are appreciated. 😬

@markuskowa
Copy link
Copy Markdown
Collaborator

Is it built with the -ffast-math compiler flag?

@sheepforce
Copy link
Copy Markdown
Member Author

Is it built with the -ffast-math compiler flag?

Hm, couldn't find anything like it in the cmake flags

@sheepforce
Copy link
Copy Markdown
Member Author

Meh, here we go, even happens when completely following the toolchain of upstream XTB. That is, it even happens when building in a plain debian pod with fully embracing the cmake build system and building everything with buildtime downloads of deps. So

sudo apt install gfortran cmake build-essential git libopenblas-dev
git clone https://github.com/grimme-lab/xtb.git && cd xtb
cmake -B build -DCMAKE_BUILD_TYPE=Release
make -C build
make -C build test

In this case tblite also fails one test. Anyway, the behaviour is exactly the same. I would consider this an upstream bug. Should we open a bug report?

@markuskowa
Copy link
Copy Markdown
Collaborator

I would consider this an upstream bug. Should we open a bug report?

That would be good.

Is it built with the -ffast-math compiler flag?

Hm, couldn't find anything like it in the cmake flags

It could potentially also be a dependency of XTB that is built with -ffast-math and is causing the problem.

@sheepforce
Copy link
Copy Markdown
Member Author

I would consider this an upstream bug. Should we open a bug report?

That would be good.

grimme-lab/xtb#772

Is it built with the -ffast-math compiler flag?

Hm, couldn't find anything like it in the cmake flags

It could potentially also be a dependency of XTB that is built with -ffast-math and is causing the problem.

I have checked in tblite, mctc-lib and mstore. There were none.

@sheepforce
Copy link
Copy Markdown
Member Author

With the tooling for XTB in place, major parts of the DFTB+ infrastructure is also here. I've added those packages, also. This is unrelated to the numerical XTB problems, of course.

Comment thread pkgs/apps/fypp/default.nix Outdated
Comment thread pkgs/lib/mpifx/default.nix Outdated
Comment thread pkgs/lib/scalapackfx/default.nix Outdated
Comment thread pkgs/lib/scalapackfx/default.nix Outdated
Comment thread pkgs/lib/tblite/default.nix Outdated
@sheepforce
Copy link
Copy Markdown
Member Author

I have removed the --acc flag from the pysis systemcall to xtb. Unfortunately we are hitting the next problem now. The tests still fail with the same errors, although I've confirmed that --acc is not present anymore. However, the very same test passes now outside of the build sandbox. I've checked the envs within the sandbox and outside. Nothing suspicious so far. Even playing around with nested OMP_NUM_THREADS does not make a difference. I am completely lost why xtb would behave differently in the sandbox and outside of it.

@sheepforce
Copy link
Copy Markdown
Member Author

Even more: outside of the sandbox omitting the --input xcontrol makes the calculation hang, fail or segfault again, identical to what happens inside the sandbox. However, inside the sandbox the --input xcontrol has no effect on the bug.

@sheepforce
Copy link
Copy Markdown
Member Author

sheepforce commented Feb 22, 2023

For the moment I would assume that the XTB fix could take some time. The behaviour is rather strange, depends on fortran optimisation level, does not happen with IFort, is sensitive against parameters that have nothing to do with the actual calculation and so on.
As an alternative I am thinking about packaging the static XTB executable in addition and use this one for the moment, until the issue is resolved. This one is free of the described bugs. What is you opinion on this?

On a sidenote: Do you know why the flang compiler is not part of the llvm packages in nixpkgs? It would be quite interesting to see if FLang would give an executable with correct behaviour.

@markuskowa
Copy link
Copy Markdown
Collaborator

markuskowa commented Feb 22, 2023

As an alternative I am thinking about packaging the static XTB executable in addition and use this one for the moment, until the issue is resolved. This one is free of the described bugs. What is you opinion on this?

We can wait a little for a proper fix?
Btw. It seems that on Hydra it passes with the pinned nixpkgs (i.e., with gfortran11/gcc11). Downgrading the compiler versions could be a solution?
EDIT: May not help. I looked at the wrong Hydra.

On a sidenote: Do you know why the flang compiler is not part of the llvm packages in nixpkgs? It would be quite interesting to see if FLang would give an executable with correct behaviour.

I would guess that Fortran is not popular enough in the Nix community. No one just made the effort yet? Integrating compilers into the nixpkgs is no easy task.

@sheepforce
Copy link
Copy Markdown
Member Author

OK, let's wait then until we know more.

Btw. It seems that on Hydra it passes with the pinned nixpkgs (i.e., with gfortran11/gcc11). Downgrading the compiler versions could be a solution?
EDIT: May not help. I looked at the wrong Hydra.

It does unfortunately not help. On Debian I've used Debian's gfortran 10.2.1 and the issue is the same.

I would guess that Fortran is not popular enough in the Nix community. No one just made the effort yet? Integrating compilers into the nixpkgs is no easy task.

Hm, actually just found NixOS/nixpkgs#163878
Has been approved but not merged yet :/

@sheepforce
Copy link
Copy Markdown
Member Author

The bug has been fixed upstream and I could build pysisyphus without errors now. Should be ready :)

Comment thread pkgs/apps/dftbplus/default.nix Outdated
Comment thread pkgs/apps/xtb/default.nix Outdated
Comment thread pkgs/lib/dftd4/default.nix Outdated
Comment thread pkgs/lib/multicharge/default.nix Outdated
Comment thread pkgs/lib/scalapackfx/default.nix Outdated
Comment thread pkgs/lib/tblite/default.nix Outdated
sheepforce and others added 13 commits February 24, 2023 11:09
dftd4: blas lapack ILP64 assertions
multicharge: blas lapack ILP64 assertions
simple-dftd3: blas lapack ILP64 assertions
tblite: fix meta
xtb: blas lapack ILP64 assertions
xtb: use final patch version
tblite: blas lapack ILP64 assertions
fypp: remove leftovers
mpifx: remove leftovers
scalapackfx: check for ILP64


scalapackfx: blas lapack ILP64 assertions
dftbplus: blas lapack ILP64 assertions
pysisyphus: fix xtb patch


pysisyphus: remove xtb workaround again
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants