-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Move `fciqmc_step!` into Intefaces (?) * Rework initiator dvec * Move operator-vector function to DictVectors * Add PDVecs and friends * some fixes and reworking * Fix MPI communication * Fix mpi_recv_any signature * Add tests * Fix bugs with dot and initiators, add MPI tests * Remove annihilation tracking workaround * Benchmark PDVec instead * Some cleaning in Hamiltonains, make PDVec the default. * Fix error caused by moving things around * Doc updates * Move hacks to pdworkingmemory * temp * Fix up after rebase * Change which project mpi_runtests is run from * instantiate MPI deps before test * Another attempt to fix MPI CI * Attempt to fix MPI CI again * using -> import * Add debugging info to job * Fix benchmark, do MPI first * MPI tests without MPI * Fix project paths * Fix install of MPI deps * Fix deps * Fix Pkg stuff * Fix deprecations in RMPI * Restore ordering, fixing errors. * Fix three-argument dotting issues * Benchmark with threads=auto * Attempt to add coverage for MPI * Fix more depwarns in RMPI * Fix even more depwarns; fix benchmark * Fix depwarn * Fix MPI probing * Split testing into phases * Fix yml * Re-rework actions * Change MPI coverage tracking * Remove dead code * Removed too much dead code * Remove foreach calls that modify LHS. * Reordering, more docs * Fix the doctest * Fix tests * Fix bug in AllOverlaps * Change example to regular code listing * Minor fix in tests, bugfix * skip some tests * Improve coverage and fix bugs * Remove folds from testset * Add distributed dot tests, remove dead code, reenable threads in testing * fix yml * Fix randomness in dot tests * Docstring fixup * Alleviate type instability * Make example numerically stable * Refix type instability * Fix doctests * enable colors, don't test PDVec docstring * Update src/DictVectors/communicators.jl Co-authored-by: christofbradly <[email protected]> * Update src/strategies_and_params/replicastrategy.jl Co-authored-by: christofbradly <[email protected]> * Change default vector choice, include it in docs. * Rename functions * Fix up docs * Keep executor in similar, fix `length` for working memory * Use PDVec in MPI example * Add an extension for using Rimu with KrylovKit (#187) * Add an extension for using Rimu with KrylovKit * Add the actual extension * Loosen the version requirement * Add KrylovKit to [extras] * Fix broken dot * Use starting address that does not produce a vector that is orthogonal to the groundstate * Remove method that provides starting vector. * apply bitstring fix * `PDVec` with tuples (#188) * Replace vectors with tuples, remove executors * add fix * doc tweak * Remove the option of setting the number of segments * Fix bugs and tests * single-segment optimization * fix depwarn * remove rogue num_segments * improve test coverage * fix mpi test * fix some dots * Merge branch 'feature/pdvec' of github.com:joachimbrand/Rimu.jl into feature/pdvec * Fix equality for `DVec` * Fix constructor and tests * Make bangbang functions work properly * checkpoint * checkpoint * set version for release * Fixes after merge * Update Project.toml version * Fix KrylovKit extension * fix MPI tests * Fix mul with deterministic vectors * `add!` -> `dict_add!` * docstring for `dict_add!`, remove `propagators.jl` * Remove mentions of `OperatorMulPropagator` * attempt at fixing type instability * Introduce FrozenPDVec for faster projected energy * Small fixes * Fix diagonal operator spawning * fix some type instabilities * Rework benchmarks - trial run * Update Project.toml * Update tune file * re-update benchmarks * Remove type stability enforcing * Add see also to all DVec types * CI setup * Remove unused parameter * Fix compression bug * Fix the benchmark setup * Fix docs issues * Fix compression issues * Doc improvements * Fix bug in tests, docstring * Docstring fix * Remove unused dependency, clean up example script * Review comments * Add MPI docs, review comments * Apply suggestions from code review Co-authored-by: Joachim Brand <[email protected]> Co-authored-by: christofbradly <[email protected]> * Update MPI doc * add `PDVecKeys/Vals/Pairs` docstrings * filter(!), out-of-place map, fix potential bug in map! * Fix doc links * Fix new code * Another bugfix * One more * Fix bug in filter! * Fix wrong method call * Remove type from `f` in `filter` * Fix method errors * Update docs/src/mpi.md Co-authored-by: christofbradly <[email protected]> * bump version * bump version --------- Co-authored-by: christofbradly <[email protected]> Co-authored-by: Joachim Brand <[email protected]> Co-authored-by: Joachim Brand <[email protected]>
- Loading branch information
1 parent
b836c95
commit 2825da8
Showing
32 changed files
with
2,243 additions
and
206 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "Rimu" | ||
uuid = "c53c40cc-bd84-11e9-2cf4-a9fde2b9386e" | ||
authors = ["Joachim Brand <[email protected]>"] | ||
version = "0.9.1-dev" | ||
version = "0.10.0" | ||
|
||
[deps] | ||
Arrow = "69666777-d1a9-59fb-9406-91d4454c9d45" | ||
|
@@ -39,6 +39,12 @@ TerminalLoggers = "5d786b92-1e48-4d6f-9151-6b4477ca9bed" | |
TupleTools = "9d95972d-f1c8-5527-a6e0-b4b365fa01f6" | ||
VectorInterface = "409d34a3-91d5-4945-b6ec-7529ddf182d8" | ||
|
||
[weakdeps] | ||
KrylovKit = "0b1a1467-8014-51b9-945f-bf0ae24f4b77" | ||
|
||
[extensions] | ||
KrylovKitExt = "KrylovKit" | ||
|
||
[compat] | ||
Arrow = "1.5, 2" | ||
BSON = "0.3" | ||
|
@@ -50,6 +56,7 @@ Distributions = "0.25" | |
FFTW = "1" | ||
Folds = "0.2" | ||
HypergeometricFunctions = "0.3" | ||
KrylovKit = "0.6" | ||
MPI = "0.20" | ||
MacroTools = "0.5" | ||
Measurements = "2" | ||
|
@@ -72,6 +79,7 @@ VectorInterface = "0.2, 0.3, 0.4" | |
julia = "1.7" | ||
|
||
[extras] | ||
KrylovKit = "0b1a1467-8014-51b9-945f-bf0ae24f4b77" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[targets] | ||
|
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# Working with MPI | ||
|
||
If you are using [`PDVec`](@ref Main.DictVectors.PDVec)s to store your vectors, working with | ||
MPI should be fairly straightforward. Generally, [`PDVec`](@ref Main.DictVectors.PDVec) will | ||
work with MPI automatically, as long as MPI is set up correctly and a few common pitfalls | ||
are avoided. | ||
|
||
Rimu includes an unexported module [`RMPI`](@ref Main.Rimu.RMPI), which must be imported to access | ||
additional MPI-related functionality. | ||
|
||
## Configuring MPI | ||
|
||
When running on a cluster, ensure that MPI.jl is using the system binary. See [the MPI.jl | ||
documentation](https://juliaparallel.org/MPI.jl/latest/configuration/) for more information. | ||
|
||
It is always a good idea to start your script with a quick test that ensures the MPI is set up correctly. One way to do this is to open with | ||
|
||
```julia | ||
using Rimu.RMPI | ||
mpi_allprintln("hello") | ||
``` | ||
|
||
which should print something like | ||
|
||
``` | ||
[ rank 0: hello | ||
[ rank 1: hello | ||
[ rank 2: hello | ||
[ rank 3: hello | ||
``` | ||
|
||
If it prints `rank 0` several times, the code will run, but ranks will not communicate. | ||
|
||
## Using Slurm | ||
|
||
When using [`PDVec`](@ref Main.DictVectors.PDVec), the recommended setup is to use threads to parallelise the | ||
computation within a node, and to only use MPI for inter-node communication. In a slurm | ||
script, this is done as follows: | ||
|
||
```bash | ||
... | ||
#SBATCH --ntasks-per-node=1 | ||
#SBATCH --nodes=4 # replace 4 with the desired number of nodes | ||
#SBATCH --cpus-per-task=28 # replace 28 with the number of cores available in a node | ||
#SBATCH --hint=nomultithread # don't use hyperthreading | ||
... | ||
|
||
srun julia --project -tauto script.jl | ||
``` | ||
|
||
On some clusters, additional settings must be used with `srun`, for example the CTCP cluster | ||
requires the following. | ||
|
||
```bash | ||
srun mpi=pmi2 julia --project -tauto script.jl | ||
``` | ||
|
||
## Common pitfalls with reducing functions | ||
|
||
### Using `@mpi_root` | ||
|
||
Take care to not use reducing functions (such as `length`, `sum`, `norm`, ...) inside | ||
[`@mpi_root`](@ref Main.Rimu.RMPI.@mpi_root) blocks. Doing so will only initiate the | ||
distributed reduction on one rank only, which will cause the code to go out of sync and | ||
freeze. As an example, to report the current length of a vector, calculate the length before | ||
the [`@mpi_root`](@ref Main.Rimu.RMPI.@mpi_root) block: | ||
|
||
```julia | ||
len = length(pdvec) | ||
@mpi_root println("vector length is $len") | ||
``` | ||
|
||
## Threaded operations and reductions | ||
|
||
When using functions that take anonymous functions, such as `map(!)`, `sum`, or `mapreduce`, it is important that the anonymous functions passed to them do not perform any MPI-reducing operations (`length`, `norm`, `sum`, etc.). These anonymous functions are executed on multiple threads and initiating MPI communication from multiple threads may cause issues. | ||
|
||
As an example, suppose we want to scale a vector by its length by using `map!`. The correct way to write this code is as | ||
|
||
```julia | ||
len = length(pdvec) | ||
map!(values(pdvec)) do x | ||
x / len | ||
end | ||
``` | ||
|
||
Similar to the previous example, `len` is calculated first and not within the body of | ||
`map!`. In this specific case, an even better option is to use the `scale!` function from | ||
[VectorInterface.jl](https://github.com/Jutho/VectorInterface.jl): | ||
|
||
```julia | ||
scale!(pdvec, 1 / length(pdvec)) | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
module KrylovKitExt | ||
|
||
using Rimu | ||
using KrylovKit | ||
using LinearAlgebra | ||
|
||
const U = Union{Symbol,EigSorter} | ||
|
||
""" | ||
OperatorMultiplier | ||
A struct that holds the working memory for repeatedly multiplying vectors with an operator. | ||
""" | ||
struct OperatorMultiplier{H,W<:PDWorkingMemory} | ||
hamiltonian::H | ||
working_memory::W | ||
end | ||
function OperatorMultiplier(hamiltonian, vector::PDVec) | ||
return OperatorMultiplier(hamiltonian, PDWorkingMemory(vector; style=IsDeterministic())) | ||
end | ||
|
||
function (o::OperatorMultiplier)(v) | ||
result = zerovector(v) | ||
return mul!(result, o.hamiltonian, v, o.working_memory) | ||
end | ||
|
||
function KrylovKit.eigsolve( | ||
ham::AbstractHamiltonian, vec::PDVec, howmany::Int=1, which::U=:LR; kwargs... | ||
) | ||
# Change the type of `vec` to float, if needed. | ||
v = scale!!(vec, 1.0) | ||
prop = OperatorMultiplier(ham, v) | ||
return eigsolve( | ||
prop, v, howmany, which; | ||
ishermitian=ishermitian(ham), issymmetric=issymmetric(ham), kwargs... | ||
) | ||
end | ||
|
||
# This method only exists to detect whether a Hamiltonian is Hermitian or not. | ||
function KrylovKit.eigsolve( | ||
ham::AbstractHamiltonian, vec::AbstractDVec, howmany::Int=1, which::U=:LR; kwargs... | ||
) | ||
return @invoke eigsolve( | ||
ham::Any, vec::Any, howmany, which; | ||
ishermitian=ishermitian(ham), issymmetric=issymmetric(ham), kwargs... | ||
) | ||
end | ||
|
||
end |
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
Oops, something went wrong.
2825da8
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.
@JuliaRegistrator register
2825da8
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.
Registration pull request created: JuliaRegistries/General/95162
Tip: Release Notes
Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.
To add them here just re-invoke and the PR will be updated.
Tagging
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: