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

Nexus: add CPU/GPU flags for batched code #4341

Merged
merged 2 commits into from
Nov 23, 2022

Conversation

jtkrogel
Copy link
Contributor

Proposed changes

Add support for key inputs that control where data is stored and operated on. Relevant operations are those that save memory by allocating work on the host/CPU instead of the GPU.

Currently, the only two (common user) relevant points of control I've identified are 1) orbitals are stored/evaluated on CPU instead of GPU, 2) matrix inverse is performed on CPU instead of GPU.

What type(s) of changes does this code introduce?

  • New feature

Does this introduce a breaking change?

  • No

What systems has this change been tested on?

Laptop

Checklist

  • Yes. This PR is up to date with current the current state of 'develop'

@jtkrogel
Copy link
Contributor Author

@ye-luo is this valid input? I want to know if other "gpu" etc flags need to be set for this to work (place/evaluate orbitals and matrix inverse on host).

<?xml version="1.0"?>
<simulation>
   <project id="vmc" series="0">
      <parameter name="driver_version"      >    batched         </parameter>
      <application name="qmcpack" role="molecu" class="serial" version="1.0"/>
   </project>
   <qmcsystem>
      <simulationcell>
         <parameter name="lattice" units="bohr">
                  6.74632230        0.00000000        0.00000000
                  0.00000000        6.74632230        0.00000000
                  0.00000000        0.00000000        6.74632230
         </parameter>
         <parameter name="bconds">
            p p p
         </parameter>
         <parameter name="LR_dim_cutoff"       >    15                 </parameter>
      </simulationcell>
      <particleset name="e" random="yes" randomsrc="ion0">
         <group name="u" size="16" mass="1.0">
            <parameter name="charge"              >    -1                    </parameter>
            <parameter name="mass"                >    1.0                   </parameter>
         </group>
         <group name="d" size="16" mass="1.0">
            <parameter name="charge"              >    -1                    </parameter>
            <parameter name="mass"                >    1.0                   </parameter>
         </group>
      </particleset>
      <particleset name="ion0">
         <group name="C" size="8" mass="21894.71359057295">
            <parameter name="charge"              >    4                     </parameter>
            <parameter name="valence"             >    4                     </parameter>
            <parameter name="atomicnumber"        >    6                     </parameter>
            <parameter name="mass"                >    21894.71359057295            </parameter>
            <attrib name="position" datatype="posArray" condition="0">
                     0.00000000        0.00000000        0.00000000
                     1.68658058        1.68658058        1.68658058
                     3.37316115        3.37316115        0.00000000
                     5.05974172        5.05974172        1.68658058
                     0.00000000        3.37316115        3.37316115
                     1.68658058        5.05974172        5.05974172
                     3.37316115        0.00000000        3.37316115
                     5.05974172        1.68658057        5.05974172
            </attrib>
         </group>
      </particleset>
      <wavefunction name="psi0" target="e">
         <sposet_builder type="bspline" href="MISSING.h5" tilematrix="1 -1 1 1 1 -1 -1 1 1" twistnum="0" source="ion0" version="0.10" meshfactor="1.0" gpu="no" precision="float" truncate="no">
            <sposet type="bspline" name="spo_ud" size="16" spindataset="0"/>
         </sposet_builder>
         <determinantset>
            <slaterdeterminant matrix_inverter="host">
               <determinant id="updet" group="u" sposet="spo_ud" size="16"/>
               <determinant id="downdet" group="d" sposet="spo_ud" size="16"/>
            </slaterdeterminant>
         </determinantset>
         <jastrow type="One-Body" name="J1" function="bspline" source="ion0" print="yes">
            <correlation elementType="C" size="7" rcut="3.37316115" cusp="0.0">
               <coefficients id="eC" type="Array">                  
0 0 0 0 0 0 0
               </coefficients>
            </correlation>
         </jastrow>
         <jastrow type="Two-Body" name="J2" function="bspline" print="yes">
            <correlation speciesA="u" speciesB="u" size="7" rcut="3.37316115">
               <coefficients id="uu" type="Array">                  
0 0 0 0 0 0 0
               </coefficients>
            </correlation>
            <correlation speciesA="u" speciesB="d" size="7" rcut="3.37316115">
               <coefficients id="ud" type="Array">                  
0 0 0 0 0 0 0
               </coefficients>
            </correlation>
         </jastrow>
      </wavefunction>
      <hamiltonian name="h0" type="generic" target="e">
         <pairpot type="coulomb" name="ElecElec" source="e" target="e"/>
         <pairpot type="coulomb" name="IonIon" source="ion0" target="ion0"/>
         <pairpot type="pseudo" name="PseudoPot" source="ion0" wavefunction="psi0" format="xml">
            <pseudo elementType="C" href="C.BFD.xml"/>
         </pairpot>
         <pairpot type="MPC" name="MPC" source="e" target="e" ecut="60.0" physical="no"/>
      </hamiltonian>
   </qmcsystem>
   <qmc method="vmc" move="pbyp">
      <parameter name="warmupSteps"         >    50              </parameter>
      <parameter name="blocks"              >    50              </parameter>
      <parameter name="steps"               >    10              </parameter>
      <parameter name="subSteps"            >    3               </parameter>
      <parameter name="timestep"            >    0.3             </parameter>
      <parameter name="useDrift"            >    no              </parameter>
   </qmc>
</simulation>

@prckent
Copy link
Contributor

prckent commented Nov 23, 2022

By eye this looks correct and consistent with the manual.

@ye-luo
Copy link
Contributor

ye-luo commented Nov 23, 2022

LGTM.

@jtkrogel jtkrogel marked this pull request as ready for review November 23, 2022 20:06
@jtkrogel
Copy link
Contributor Author

OK, good. Let's move forward then.

@prckent
Copy link
Contributor

prckent commented Nov 23, 2022

Test this please

@prckent prckent self-requested a review November 23, 2022 20:53
@ye-luo ye-luo merged commit 7d401d9 into QMCPACK:develop Nov 23, 2022
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.

3 participants