Skip to content

implement per-chain progress bars with ProgressMeter.jl #165

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

penelopeysm
Copy link
Member

@penelopeysm penelopeysm commented Jun 27, 2025

This PR enables per-chain progress bars when sampling multiple chains with MCMCThreads().

To do so, it switches the logging functionality to use ProgressMeter.jl which appears to be much more actively maintained.

As a bonus, it also means that when sampling with isdone (i.e., we don't know how many iterations will happen until isdone returns true) we can make use of ProgressMeter.ProgressUnknown which is a more sensible interface than the typical progress bar.

I had first tried to implement this using the existing logging setup (with ProgressLogging.jl -- see https://github.com/TuringLang/AbstractMCMC.jl/tree/py/parallel), but found myself blocked by JuliaLogging/ProgressLogging.jl#41 (I have asked on Slack to see if somebody would merge it).

Here is a video:

Screen.Recording.2025-06-27.at.01.20.51.mov

The code I ran in the video is:

using AbstractMCMC
struct M <: AbstractMCMC.AbstractModel end
struct S <: AbstractMCMC.AbstractSampler end
function AbstractMCMC.step(rng, ::M, ::S, state=nothing; kwargs...)
    sleep(0.002)
    rand(rng), nothing
end

sample(M(), S(), 500)

isd(rng, model, sampler, samples, state, i; kwargs...) = i > 500
sample(M(), S(), isd)

sample(M(), S(), MCMCThreads(), 500, 6)

TODO

  • MCMCSerial
  • MCMCDistributed
  • Fix tests
  • Is there a way to fix the per-chain progress bars not being cleared fully? keep=true doesn't seem to have the intended behaviour
  • Check platform generality (I'm mildly concerned that, for example, ProgressMeter might not work on Pluto)

Closes #24
Closes #82
Would close TuringLang/Turing.jl#2264 as well

@penelopeysm penelopeysm marked this pull request as draft June 27, 2025 00:22
Copy link
Contributor

AbstractMCMC.jl documentation for PR #165 is available at:
https://TuringLang.github.io/AbstractMCMC.jl/previews/PR165/

@penelopeysm penelopeysm changed the title implement multi-chain progress bars with ProgressMeter.jl implement per-chain progress bars with ProgressMeter.jl Jun 27, 2025
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.

Progress reporting in parallel sampling More useful logging when sampling multiple chains Convergence Logging
1 participant