Skip to content

Commit 9f0c204

Browse files
committed
Initial try at fixing incompatibility of Zygote with multithreading
1 parent 75eb4e9 commit 9f0c204

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/compat/ad.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,16 @@ ZygoteRules.@adjoint function push!(
99
)
1010
return push!(vi, vn, r, dist, gidset), _ -> nothing
1111
end
12+
13+
# Multithreaded evaluation is not compatible with Zygote.
14+
ZygoteRules.@adjoint function (model::Model)(
15+
vi::AbstractVarInfo,
16+
spl::AbstractSampler,
17+
ctx::AbstractContext
18+
)
19+
function evaluate(vi, spl, ctx)
20+
return evaluate_singlethreaded(model, vi, spl, ctx)
21+
end
22+
return ZygoteRules.pullback(evaluate, vi, spl, ctx)
23+
end
24+

0 commit comments

Comments
 (0)