Skip to content
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

Fix UKS gradient threading #2941

Closed
loriab opened this issue May 1, 2023 · 5 comments · Fixed by #2945
Closed

Fix UKS gradient threading #2941

loriab opened this issue May 1, 2023 · 5 comments · Fixed by #2945
Labels
Milestone

Comments

@loriab
Copy link
Member

loriab commented May 1, 2023

I just noticed that the UKS gradients are off when nthreads>1. Failing tests are: dft_grad_lr2, dft_grad_lr3, dft_grad_meta, dft-grad2. An example case is:

func_reference = psi4.Matrix.from_list([                         #TEST
 [ 0.,          0.,         -5.23600907e-02],                    #TEST
 [ 0.,          0.,          5.23600907e-02]])                   #TEST
cam_b3lyp_reference = psi4.Matrix.from_list([                    #TEST
 [ 0.,          0.,         -1.09138077e-01],                    #TEST
 [ 0.,          0.,          1.09137576e-01]])                   #TEST
func_uks_reference = psi4.Matrix.from_list([                     #TEST
 [ 0.,          0.,          1.77777928e-03],                    #TEST
 [ 0.,          0.,         -1.77777928e-03]])                   #TEST
cam_b3lyp_uks_reference = psi4.Matrix.from_list([                #TEST
 [ 0.,          0.,         -3.46813335e-02],                    #TEST
 [ 0.,          0.,          3.46809033e-02]])                   #TEST

molecule {
    H  0.000  0.000  0.000
    F  0.000  0.000  1.100
}

set {
    scf_type              df
    basis                 cc-pvdz
    dft_radial_points     120
    dft_spherical_points  434
    e_convergence         12
    d_convergence         10
    points 5
}

molecule {
    1 2
    H  0.000  0.000  0.000
    F  0.000  0.000  1.100
}

set reference uks

anl_grad = gradient('scf', dft_functional="CAM-B3LYP", dertype=1)
fd_grad = gradient('scf', dft_functional="CAM-B3LYP", dertype=0)
compare_matrices(cam_b3lyp_uks_reference, anl_grad, 6, "Analytic vs Reference CAM Gradients")    #TEST
compare_matrices(anl_grad, fd_grad, 4, "Analytic vs FD CAM Gradients")    #TEST
@loriab loriab added the bug label May 1, 2023
@loriab loriab added this to the Psi4 1.8 milestone May 1, 2023
@JonathonMisiewicz
Copy link
Contributor

The bug was introduced in #2839, which parallelized UKS gradients. I assumed the feature was ready to go, somebody had just forgotten to enable it, but apparently not.

I'll fix this before the release.

@susilehtola
Copy link
Member

The bug was introduced in #2839, which parallelized UKS gradients. I assumed the feature was ready to go, somebody had just forgotten to enable it, but apparently not.

The question is why was this not caught by the test suite..?

@JonathonMisiewicz
Copy link
Contributor

I recall that the test suite runs in serial. We'd love a parallel version, but @loriab has had other priorities.

Do correct me if I'm wrong.

@loriab
Copy link
Member Author

loriab commented May 2, 2023

The parallel test suite is a matter of adding -n2 in 2-3 places. I really should make it an option. CI (that won't tell us how many threads are even available) hasn't been the best place for running a parallel suite.

@q-posev
Copy link
Contributor

q-posev commented May 2, 2023

GitHub runners with Ubuntu have 2 cores, the MacOS ones have 3. Source

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants