Skip to content

Conversation

abussy
Copy link

@abussy abussy commented Sep 30, 2025

This PR is part of an effort to port DFTK's stress and response calculations to the GPU. The main issue with the current implementation is that various types are not isbits. Any data passed to a GPU kernel must be isbits.

Changes:

  • Changed the type of functional parameters from ComponentArray to NamedTuple. Usage remains the same, while the new type is isbits.
  • Introduced a to_isbits() function that returns a isbits version of a functional. Issue is that the identifier field was restricted to be a Symbol, which is not isbits. The parametrization of the identifier is extended to accept Val, and the to_isbits() function returns a copy of the input functional with the identifier set to Val{identifier}()

With these changes (and a few more, for a later PR), it is possible to run DFTK stress calculations on the GPU.

Possible points of contention/discussion:

  • Some workaround is necessary to calculate the derivative of a functional wrt its parameters, since ForwardDiff expects functions to take Arrays as input (see runtests.jl and change_parameters dispatching in individual functional implementations)
  • Functional types are parametrized with plain NamedTuple, vs formerly ComponentArray{<:Number}. So the type of the individual parameters is not enforced. I am not 100% sure whether that is an issue.

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

Successfully merging this pull request may close these issues.

1 participant