There seems to be a memory leak when descriptors in a long running loop - seems like python can't clear away previously created objects. While the use case in which this behavior manifests isn't necessarily a typical usecase (I'm testing out different coarse-grained configurations on the same underlying AA configuration), this behavior isn't correct.
If I run the MWE below, the memory will slowly balloon over time.
MWE:
from featomic.calculators import SoapPowerSpectrum
from ase.io import read
def soapify(frames, batchsize=1000, rcut=30, disable_progressbar=True):
""" Splits frames into batches """
HYPER_PARAMETERS = {
"cutoff": {
"radius": rcut,
# "smoothing": {"type": "ShiftedCosine", "width": 0.5},
"smoothing": {"type": "Step"},
},
"density": {
"type": "Gaussian",
"width": 5.0,
},
"basis": {
"type": "TensorProduct",
"max_angular": 4,
"radial": {"type": "Gto", "max_radial": 6},
},
}
calculator = SoapPowerSpectrum(**HYPER_PARAMETERS)
soap_batches = []
for i in tqdm(range(0, len(frames), batchsize), disable=disable_progressbar):
desc = calculator.compute(frames[i:i+batchsize])
desc = desc.keys_to_samples("center_type")
desc = desc.keys_to_properties(["neighbor_1_type", "neighbor_2_type"])
soap_batches.append(desc)
return soap_batches
if __name__ == "__main__":
frames = read("frames.xyz", ":") # 10,000 frames, 175 atoms per frame.
for i in range(500):
desc = soapify(frames)
... # do a calculation with desc, but each iteration is independent from each other so desc should be overwritten and garbage collected.
There seems to be a memory leak when descriptors in a long running loop - seems like python can't clear away previously created objects. While the use case in which this behavior manifests isn't necessarily a typical usecase (I'm testing out different coarse-grained configurations on the same underlying AA configuration), this behavior isn't correct.
If I run the MWE below, the memory will slowly balloon over time.
MWE: