Skip to content

Commit

Permalink
Update actions checkout and setup-python (fixes warning). (#277)
Browse files Browse the repository at this point in the history
The mpi tests failing was a red herring. The examples were failing
because of #278, this sent a signal to the other tests to fail but I'm
guessing the error was only received on the root process so the MPI jobs
would hang. I've set a timeout for these for the moment but there may be
a more sensible thing to do.
  • Loading branch information
fdmalone authored Dec 10, 2023
1 parent 293db7c commit e1c4854
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 181 deletions.
31 changes: 16 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ jobs:
python dev/run_tests.py --flynt
pytest-mpi4py:
strategy:
fail-fast: false
matrix:
python-version: [ '3.8', '3.9', '3.10' ]
mpi:
- openmpi
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64'
Expand All @@ -51,7 +52,8 @@ jobs:
pip install -r requirements.txt
pip install -r dev/dev.txt
pip install pyblock
pip install pyscf
# https://github.com/JoonhoLee-Group/ipie/issues/278
pip install "pyscf<=2.3.0"
- name: Install package
run: |
# HACK FOR LEGACY CODE!
Expand All @@ -60,12 +62,13 @@ jobs:
run: |
pip install pytest
pip install pytest-xdist
python -m pytest -n=auto
#python -m pytest -n=auto
- name: mpi test
timeout-minutes: 10
run: |
mpiexec -n 2 python -m pytest ipie/legacy/walkers/tests/test_handler.py
mpiexec -n 6 python -m pytest ipie/estimators/tests/test_generic_chunked.py
mpiexec -n 6 python -m pytest ipie/propagation/tests/test_generic_chunked.py
mpiexec --mca btl_tcp_if_include lo --mca oob_tcp_if_include lo -n 2 python -m pytest ipie/legacy/walkers/tests/test_handler.py
mpiexec --mca btl_tcp_if_include lo --mca oob_tcp_if_include lo -n 6 python ipie/estimators/tests/test_generic_chunked.py
mpiexec --mca btl_tcp_if_include lo --mca oob_tcp_if_include lo -n 6 python -m pytest ipie/propagation/tests/test_generic_chunked.py
pytest-no_mpi:
runs-on: ubuntu-latest
steps:
Expand All @@ -83,6 +86,8 @@ jobs:
python -c "from ipie.config import MPI; assert \"FakeComm\" in str(MPI.COMM_WORLD)"
python -m pytest -n=auto
integration:
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -104,29 +109,25 @@ jobs:
- name: Test Integration
timeout-minutes: 10
run: |
mpirun -np 4 python -u ipie/qmc/tests/test_mpi_integration.py
mpiexec --mca btl_tcp_if_include lo --mca oob_tcp_if_include lo -np 4 python -u ipie/qmc/tests/test_mpi_integration.py
examples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Setup MPI
uses: mpi4py/setup-mpi@v1
with:
mpi: openmpi
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r dev/dev.txt
pip install pyblock
pip install pyscf
# https://github.com/JoonhoLee-Group/ipie/issues/278
pip install "pyscf<=2.3.0"
- name: Install package
run: |
python -m pip install -e .
- name: Test Integration
- name: Test Examples
timeout-minutes: 10
run: |
python dev/run_tests.py --examples
101 changes: 0 additions & 101 deletions examples/02-multi_determinant/README.rst

This file was deleted.

60 changes: 44 additions & 16 deletions examples/02-multi_determinant/run_afqmc.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,40 @@
import h5py
import numpy
from mpi4py import MPI
from pyscf import fci, gto, mcscf, scf

from ipie.hamiltonians.generic import Generic as HamGeneric
from ipie.qmc.afqmc import AFQMC
from ipie.systems.generic import Generic
from ipie.hamiltonians.generic import Generic as HamGeneric
import h5py
from ipie.utils.from_pyscf import gen_ipie_input_from_pyscf_chk
from ipie.trial_wavefunction.particle_hole import ParticleHoleNonChunked
import scf
from ipie.utils.from_pyscf import gen_ipie_input_from_pyscf_chk

nocca = 4
noccb = 2

mol = gto.M(
atom=[("N", 0, 0, 0), ("N", (0, 0, 3.0))],
basis="ccpvdz",
verbose=3,
spin=nocca - noccb,
unit="Bohr",
)
mf = scf.RHF(mol)
mf.chkfile = "scf.chk"
ehf = mf.kernel()
M = 6
N = 6
mc = mcscf.CASSCF(mf, M, N)
mc.chkfile = "scf.chk"
e_tot, e_cas, fcivec, mo, mo_energy = mc.kernel()
coeff, occa, occb = zip(
*fci.addons.large_ci(fcivec, M, (nocca, noccb), tol=1e-8, return_strs=False)
)
# Need to write wavefunction to checkpoint file.
with h5py.File("scf.chk", "r+") as fh5:
fh5["mcscf/ci_coeffs"] = coeff
fh5["mcscf/occs_alpha"] = occa
fh5["mcscf/occs_beta"] = occb

comm = MPI.COMM_WORLD
gen_ipie_input_from_pyscf_chk("scf.chk", mcscf=True)
mol_nelec = [8, 6]

Expand All @@ -24,22 +50,23 @@
ham = HamGeneric(
numpy.array([h1e, h1e]),
chol.transpose((1, 2, 0)).reshape((num_basis * num_basis, num_chol)),
e0
e0,
)

# Build trial wavefunction
with h5py.File("wavefunction.h5", 'r') as fh5:
coeff = fh5['ci_coeffs'][:]
occa = fh5['occ_alpha'][:]
with h5py.File("wavefunction.h5", "r") as fh5:
coeff = fh5["ci_coeffs"][:]
occa = fh5["occ_alpha"][:]
occb = fh5["occ_beta"][:]
wavefunction = (coeff, occa, occb)
trial = ParticleHoleNonChunked(
wavefunction,
mol_nelec,
num_basis,
num_dets_for_props=len(wavefunction[0])
num_dets_for_props=len(wavefunction[0]),
verbose=True,
)
trial.compute_trial_energy = False
trial.compute_trial_energy = True
trial.build()
trial.half_rotate(ham)

Expand All @@ -53,8 +80,9 @@
num_blocks=10,
timestep=0.005,
stabilize_freq=5,
pop_control_freq=5
seed=96264512,
pop_control_freq=5,
verbose=True,
)
afqmc_msd.run()
afqmc_msd.finalise(verbose=True)

# afqmc_msd.run()
# afqmc_msd.finalise(verbose=True)
49 changes: 0 additions & 49 deletions examples/02-multi_determinant/scf.py

This file was deleted.

0 comments on commit e1c4854

Please sign in to comment.