-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Numpy operations on sparsed derivatives #124
Comments
Hi @VondrakMar! We use the Another option is to convert to other formats for the operations. Converting to There are some additional details in our docs. |
Hey @lauri-codes, I rewrote my code with a sparse library. However, are derivatives transformed to the sparse output in one go AFTER all of them are computed? I mean, if my derivatives of 1 system are filling my memory even before finishing their computation, will they fill the memory the same way even with sparse = True? (I went very briefly through the code, and I think this is what is happening? But I am really not sure...) Thank you again for your answer, |
Hi @VondrakMar: Good question: The implementation is such that at most we keep the dense form for one system at a time per process. So when using multiple systems, each system gets translated to the sparse form when stored to the final result before moving on to the next system. It would be possible to use the sparse form throughout the process, but this would be quite tedious to implement, as the sparse arrays are not a simple drop-in replacement on the C++ side. I guess you are hitting the limits of your system memory: how big systems are you dealing with and how many |
Hey @lauri-codes However, I am pretty sure that it should be possible to fit sparsed derivatives into the memory. Now I think that Just calculate neighbor list with cutoff extended by However, thank you for your answer, |
Hey @lauri-codes, I did change my code to use import numpy as np
from ase.build import bulk,make_supercell
from dscribe.descriptors import SOAP
a2 = bulk('Cu', 'fcc', a=3.6, orthorhombic=True)
newMol = make_supercell(a2,[[5,0,0],[0,5,0],[0,0,5]])
soap = SOAP(
n_max = 4,
l_max = 3,
r_cut = 2,
sigma = 1,
periodic=True,
species=["Cu"]
derW,descW = soap.derivatives(newMol,attach=True)
der,desc = soap.derivatives_single(newMol,centers=[5],indices=[4],attach=True)
print(der[0][0][0]/derW[5][4][0]) # 1s
der,desc = soap.derivatives_single(newMol,centers=[5],indices=[5],attach=True)
print(der[0][0][0]/derW[5][5][0]) # not 1s
derW,descW = soap.derivatives(newMol,attach=False)
der,desc = soap.derivatives_single(newMol,centers=[5],indices=[5],attach=True)
print(der[0][0][0]/derW[5][5][0]) # 1s again
derW,descW = soap.derivatives(newMol,attach=True)
der,desc = soap.derivatives_single(newMol,centers=[0],indices=[0],attach=True)
print(der[0][0][0]/derW[0][0][0]) # 1s again If indices and centers are the same (and are not 0s), it is calculated as if |
May I have a question about math operation on the sparse output of the descriptor, please?
I would like to do numpy operations on the sparse output. E.g., I want to do np.moveaxis, and einstein summation (attached code is creating derivatives of normalized soap).
As far as I know, this is not possible with the sparse output, and I would have to create dense array with
.todense()
? Or is there a way how to do a math operations?At the end I am creating a neighbors list and want to do a matrix multiplication w.r.t. my pair list, so I would really like to keep a sparse representation until this moment, since my memory is exploding with a dense one.
Thank you for your answer
Best,
Martin
The text was updated successfully, but these errors were encountered: