Skip to content

Commit 7def4b4

Browse files
committed
Explain progress logging in docs
1 parent 594483f commit 7def4b4

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

docs/src/api.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ AbstractMCMC.MCMCSerial
6868
## Common keyword arguments
6969

7070
Common keyword arguments for regular and parallel sampling are:
71-
- `progress` (default: `AbstractMCMC.PROGRESS[]` which is `true` initially): toggles progress logging
71+
- `progress` (default: `AbstractMCMC.PROGRESS[]` which is `true` initially): toggles progress logging. See the section on [Progress logging](#progress-logging) below for more details.
7272
- `chain_type` (default: `Any`): determines the type of the returned chain
7373
- `callback` (default: `nothing`): if `callback !== nothing`, then
7474
`callback(rng, model, sampler, sample, iteration)` is called after every sampling step,
@@ -90,12 +90,31 @@ However, multiple packages such as [EllipticalSliceSampling.jl](https://github.c
9090
To ensure that sampling multiple chains "just works" when sampling of a single chain is implemented, [we decided to support `initial_params` in the default implementations of the ensemble methods](https://github.com/TuringLang/AbstractMCMC.jl/pull/94):
9191
- `initial_params` (default: `nothing`): if `initial_params isa AbstractArray`, then the `i`th element of `initial_params` is used as initial parameters of the `i`th chain. If one wants to use the same initial parameters `x` for every chain, one can specify e.g. `initial_params = FillArrays.Fill(x, N)`.
9292

93-
Progress logging can be enabled and disabled globally with `AbstractMCMC.setprogress!(progress)`.
93+
## Progress logging
94+
95+
The default value for the `progress` keyword argument is `AbstractMCMC.PROGRESS[]`, which is always set to `true` unless modified with `AbstractMCMC.setprogress!`.
96+
For example, `setprogress!(false)` will disable all progress logging.
9497

9598
```@docs
9699
AbstractMCMC.setprogress!
97100
```
98101

102+
For single-chain sampling (i.e., `sample([rng,] model, sampler, N)`), as well as multiple-chain sampling with `MCMCSerial`, the `progress` keyword argument should be a `Bool`.
103+
104+
For multiple-chain sampling using `MCMCThreads`, there are several, more detailed, options:
105+
106+
- `:perchain`: create one progress bar per chain being sampled
107+
- `:overall`: create one progress bar for the overall sampling process, which tracks the percentage of samples that have been sampled across all chains
108+
- `:none`: do not create any progress bar
109+
- `true` (the default): use `perchain` for 10 or fewer chains, and `overall` for more than 10 chains
110+
- `false`: same as `none`, i.e. no progress bar
111+
112+
The threshold of 10 chains can be changed using `AbstractMCMC.setmaxchainsprogress!(N)`, which will cause `MCMCThreads` to use `:perchain` for `N` or fewer chains, and `:overall` for more than `N` chains.
113+
Thus, for example, if you _always_ want to use `:overall`, you can call `AbstractMCMC.setmaxchainsprogress!(0)`.
114+
115+
Multiple-chain sampling using `MCMCDistributed` behaves the same as `MCMCThreads`, except that `:perchain` is not (yet?) implemented.
116+
So, `true` always corresponds to `:overall`, and `false` corresponds to `:none`.
117+
99118
## Chains
100119

101120
The `chain_type` keyword argument allows to set the type of the returned chain. A common

0 commit comments

Comments
 (0)