Skip to content
This repository was archived by the owner on Jun 15, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ad.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def run_ad(args):

results = {}

if model_key == "multithreaded":
if model_key.startswith("threaded_"):
RUN_JULIA_COMMAND = ["julia", "--threads=4", *JULIA_COMMAND[1:]]
else:
RUN_JULIA_COMMAND = JULIA_COMMAND
Expand Down
3 changes: 2 additions & 1 deletion main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ end
# x, y, z, ... are observed variables
# although it's hardly a big deal.
@include_model "Base Julia features" "control_flow"
@include_model "Base Julia features" "multithreaded"
@include_model "Base Julia features" "threaded_assume"
@include_model "Base Julia features" "threaded_observe"
@include_model "Core Turing syntax" "assume_submodel"
@include_model "Core Turing syntax" "broadcast_macro"
@include_model "Core Turing syntax" "dot_assume"
Expand Down
16 changes: 0 additions & 16 deletions models/multithreaded.jl

This file was deleted.

14 changes: 14 additions & 0 deletions models/threaded_assume.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#=
Note: this example is run with 4 threads
=#

@model function threaded_assume(x)
a = Vector{Float64}(undef, length(x))
Threads.@threads for i in eachindex(x)
a[i] ~ Normal()
x[i] ~ Normal(a[i])
end
end

x = randn(50)
model = setthreadsafe(threaded_assume(x), true)
13 changes: 13 additions & 0 deletions models/threaded_observe.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#=
Note: this model is run with 4 threads
=#

@model function threaded_observe(x)
a ~ Normal()
Threads.@threads for i in eachindex(x)
x[i] ~ Normal(a)
end
end

x = randn(100)
model = setthreadsafe(threaded_observe(x), true)
Loading