-
Notifications
You must be signed in to change notification settings - Fork 89
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
Make some computations in DFTK GPU-compatible #712
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…h no SCF solver (solver=scf_damping_solver(1.0)) and just one Kinetic term.
mfherbst
reviewed
Nov 18, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nits
mfherbst
reviewed
Nov 21, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, minor nits and good to merge! I like the to_cpu and to_device!
mfherbst
reviewed
Nov 22, 2022
Congrats! This is great :) |
Thanks a lot! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a followup of this one, which implements GPU compatibility for LOBPCG. If you have any questions/remarks as to how LOBPCG works, please refer to this other PR.
The goal of the following PR is to implement GPU compatibility for some computations made by DFTK. This mainly means modifying the PlaneWaveBasis so it can store GPUArrays, and extending the
apply!
functions to allow the Hamiltonian and its operators to be applied to GPUArrays.From an end user perspective, the only thing that changes is when he builds the basis. There is now an optional argument
array_type
which tells the code which type of array structure should be used. For example :The end-user can then call the SCF with either
basis
orbasis_gpu
.I used CUDA since I have an NVIDIA GPU, but this part of the code should also work with other GPUs, since I did not use any CUDA-specific function.
Things that I already know could be greatly improved:
mean_kin
to the GPU. That would require some work, as it means we would have to rewriteldiv!
andmul!
(which right now does a lot of scalar indexing).The other thing would be to buildkin
directly on the GPU instead of building it on CPU then offloading it (which is currently being done). In order to do this, we would needGplusk_vectors_cart
to return a GPUArray: this means thatG_vectors(basis, kpoint)
should return a GPUArray, ie thatkpt.G_vectors
should be on GPU. And this is going to be quite hard, as it means that we would have to rewrite every function callingG_vectors(basis, kpoint)
to be GPU-compatible.scf_damping_solver
works fine, but notscf_anderson_solver
as I didn't manage to write it in a GPU-compatible way.Edit: Two big changes:
compute_density
) have to bring those arrays back on the CPU, as they do scalar indexing. This could be improved if it is performance-critical.βs
, which should really be fine as it isn't a big vector.