Module StochasticStyles

Rimu.StochasticStylesModule

This module provides concrete implementations of StochasticStyles, which specify the algorithm used by lomc! when performing stochastic matrix-vector multiplication.

Implemented stochastic styles:

The offdiagonal spawning is defined in spawning.jl and is controlled by setting a SpawningStrategy.

The vector compression strategies are defined in compression.jl and are controlled by setting a CompressionStrategy.

source

Available StochasticStyles

Rimu.Interfaces.StyleUnknownType
StyleUnknown{T}() <: StochasticStyle

Trait for value types not (currently) compatible with FCIQMC. This style makes it possible to construct dict vectors with unsupported valtypes.

See also StochasticStyle.

source
Rimu.StochasticStyles.IsDynamicSemistochasticType
IsDynamicSemistochastic{T=Float64}(; kwargs...) <: StochasticStyle{T}

QMC propagation with floating-point walker numbers and reduced noise. All possible spawns (offdiagonal elements in vector-matrix multiplication) are performed deterministically when number of walkers in a configuration is high, as controlled by the rel_spawning_threshold and abs_spawning_threshold keywords. Stochastic selection of spawns is controlled by the spawning keyword.

By default, a stochastic vector compression is applied after annihilations are completed. This behaviour can be changed to on-the-fly projection (as in IsStochasticInteger or IsStochasticWithThreshold) by setting late_compression=false, or modifying spawning and compression. See parameters below for a more detailed explanation.

Parameters:

  • threshold = 1.0: Values below this number are stochastically projected to this value or zero. See also ThresholdCompression.

  • late_compression = true: If this is set to true, stochastic vector compression is performed after all the spawns are performed. If it is set to false, values are stochastically projected as they are being spawned. late_compression=true is equivalent to setting compression=ThresholdCompression(threshold) and spawning=WithReplacement(). late_compression=false is equivalent to compression=NoCompression() and spawning=WithReplacement(threshold).

  • rel_spawning_threshold = 1.0: If the walker number on a configuration times this threshold is greater than the number of offdiagonals, spawning is done deterministically. Should be set to 1 or more for best performance.

  • abs_spawning_threshold = Inf: If the walker number on a configuration is greater than this value, spawning is done deterministically. Can be set to e.g. abs_spawning_threshold = 0.1 * target_walkers.

  • spawning = WithReplacement(): SpawningStrategy to use for the non-exact spawns.

  • compression = ThresholdCompression(threshold): CompressionStrategy used to compress the vector after a step. Overrides threshold.

See also StochasticStyle.

source

The StochasticStyle interface

Rimu.Interfaces.StochasticStyleType
StochasticStyle(v)

Abstract type. When called as a function it returns the native style of the generalised vector v that determines how simulations are to proceed.

Usage

Concrete StochasticStyles can be used for the style keyword argument of lomc!, DVec and PDVec. The following styles are available:

Extended Help

Interface

When defining a new StochasticStyle, subtype it as MyStyle<:StochasticStyle{T} where T is the concrete value type the style is designed to work with.

For it to work with lomc!, a StochasticStyle must define the following:

and optionally

See also StochasticStyles, Interfaces.

source
Rimu.Interfaces.step_statsFunction
step_stats(::StochasticStyle)
step_stats(::CompressionStrategy)

Return a tuple of stat names (Symbol or String) and a tuple of zeros of the same length. These will be reported as columns in the DataFrame returned by lomc!.

source
Rimu.Interfaces.apply_column!Function
apply_column!(v, op, addr, num, boost=1) -> stats::Tuple

Apply the product of column addr of the operator op and the scalar num to the vector v according to the StochasticStyle of v. By expectation value this should be equivalent to

v .+= op[:, add] .* num

This is used to perform the spawning step in FCIQMC and to implement operator-vector multiplications. Mutates v and reports spawning statistics.

The boost argument multiplicatively increases the number of spawns to be performed without affecting the expectation value of the procedure.

source

Compression strategies

Rimu.Interfaces.CompressionStrategyType
CompressionStrategy

The CompressionStrategy controls how a vector is compressed after a step.

Default implementation:

Usage

A subtype of CompressionStrategy can be passed as a keyword argument to the constructors for some StochasticStyles. Calling CompressionStrategy(s::StochasticStyle) returns a relevant subtype. The default is NoCompression.

Interface

When defining a new CompressionStrategy, subtype it as MyCompressionStrategy <: CompressionStrategy and define these methods:

source
Rimu.StochasticStyles.ThresholdCompressionType
ThresholdCompression(threshold=1) <: CompressionStrategy

CompressionStrategy that compresses a vector by threshold projection. Every entry in the vector with a value below the threshold is either set to zero, or increased to the threshold. The probabilty of setting it to zero is equal to abs(value) / threshold.

source
Rimu.Interfaces.compress!Function
compress!([::CompressionStrategy,] v) -> ::NTuple{N,::Symbol}, ::NTuple{N}
compress!([::CompressionStrategy,] w, v) -> ::NTuple{N,::Symbol}, ::NTuple{N}

Compress the vector v. The one-argument version compresses the vector in-place. The two-argument vector stores the result in w. The CompressionStrategy associated with the StochasticStyle of v is used to determine the type of compression.

Returns two tuples, containing the names and values of statistics that are to be reported.

source

Spawning strategies and convenience functions

The following functions and types are unexported, but are useful when defining new styles.

Rimu.StochasticStyles.diagonal_step!Function
diagonal_step!(w, op, add, val, threshold=0) -> (clones, deaths, zombies)

Perform diagonal step on a walker add => val. Optional argument threshold sets the projection threshold. If eltype(w) is an Integer, the val is rounded to the nearest integer stochastically.

source
Rimu.StochasticStyles.spawn!Function
spawn!(s::SpawningStrategy, w, op::AbstractHamiltonian, add, val, boost)
spawn!(s::SpawningStrategy, w, offdiags::AbstractOffdiagonals, add, val, boost)

Perform stochastic spawns to w from address add with val walkers. val * boost controls the number of spawns performed.

This function should be overloaded in the second form, with offdiags as an argument.

See SpawningStrategy.

source
Rimu.StochasticStyles.BernoulliType
Bernoulli(threshold=0.0) <: SpawningStrategy

Perform Bernoulli sampling. A spawn is attempted on each offdiagonal element with a probability that results in an expected number of spawns equal to the number of walkers on the spawning configuration. This is significantly less efficient than WithReplacement.

If the number of spawn attempts is greater than the number of offdiagonals, this functions like Exact, but is less efficient. For best performance, this strategy is to be used as a substrategy of DynamicSemistochastic.

Parameters

  • threshold sets the projection threshold.

spawn! with this strategy returns the number of spawn attempts and the number of spawns.

source
Rimu.StochasticStyles.DynamicSemistochasticType
DynamicSemistochastic(; strat, rel_threshold, abs_threshold) <: SpawningStrategy

SpawningStrategy that behaves like strat when the number of walkers is low, but performs exact steps when it is high. What "high" means is controlled by the two thresholds described below.

Parameters

  • strat = WithReplacement(): a SpawningStrategy to use when the multiplication is not performed exactly. If the strat has a threshold different from zero, all spawns will be projected to that threshold.

  • rel_threshold = 1.0: When deciding on whether to perform an exact spawn, this value is multiplied to the number of walkers. Should be set to 1 or more for best performance. This threshold is affected by the boost argument to spawn!.

  • abs_threshold = Inf: When deciding on whether to perform an exact spawn, min(abs_threshold, num_offdiagonals) is used. This threshold is not affected by the boost argument to spawn!.

See e.g. WithoutReplacement for a description of the strat.threshold parameter.

spawn! with this strategy returns the numbers of exact and inexact spawns, the number of spawn attempts and the number of spawns.

source
Rimu.StochasticStyles.ExactType
Exact(threshold=0.0) <: SpawningStrategy

Perform an exact spawning step.

Parameters

  • threshold sets the projection threshold. If set to zero, no projection is performed.

spawn! with this strategy returns the number of spawn attempts and the number of spawns.

source
Rimu.StochasticStyles.SingleSpawnType
SingleSpawn(threshold=0.0) <: SpawningStrategy

Perform a single spawn. Useful as a building block for other stochastic styles.

Parameters

  • threshold sets the projection threshold. If set to zero, no projection is performed.

spawn! with this strategy returns the number of spawn attempts (always 1) and the number of spawns.

source
Rimu.StochasticStyles.SpawningStrategyType
SpawningStrategy

A SpawningStrategy is used to control how spawns (multiplies with off-diagonal part of the column vector) are performed and can be passed to some of the StochasticStyles as keyword arguments.

The following concrete implementations are provided:

Interface

In order to implement a new SpawningStrategy, define a method for spawn!.

source
Rimu.StochasticStyles.WithReplacementType
WithReplacement(threshold=0.0) <: SpawningStrategy

SpawningStrategy where spawn targets are sampled with replacement. This is the default spawning strategy for most of the StochasticStyles.

Parameters

  • threshold sets the projection threshold. If set to zero, no projection is performed.

spawn! with this strategy returns the number of spawn attempts and the number of spawns.

source
Rimu.StochasticStyles.WithoutReplacementType
WithoutReplacement(threshold=0.0) <: SpawningStrategy

SpawningStrategy where spawn targets are sampled without replacement. This strategy needs to allocate a temporary array during spawning, which makes it significantly less efficient than WithReplacement.

If the number of spawn attempts is greater than the number of offdiagonals, this functions like Exact, but is less efficient. For best performance, this strategy is to be used as a substrategy of DynamicSemistochastic.

Parameters

  • threshold sets the projection threshold. If set to zero, no projection is performed.

spawn! with this strategy returns the number of spawn attempts and the number of spawns.

source

Index