flare icon indicating copy to clipboard operation
flare copied to clipboard

Bug: Python API cannot save trained model (Segmentation fault, list index out of range)

Open m-a-saleh opened this issue 1 year ago • 8 comments

Describe the bug After training an SGP model using Python, I am not able to save the model. Using sgp_calc.write_model('my_model.json') generates empty "my_model.json" file, and gives the following error:

Traceback (most recent call last):
  File "train_validate.py", line 289, in <module>
    sgp_calc.write_model('my_model.json') #save the the trained model
  File "/home/saleh/miniconda3/envs/flare/lib/python3.8/site-packages/flare/bffs/sgp/calculator.py", line 158, in write_model
    json.dump(self.as_dict(), f, cls=NumpyEncoder)
  File "/home/saleh/miniconda3/envs/flare/lib/python3.8/site-packages/flare/bffs/sgp/calculator.py", line 139, in as_dict
    out_dict["gp_model"] = self.gp_model.as_dict()
  File "/home/saleh/miniconda3/envs/flare/lib/python3.8/site-packages/flare/bffs/sgp/sparse_gp.py", line 205, in as_dict
    train_struc.info["rel_efs_noise"] = np.array(self.rel_efs_noise[s])
IndexError: list index out of range

The bug is: in "sparce_sgp.py", the lists self.atom_indices and self.rel_efs_noise are initialized to empty but never get populated and stay empty.

On the other hand, using sgp_calc.build_map("lmp.flare", "my_name") generates empty "lmp.flare" file and gives the following error:

Segmentation fault (core dumped)

To Reproduce In the example given here, just add sgp_calc.write_model('my_model.json') and sgp_calc.build_map("lmp.flare", "my_name") to the end of the script.

Expected behavior Write "my_model.json" and "lmp.flare" model files.

Desktop (please complete the following information):

  • OS: [Ubuntu 20 LTS]
  • flare version: 1.3.3 and development

m-a-saleh avatar Dec 06 '23 17:12 m-a-saleh