Skip to content
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

Add plugins to 4.0 branch #153

Merged
merged 54 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
440314e
initial commit for plugins
bvdmitri Jan 15, 2024
17350d1
implement plugins modifications
bvdmitri Jan 15, 2024
56a1f4b
2prev
bvdmitri Jan 15, 2024
7e6982e
implement the getplugin function
bvdmitri Jan 15, 2024
db08170
Implement `MissingPlugin` instead of nothing
bvdmitri Jan 15, 2024
1bc1fe4
wip: add created_by plugin
bvdmitri Jan 15, 2024
9692c06
refactor options
bvdmitri Jan 15, 2024
079c77e
wip: fix some tests
bvdmitri Jan 15, 2024
8c4f8d8
fix more tests
bvdmitri Jan 16, 2024
cf78f3a
fix more tests
bvdmitri Jan 16, 2024
e4eefdd
2prev
bvdmitri Jan 16, 2024
b0c9bad
add global plugins to the model
bvdmitri Jan 16, 2024
cf0b2c3
remove FactorNodeOptions
bvdmitri Jan 16, 2024
906f28d
major structure refactoring
bvdmitri Jan 16, 2024
597ccbc
fix some tests
bvdmitri Jan 16, 2024
b87bc57
fix some tests
bvdmitri Jan 16, 2024
71489bb
fix some tests
bvdmitri Jan 16, 2024
3c98f03
2prev
bvdmitri Jan 16, 2024
c1ce874
fix tests
bvdmitri Jan 18, 2024
f8ee800
fix more tests
bvdmitri Jan 18, 2024
38752ee
fix tests
bvdmitri Jan 18, 2024
7ad8174
improve the plugins
bvdmitri Jan 18, 2024
398b8e1
2prev
bvdmitri Jan 18, 2024
6d0665c
tests for the created by plugin
bvdmitri Jan 18, 2024
14465fb
make the created_by lambda based
bvdmitri Jan 18, 2024
bc41b0a
slight code optimization
bvdmitri Jan 18, 2024
c3e880e
code optimization
bvdmitri Jan 18, 2024
2d625f9
code optimization
bvdmitri Jan 18, 2024
c47895a
more tests
bvdmitri Jan 18, 2024
753fe72
code refactoring
bvdmitri Jan 18, 2024
ac745b1
code optimization
bvdmitri Jan 18, 2024
826f891
restructure files
bvdmitri Jan 22, 2024
3676344
fix tests
bvdmitri Jan 22, 2024
e9a8128
fix tests
bvdmitri Jan 22, 2024
3fb64da
Fix showing the nodes
bvdmitri Feb 5, 2024
4a9e92c
Refactor plugins, allow to change more properties
bvdmitri Feb 5, 2024
4dbaf0b
add more tests
bvdmitri Feb 6, 2024
576ba3a
Folder restructure
bvdmitri Feb 6, 2024
fc86aab
Move factorization constraints to its own plugin
bvdmitri Feb 6, 2024
f24de34
Fix default_constraints test
bvdmitri Feb 6, 2024
86412f4
Merge branch 'dev-4.0.0' into dev-4.0.0-plugins-system
bvdmitri Feb 7, 2024
c352b82
Move posterior and message form constraints to the plugins
bvdmitri Feb 7, 2024
50dae5d
Fix tests
bvdmitri Feb 7, 2024
67918be
Move meta to plugins
bvdmitri Feb 7, 2024
646b7db
Fix remaining tests for VI plugin
bvdmitri Feb 7, 2024
5734d2c
2prev
bvdmitri Feb 7, 2024
50d8957
style: make format
bvdmitri Feb 7, 2024
61955bd
Add Dictionaries to the compat entry
bvdmitri Feb 7, 2024
a0103f2
Improve allocation profile for the Context stucture
bvdmitri Feb 7, 2024
670ca47
Remove unnecessary fields
bvdmitri Feb 7, 2024
4baafe0
Fix model spec in model_zoo
bvdmitri Feb 7, 2024
0d8aecf
Update ci.yml
bvdmitri Feb 7, 2024
f709811
Improve allocation profile for empty constraints
bvdmitri Feb 7, 2024
efae863
fix benchmarks
wouterwln Feb 8, 2024
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 .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
style = "blue"
indent = 4
margin = 180
margin = 140
always_for_in = true
whitespace_typedefs = true
whitespace_ops_in_indices = true
Expand Down
21 changes: 6 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1.9'
- '1.10'
- 'nightly'
os:
- ubuntu-latest
Expand All @@ -33,18 +33,9 @@ jobs:
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-runtest@latest
- uses: julia-actions/cache@v1
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v3
env:
Expand All @@ -56,8 +47,8 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@latest
with:
version: '1.9'
- uses: julia-actions/cache@v1
- uses: julia-actions/julia-buildpkg@v1
- name: Install dependencies
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
- name: Build and deploy
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ Coverage.ipynb

examples/*Compiled
statprof
profile.pb.gz
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ version = "3.1.0"
[deps]
BitSetTuples = "0f2f92aa-23a3-4d05-b791-88071d064721"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Dictionaries = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4"
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
Memoization = "6fafb56a-5788-4b4e-91ca-c0cea6611c73"
MetaGraphsNext = "fa8bd995-216d-47f1-8a91-f3b68fbeb377"
Expand All @@ -30,6 +31,7 @@ BitSetTuples = "1"
Cairo = "1.0"
Compose = "0.9"
DataStructures = "0.18"
Dictionaries = "0.4"
Distributions = "0.25"
Documenter = "1.0"
GraphPlot = "0.5"
Expand Down
4 changes: 2 additions & 2 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ using BenchmarkTools
const SUITE = BenchmarkGroup()
include("graph_engine.jl")
include("model_creation.jl")
include("constraints_engine.jl")
SUITE["constraints_engine"] = benchmark_constraints_engine()
# include("constraints_engine.jl")
# SUITE["constraints_engine"] = benchmark_constraints_engine()
SUITE["graph_engine"] = benchmark_graph_engine()
SUITE["model_creation"] = benchmark_model_creation()
9 changes: 4 additions & 5 deletions benchmark/graph_engine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ function factor_node_creation()
x = GraphPPL.getorcreate!(model, ctx, :x, j)
end
y = GraphPPL.getorcreate!(model, ctx, :y, nothing)
SUITE["Create factor node with $i edges"] = @benchmarkable GraphPPL.make_node!(m, c, sum, $y, [$x]) setup=(m=deepcopy($model);c=deepcopy($ctx)) evals=1
SUITE["Create factor node with $i edges"] = @benchmarkable GraphPPL.make_node!(m, c, sum, $y, (in = $x,)) setup=(m=deepcopy($model);c=deepcopy($ctx)) evals=1
end
return SUITE
end

function add_n_nodes(n::Int, model, ctx)
for i in 1:n
GraphPPL.add_variable_node!(model, ctx, :x; index=i)
GraphPPL.add_variable_node!(model, ctx, :x, i)
end
end

Expand All @@ -43,14 +43,13 @@ function variable_node_creation()
SUITE = BenchmarkGroup(["node_creation"])
model = GraphPPL.create_model()
ctx = GraphPPL.getcontext(model)
SUITE["add_variable_node"] = @benchmarkable GraphPPL.add_variable_node!(m, c, :x) setup=(m=deepcopy($model);c=deepcopy($ctx)) evals=1
SUITE["add_variable_node"] = @benchmarkable GraphPPL.add_variable_node!(m, c, :x, nothing) setup=(m=deepcopy($model);c=deepcopy($ctx)) evals=1

for j in 10 .^ range(1, stop=3)
j = convert(Int, j)
model = GraphPPL.create_model()
ctx = GraphPPL.getcontext(model)
x = GraphPPL.ResizableArray(GraphPPL.NodeLabel, Val(1))
ctx.vector_variables[:x] = x
x = GraphPPL.getorcreate!(model, ctx, :x, 1)
SUITE["add $j variable nodes"] = @benchmarkable add_n_nodes($j, m, c) setup=(m=deepcopy($model);c=deepcopy($ctx)) evals=1
SUITE["getorcreate $j variable nodes ascending"] = @benchmarkable getorcreate_n_nodes($j, m, c) setup=(m=deepcopy($model);c=deepcopy($ctx)) evals=1
SUITE["getorcreate $j variable nodes descending"] = @benchmarkable getorcreate_n_nodes($j, m, c; asc=false) setup=(m=deepcopy($model);c=deepcopy($ctx)) evals=1
Expand Down
6 changes: 2 additions & 4 deletions benchmark/model_zoo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ function create_hgf(n::Int)
ω = GraphPPL.getorcreate!(model, ctx, :ω, nothing)
θ = GraphPPL.getorcreate!(model, ctx, :θ, nothing)
x_begin = GraphPPL.getorcreate!(model, ctx, :x_begin, nothing)
GraphPPL.add_terminated_submodel!(
GraphPPL.add_toplevel_model!(
model,
ctx,
hgf,
(κ = κ, ω = ω, θ = θ, x_begin = x_begin, depth = n);
__debug__ = false,
(κ = κ, ω = ω, θ = θ, x_begin = x_begin, depth = n)
)
return model
end
Expand Down Expand Up @@ -58,7 +57,6 @@ function create_longarray(n::Int)
ctx,
long_array,
(μ = μ, σ = σ, depth=n);
__debug__ = false,
)
return model
end
Expand Down
3 changes: 1 addition & 2 deletions docs/src/developers_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,11 @@ x = GraphPPL.getorcreate!(model, context, :x, nothing; options = GraphPPL.Variab
y = GraphPPL.getorcreate!(model, context, :y, nothing; options = GraphPPL.VariableNodeOptions(datavar=true))

# Add the gcv model
GraphPPL.add_terminated_submodel!(
GraphPPL.add_toplevel_model!(
model,
context,
gcv,
(κ = κ, ω = ω, z = z, x = x, y = y);
__debug__ = false,
)

# Apply the constraints
Expand Down
2 changes: 1 addition & 1 deletion ext/GraphPPLDistributionsExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using GraphPPL, Distributions, Static

GraphPPL.NodeBehaviour(::Type{<:Distributions.Distribution}) = GraphPPL.Stochastic()

function GraphPPL.default_parametrization(::GraphPPL.Atomic, t::Type{<:Distributions.Distribution}, interface_values)
function GraphPPL.default_parametrization(::GraphPPL.Atomic, t::Type{<:Distributions.Distribution}, interface_values::Tuple)
return distributions_ext_default_parametrization(t, distributions_ext_input_interfaces(t), interface_values)
end

Expand Down
11 changes: 6 additions & 5 deletions src/GraphPPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ module GraphPPL
using MacroTools

include("resizable_array.jl")
include("indexedvariable.jl")
include("plugins_collection.jl")

include("graph_engine.jl")
include("model_macro.jl")
include("constraints_engine.jl")
include("constraints_macro.jl")
include("meta_engine.jl")
include("meta_macro.jl")

include("plugins/node_created_by.jl")
include("plugins/variational_constraints/variational_constraints.jl")
include("plugins/meta/meta.jl")

include("old/old.jl")

Expand Down
Loading
Loading