# Turing: help with slow model

**URL:** https://discourse.julialang.org/t/turing-help-with-slow-model/54563
**Category:** Probabilistic Programming
**Created:** [February 3, 2021, 9:18pm UTC](https://discourse.julialang.org/t/turing-help-with-slow-model/54563 "2021-02-03T21:18:53Z")
**Posts on this page:** 7
**Page:** 3

<div class="post-metadata">

### Author: ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)
#### Post date: [February 8, 2021, 5:11pm UTC](https://discourse.julialang.org/t/turing-help-with-slow-model/54563/41 "2021-02-08T17:11:38Z")

</div>

Hmmm. It does not sound like intended behavior. My best guess is that threading is making it difficult to calculate the expected finish time. It might be worth opening an issue at Turing and including a minimum working example.

---

<div class="post-metadata">

### Author: ![treichelt](https://avatars.discourse-cdn.com/v4/letter/t/7cd45c/32.png) [@treichelt](https://discourse.julialang.org/u/treichelt)
#### Post date: [February 8, 2021, 5:52pm UTC](https://discourse.julialang.org/t/turing-help-with-slow-model/54563/42 "2021-02-08T17:52:48Z")

</div>

I think that if you sample multiple chains using `MCMCThreads` then the progress bar shows how many chains already finished. Therefore if you sample 4 chains you will only get values of 25, 50, and 75 percent. The relevant code in Turing is [here](https://github.com/TuringLang/AbstractMCMC.jl/blob/7e0967af0085e53f1c1cd1b1852d6669f58891d8/src/sample.jl#L259). So I think this is the intended behaviour. You might want to open an issue/discussion in Turing about whether it would be possible to change this behaviour.

---

<div class="post-metadata">

### Author: ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)
#### Post date: [February 8, 2021, 6:01pm UTC](https://discourse.julialang.org/t/turing-help-with-slow-model/54563/43 "2021-02-08T18:01:07Z")

</div>

That makes sense. An alternative approach might show a progress bar for each chain. It would provide more detail about the progress of the sampler. I don’t know if that is feasible with threads though.

---

<div class="post-metadata">

### Author: ![cpfiffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cpfiffer/32/208747_2.png) [@cpfiffer](https://discourse.julialang.org/u/cpfiffer)
#### Post date: [February 8, 2021, 6:06pm UTC](https://discourse.julialang.org/t/turing-help-with-slow-model/54563/44 "2021-02-08T18:06:36Z")

</div>

We’ve had lots of discussion about how to modify this behavior, and I think the consensus is that it is difficult to do well, so we’ve opted towards simpler and perhaps misleading solutions. I would like to see separate bars for each chain but right now it’s not a high priority.

---

<div class="post-metadata">

### Author: ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)
#### Post date: [February 8, 2021, 7:27pm UTC](https://discourse.julialang.org/t/turing-help-with-slow-model/54563/45 "2021-02-08T19:27:14Z")

</div>

I think the challenge is printing the updates to the same line. In this example, each update is given a new line:

```julia
using ProgressMeter
import Base.Threads.@threads

function fun()
  @showprogress for i in 1:100
    sleep(.01)
  end
end

@threads for i in 1:4
  fun()
end

```

I believe that this used to be the behavior in Turing at one point.

---

<div class="post-metadata">

### Author: ![cscherrer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cscherrer/32/7631_2.png) [@cscherrer](https://discourse.julialang.org/u/cscherrer)
#### Post date: [February 12, 2021, 10:12pm UTC](https://discourse.julialang.org/t/turing-help-with-slow-model/54563/46 "2021-02-12T22:12:19Z")

</div>

@drbenvincent In [MeasureTheory.jl](https://github.com/cscherrer/MeasureTheory.jl) we have different ways to parameterize things, so logistic or probit regression should become easier to write, and hopefully faster too. So in Soss (or other things that use MeasureTheory) you’ll be able to write your likelihood as

```julia
sᵇ ~ For(ϕᵇ) do z Binomial(n = nᵇ, probit_p = z) end
sⁿ ~ For(ϕⁿ) do z Binomial(n = nⁿ, probit_p = z) end

```

The posterior sampling isn’t working for me right now with Zygote, but I think maybe that’s more of an AD issue than a modeling issue.

---

<div class="post-metadata">

### Author: ![drbenvincent](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/drbenvincent/32/3046_2.png) [@drbenvincent](https://discourse.julialang.org/u/drbenvincent)
#### Post date: [February 13, 2021, 11:19am UTC](https://discourse.julialang.org/t/turing-help-with-slow-model/54563/47 "2021-02-13T11:19:03Z")

</div>

Nice. Soss is definitely on my list of things to look at. Just a matter of time!

[Previous page](https://discourse.julialang.org/t/turing-help-with-slow-model/54563.md?page=2)
