Skip to content

Commit afe3ba2

Browse files
committed
Add changelog
1 parent d937157 commit afe3ba2

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

HISTORY.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,41 @@
22

33
## 0.38.0
44

5+
**Breaking changes**
6+
7+
foo
8+
9+
**Other changes**
10+
11+
### Thread-safe execution
12+
13+
This release removes `ThreadSafeVarInfo`, which was a construction used to ensure thread-safe accumulation of log-likelihood terms using the `Threads.@threads`.
14+
However, `Threads.@threads` is no longer the recommended way to perform multithreaded tasks: see e.g. [this Julia blog post](https://julialang.org/blog/2023/07/PSA-dont-use-threadid/).
15+
16+
In its place a new macro, `@pobserve` is introduced, which under the hood uses `Threads.@spawn`.
17+
**From a user's point of view you simply need to replace `Threads.@threads` with `@pobserve`.**
18+
For example, here the likelihood contributions for each element of `y` are calculated in parallel:
19+
20+
```julia
21+
@model function f(y)
22+
mu ~ Normal()
23+
yplusones = @pobserve for i in eachindex(y)
24+
y[i] ~ Normal(mu)
25+
return y[i] + 1
26+
end
27+
end
28+
```
29+
30+
Furthermore, the `@pobserve` block will also return the final value inside the block, so can also be used to parallelise arbitrary computation. In the model above, `yplusones` will be a vector of length `y` where each element is `y[i] + 1`.
31+
32+
Please note that this only works for **likelihood terms**, i.e., observed variables (hence the macro name).
33+
It is a long-term goal to be able to parallelise other parts of model execution such as the sampling of new variables, but this is not presently possible.
34+
35+
`@pobserve` is also not currently compatible with Turing's particle samplers (because Libtask.jl does not work with `Threads.@spawn)`.
36+
This is, in fact, a good thing, because the previous behaviour of particle samplers with `Threads.@threads` was to silently give a wrong result.
37+
38+
### Other minor changes
39+
540
The `varname_leaves` and `varname_and_value_leaves` functions have been moved to AbstractPPL.jl.
641
Their behaviour is otherwise identical.
742

0 commit comments

Comments
 (0)