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

can't run demo on macOS and Windows (linux works fine) #13

Closed
thorek1 opened this issue Aug 6, 2023 · 6 comments
Closed

can't run demo on macOS and Windows (linux works fine) #13

thorek1 opened this issue Aug 6, 2023 · 6 comments

Comments

@thorek1
Copy link

thorek1 commented Aug 6, 2023

Hi,

when running this:

using Turing, MuseInference, LinearAlgebra
# toy hierarchical model
Turing.@model function toy()
    σ ~ Uniform(0, 1)
    θ ~ Normal(0, σ)
    z ~ MvNormal(zeros(512), exp/2)*I)
    w ~ MvNormal(z, I)
    x ~ MvNormal(w, I)
    y ~ MvNormal(x, I)
    (;σ, θ, z, w, x, y)
end
sim = toy()()
model = toy() | (;sim.x, sim.y)
prob = TuringMuseProblem(model, params=(, ))

# get solution
result = muse(prob, (σ=0.5, θ=0))

I get the following error:

ERROR: InexactError: Int64(-0.2257913526447275)
Stacktrace:
  [1] Int64
    @ ./float.jl:900 [inlined]
  [2] convert
    @ ./number.jl:7 [inlined]
  [3] setindex!
    @ ./array.jl:969 [inlined]
  [4] acclogp!!
    @ ~/.julia/packages/DynamicPPL/zPOYL/src/threadsafe.jl:23 [inlined]
  [5] tilde_observe!!
    @ ~/.julia/packages/DynamicPPL/zPOYL/src/context_implementations.jl:184 [inlined]
  [6] tilde_observe!!
    @ ~/.julia/packages/DynamicPPL/zPOYL/src/context_implementations.jl:170 [inlined]
  [7] toy(__model__::DynamicPPL.Model{typeof(toy), (), (), (), Tuple{}, Tuple{}, DynamicPPL.ConditionContext{NamedTuple{(, ), Tuple{Float64, Float64}}, DynamicPPL.DefaultContext}}, __varinfo__::DynamicPPL.ThreadSafeVarInfo{DynamicPPL.SimpleVarInfo{NamedTuple{(), Tuple{}}, Int64, MuseInference.PartialTransformation{Tuple{AbstractPPL.VarName{:z, Setfield.IdentityLens}, AbstractPPL.VarName{:w, Setfield.IdentityLens}}}}, Vector{Int64}}, __context__::DynamicPPL.SamplingContext{DynamicPPL.SampleFromPrior, DynamicPPL.ConditionContext{NamedTuple{(, ), Tuple{Float64, Float64}}, DynamicPPL.DefaultContext}, Random.Xoshiro})
    @ Main ./Untitled-1:58
  [8] macro expansion
    @ ~/.julia/packages/DynamicPPL/zPOYL/src/model.jl:593 [inlined]
  [9] _evaluate!!
    @ ~/.julia/packages/DynamicPPL/zPOYL/src/model.jl:576 [inlined]
 [10] evaluate_threadsafe!!(model::DynamicPPL.Model{typeof(toy), (), (), (), Tuple{}, Tuple{}, DynamicPPL.ConditionContext{NamedTuple{(, ), Tuple{Float64, Float64}}, DynamicPPL.DefaultContext}}, varinfo::DynamicPPL.SimpleVarInfo{NamedTuple{(), Tuple{}}, Int64, MuseInference.PartialTransformation{Tuple{AbstractPPL.VarName{:z, Setfield.IdentityLens}, AbstractPPL.VarName{:w, Setfield.IdentityLens}}}}, context::DynamicPPL.SamplingContext{DynamicPPL.SampleFromPrior, DynamicPPL.DefaultContext, Random.Xoshiro})
    @ DynamicPPL ~/.julia/packages/DynamicPPL/zPOYL/src/model.jl:567
 [11] evaluate!!
    @ ~/.julia/packages/DynamicPPL/zPOYL/src/model.jl:502 [inlined]
 [12] evaluate!!
    @ ~/.julia/packages/DynamicPPL/zPOYL/src/model.jl:515 [inlined]
 [13] evaluate!!(model::DynamicPPL.Model{typeof(toy), (), (), (), Tuple{}, Tuple{}, DynamicPPL.ConditionContext{NamedTuple{(, ), Tuple{Float64, Float64}}, DynamicPPL.DefaultContext}}, rng::Random.Xoshiro, varinfo::DynamicPPL.SimpleVarInfo{NamedTuple{(), Tuple{}}, Int64, MuseInference.PartialTransformation{Tuple{AbstractPPL.VarName{:z, Setfield.IdentityLens}, AbstractPPL.VarName{:w, Setfield.IdentityLens}}}})
    @ DynamicPPL ~/.julia/packages/DynamicPPL/zPOYL/src/model.jl:515
 [14] sample_x_z(prob::TuringMuseProblem{AbstractDifferentiation.ForwardDiffBackend{Nothing}, DynamicPPL.Model{typeof(toy), (), (), (), Tuple{}, Tuple{}, DynamicPPL.DefaultContext}}, rng::Random.Xoshiro, θ::ComponentArrays.ComponentVector{Float64, Vector{Float64}, Tuple{ComponentArrays.Axis{(σ = 1, θ = 2)}}})
    @ MuseInference ~/.julia/packages/MuseInference/C6pYH/src/turing.jl:210
 [15] (::MuseInference.var"#46#51"{Nothing, TuringMuseProblem{AbstractDifferentiation.ForwardDiffBackend{Nothing}, DynamicPPL.Model{typeof(toy), (), (), (), Tuple{}, Tuple{}, DynamicPPL.DefaultContext}}})(rng::Random.Xoshiro)
    @ MuseInference ~/.julia/packages/MuseInference/C6pYH/src/muse.jl:133
 [16] iterate
    @ ./generator.jl:47 [inlined]
 [17] _collect(c::Vector{Random.Xoshiro}, itr::Base.Generator{Vector{Random.Xoshiro}, MuseInference.var"#46#51"{Nothing, TuringMuseProblem{AbstractDifferentiation.ForwardDiffBackend{Nothing}, DynamicPPL.Model{typeof(toy), (), (), (), Tuple{}, Tuple{}, DynamicPPL.DefaultContext}}}}, #unused#::Base.EltypeUnknown, isz::Base.HasShape{1})
    @ Base ./array.jl:802
 [18] collect_similar(cont::Vector{Random.Xoshiro}, itr::Base.Generator{Vector{Random.Xoshiro}, MuseInference.var"#46#51"{Nothing, TuringMuseProblem{AbstractDifferentiation.ForwardDiffBackend{Nothing}, DynamicPPL.Model{typeof(toy), (), (), (), Tuple{}, Tuple{}, DynamicPPL.DefaultContext}}}})
    @ Base ./array.jl:711
 [19] map(f::Function, A::Vector{Random.Xoshiro})
    @ Base ./abstractarray.jl:3261
 [20] pmap(f::Function, #unused#::MuseInference.LocalWorkerPool, args::Vector{Random.Xoshiro})
    @ MuseInference ~/.julia/packages/MuseInference/C6pYH/src/util.jl:75
 [21] muse!(result::MuseResult, prob::TuringMuseProblem{AbstractDifferentiation.ForwardDiffBackend{Nothing}, DynamicPPL.Model{typeof(toy), (), (), (), Tuple{}, Tuple{}, DynamicPPL.DefaultContext}}, θ₀::NamedTuple{(:σ, :θ), Tuple{Float64, Int64}}; rng::Nothing, z₀::Nothing, maxsteps::Int64, θ_rtol::Float64, ∇z_logLike_atol::Float64, nsims::Int64, α::Float64, progress::Bool, pool::MuseInference.LocalWorkerPool, regularize::typeof(identity), H⁻¹_like′::Nothing, H⁻¹_update::Symbol, broyden_memory::Float64, checkpoint_filename::Nothing, get_covariance::Bool)
    @ MuseInference ~/.julia/packages/MuseInference/C6pYH/src/muse.jl:132
 [22] muse!(result::MuseResult, prob::TuringMuseProblem{AbstractDifferentiation.ForwardDiffBackend{Nothing}, DynamicPPL.Model{typeof(toy), (), (), (), Tuple{}, Tuple{}, DynamicPPL.DefaultContext}}, θ₀::NamedTuple{(:σ, :θ), Tuple{Float64, Int64}})
    @ MuseInference ~/.julia/packages/MuseInference/C6pYH/src/muse.jl:106
 [23] muse(::TuringMuseProblem{AbstractDifferentiation.ForwardDiffBackend{Nothing}, DynamicPPL.Model{typeof(toy), (), (), (), Tuple{}, Tuple{}, DynamicPPL.DefaultContext}}, ::Vararg{Any}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ MuseInference ~/.julia/packages/MuseInference/C6pYH/src/muse.jl:101
 [24] muse(::TuringMuseProblem{AbstractDifferentiation.ForwardDiffBackend{Nothing}, DynamicPPL.Model{typeof(toy), (), (), (), Tuple{}, Tuple{}, DynamicPPL.DefaultContext}}, ::Vararg{Any})
    @ MuseInference ~/.julia/packages/MuseInference/C6pYH/src/muse.jl:101
 [25] top-level scope
    @ Untitled-1:70

(@v1.9) pkg> st -m
Status `~/.julia/environments/v1.9/Manifest.toml`
  [47edcb42] ADTypes v0.1.6
⌅ [c29ec348] AbstractDifferentiation v0.4.4
  [621f4979] AbstractFFTs v1.5.0
  [80f14c24] AbstractMCMC v4.4.2
⌅ [7a57a42e] AbstractPPL v0.5.4
  [1520ce14] AbstractTrees v0.4.4
  [79e6a3ab] Adapt v3.6.2
⌅ [0bf59076] AdvancedHMC v0.3.6
⌅ [5b7e9947] AdvancedMH v0.6.8
⌅ [576499cb] AdvancedPS v0.3.8
⌅ [b5ca4192] AdvancedVI v0.1.6
  [dce04be8] ArgCheck v2.3.0
  [4fba245c] ArrayInterface v7.4.11
  [30b0a656] ArrayInterfaceCore v0.1.29
  [a9b6321e] Atomix v0.1.0
  [13072b0f] AxisAlgorithms v1.0.1
  [39de3d68] AxisArrays v0.4.7
  [198e06fe] BangBang v0.3.39
  [9718e550] Baselet v0.1.1
⌅ [76274a88] Bijectors v0.10.8
  [fa961155] CEnum v0.4.2
  [49dc2e85] Calculus v0.5.1
  [082447d4] ChainRules v1.53.0
  [d360d2e6] ChainRulesCore v1.16.0
  [9e997f8a] ChangesOfVariables v0.1.8
  [861a8166] Combinatorics v1.0.2
  [38540f10] CommonSolve v0.2.4
  [bbf7d656] CommonSubexpressions v0.3.0
  [34da2185] Compat v4.9.0
⌅ [b0b7db55] ComponentArrays v0.13.10
  [a33af91c] CompositionsBase v0.1.2
  [88cd18e8] ConsoleProgressMonitor v0.1.2
  [187b0558] ConstructionBase v1.5.3
  [587fd27a] CovarianceEstimation v0.2.9
  [a8cc5b0e] Crayons v4.1.1
  [9a962f9c] DataAPI v1.15.0
  [864edb3b] DataStructures v0.18.15
  [e2d170a0] DataValueInterfaces v1.0.0
  [244e2a9f] DefineSingletons v0.1.2
  [8bb1440f] DelimitedFiles v1.9.1
  [b429d917] DensityInterface v0.4.0
  [163ba53b] DiffResults v1.1.0
  [b552c78f] DiffRules v1.15.1
  [31c24e10] Distributions v0.25.99
  [ced4e74d] DistributionsAD v0.6.52
  [ffbed154] DocStringExtensions v0.9.3
  [fa6b7ba4] DualNumbers v0.6.8
⌅ [366bfd00] DynamicPPL v0.20.2
  [cad2338a] EllipticalSliceSampling v1.1.0
  [4e289a0a] EnumX v1.0.4
  [e2ba6199] ExprTools v0.1.10
  [7a1cc6ca] FFTW v1.7.1
  [5789e2e9] FileIO v1.16.1
  [1a297f60] FillArrays v1.5.0
⌃ [6a86dc24] FiniteDiff v2.17.0
  [26cc04aa] FiniteDifferences v0.12.29
  [59287772] Formatting v0.4.2
  [f6369f11] ForwardDiff v0.10.35
  [069b7b12] FunctionWrappers v1.1.3
  [77dc65aa] FunctionWrappersWrappers v0.1.3
⌅ [d9f16b24] Functors v0.3.0
  [46192b85] GPUArraysCore v0.1.5
  [34004b35] HypergeometricFunctions v0.3.23
  [615f187c] IfElse v0.1.1
  [22cec73e] InitialValues v0.3.1
  [505f98c9] InplaceOps v0.3.0
  [a98d9a8b] Interpolations v0.14.7
  [8197267c] IntervalSets v0.7.7
  [3587e190] InverseFunctions v0.1.12
  [41ab1584] InvertedIndices v1.3.0
  [92d709cd] IrrationalConstants v0.2.2
  [c8e1da08] IterTools v1.8.0
  [42fd0dbc] IterativeSolvers v0.9.2
  [82899510] IteratorInterfaceExtensions v1.0.0
  [692b3bcd] JLLWrappers v1.4.1
  [63c18a36] KernelAbstractions v0.9.8
  [5ab0869b] KernelDensity v0.6.7
  [929cbde3] LLVM v6.1.0
  [8ac3fa9e] LRUCache v1.4.1
  [b964fa9f] LaTeXStrings v1.3.0
  [50d2b5c4] Lazy v0.15.1
  [1d6d02ad] LeftChildRightSiblingTrees v0.2.0
⌅ [6f1fad26] Libtask v0.7.5
  [d3d80556] LineSearches v7.2.0
  [7a12625a] LinearMaps v3.11.0
  [6fdf6af0] LogDensityProblems v2.1.1
  [2ab3a3ac] LogExpFunctions v0.3.24
  [e6f89c97] LoggingExtras v1.0.0
⌅ [c7f686f2] MCMCChains v5.7.1
⌅ [be115224] MCMCDiagnosticTools v0.2.6
  [e80e1ace] MLJModelInterface v1.8.0
  [1914dd2f] MacroTools v0.5.10
  [dbb5928d] MappedArrays v0.4.2
  [128add7d] MicroCollections v0.1.4
  [e1d29d7a] Missings v1.1.0
  [43b88160] MuseInference v0.2.2
  [d41bc354] NLSolversBase v7.8.3
  [872c559c] NNlib v0.9.4
  [77ba4419] NaNMath v1.0.2
  [86f7a689] NamedArrays v0.9.8
  [d9ec5142] NamedTupleTools v0.14.3
  [c020b1a1] NaturalSort v1.0.0
  [6fe1bfb0] OffsetArrays v1.12.10
  [429524aa] Optim v1.7.6
⌃ [3bd65402] Optimisers v0.2.15
  [bac558e1] OrderedCollections v1.6.2
  [90014a1f] PDMats v0.11.17
  [d96e819e] Parameters v0.12.3
  [85a6dd25] PositiveFactorizations v0.2.4
  [aea7be01] PrecompileTools v1.1.2
  [21216c6a] Preferences v1.4.0
  [08abe8d2] PrettyTables v2.2.7
  [33c8b6b6] ProgressLogging v0.1.4
  [92933f4c] ProgressMeter v1.7.2
  [1fd47b50] QuadGK v2.8.2
  [b3c3ace0] RangeArrays v0.3.2
  [c84ed2f1] Ratios v0.4.5
  [c1ae055f] RealDot v0.1.0
  [3cdcf5f2] RecipesBase v1.3.4
  [731186ca] RecursiveArrayTools v2.38.7
  [189a3867] Reexport v1.2.2
  [ae029012] Requires v1.3.0
  [708f8203] Richardson v1.4.0
  [79098fc4] Rmath v0.7.1
  [f2b01f46] Roots v2.0.17
  [7e49a35a] RuntimeGeneratedFunctions v0.5.11
  [0bca4576] SciMLBase v1.94.0
  [c0aeaf25] SciMLOperators v0.3.6
  [30f210dd] ScientificTypesBase v3.0.0
⌅ [efcf1570] Setfield v0.8.2
  [66db9d55] SnoopPrecompile v1.0.3
  [a2af1166] SortingAlgorithms v1.1.1
  [276daf66] SpecialFunctions v2.3.0
  [171d559e] SplittablesBase v0.1.15
  [aedffcd0] Static v0.8.8
  [0d7ed370] StaticArrayInterface v1.4.0
  [90137ffa] StaticArrays v1.6.2
  [1e83bf80] StaticArraysCore v1.4.2
  [64bff920] StatisticalTraits v3.2.0
  [82ae8749] StatsAPI v1.6.0
⌅ [2913bbd2] StatsBase v0.33.21
  [4c63d2b9] StatsFuns v1.3.0
  [892a3eda] StringManipulation v0.3.0
  [09ab397b] StructArrays v0.6.15
  [2efcf032] SymbolicIndexingInterface v0.2.2
  [3783bdb8] TableTraits v1.0.1
  [bd369af6] Tables v1.10.1
  [5d786b92] TerminalLoggers v0.1.7
  [9f7883ad] Tracker v0.2.26
  [28d57a85] Transducers v0.4.78
  [410a4b4d] Tricks v0.1.7
  [781d530d] TruncatedStacktraces v1.4.0
⌃ [fce5fe82] Turing v0.21.10
  [3a884ed6] UnPack v1.0.2
  [013be700] UnsafeAtomics v0.2.1
  [d80eeb9a] UnsafeAtomicsLLVM v0.1.3
  [efce3f68] WoodburyMatrices v0.5.5
  [700de1a5] ZygoteRules v0.2.3
  [f5851436] FFTW_jll v3.3.10+0
  [1d5cc7b8] IntelOpenMP_jll v2023.1.0+0
  [dad2f222] LLVMExtra_jll v0.0.23+0
  [856f044c] MKL_jll v2023.1.0+0
  [efe28fd5] OpenSpecFun_jll v0.5.5+0
  [f50d1b31] Rmath_jll v0.4.0+0
  [0dad84c5] ArgTools v1.1.1
  [56f22d72] Artifacts
  [2a0f44e3] Base64
  [ade2ca70] Dates
  [8ba89e20] Distributed
  [f43a241f] Downloads v1.6.0
  [7b1f6079] FileWatching
  [9fa8497b] Future
  [b77e0a4c] InteractiveUtils
  [4af54fe1] LazyArtifacts
  [b27032c2] LibCURL v0.6.3
  [76f85450] LibGit2
  [8f399da3] Libdl
  [37e2e46d] LinearAlgebra
  [56ddb016] Logging
  [d6f4376e] Markdown
  [a63ad114] Mmap
  [ca575930] NetworkOptions v1.2.0
  [44cfe95a] Pkg v1.9.0
  [de0858da] Printf
  [3fa0cd96] REPL
  [9a3f8284] Random
  [ea8e919c] SHA v0.7.0
  [9e88b42a] Serialization
  [1a1011a3] SharedArrays
  [6462fe0b] Sockets
  [2f01184e] SparseArrays
  [10745b16] Statistics v1.9.0
  [4607b0f0] SuiteSparse
  [fa267f1f] TOML v1.0.3
  [a4e569a6] Tar v1.10.0
  [8dfed614] Test
  [cf7118a7] UUIDs
  [4ec0a83e] Unicode
  [e66e0078] CompilerSupportLibraries_jll v1.0.2+0
  [deac9b47] LibCURL_jll v7.84.0+0
  [29816b5a] LibSSH2_jll v1.10.2+0
  [c8ffd9c3] MbedTLS_jll v2.28.2+0
  [14a3606d] MozillaCACerts_jll v2022.10.11
  [4536629a] OpenBLAS_jll v0.3.21+4
  [05823500] OpenLibm_jll v0.8.1+0
  [bea87d4a] SuiteSparse_jll v5.10.1+6
  [83775a58] Zlib_jll v1.2.13+0
  [8e850b90] libblastrampoline_jll v5.8.0+0
  [8e850ede] nghttp2_jll v1.48.0+0
  [3f19e933] p7zip_jll v17.4.0+0
Info Packages marked with ⌃ and ⌅ have new versions available, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated -m`

I tested on Windows x64, macOS x64 and arm64 architectures with the same result. Linux (aarch64) works fine. Given the other issue on windows it seems that these are OS specific issues. Furthermore, the error is in the same spot: acclogp

I tried as well to get it to work with the test environment but ended up with the same.

I made a pull request #14 with additional tests for other OS and Julia versions. Interestingly enough macOS and windows work just fine there.

Any help would be much appreciated. I have a good use case for your package but cannot make it work :/

@thorek1 thorek1 changed the title can't run demo on macOS (linux works fine) can't run demo on macOS and Windows (linux works fine) Aug 6, 2023
@thorek1
Copy link
Author

thorek1 commented Aug 7, 2023

new hint: it works on macOS on a fresh install

there must be something that breaks once you add more packages

@marius311
Copy link
Owner

Can you try and make sure its the exact same Manifest.toml on all platforms? (or Im not sure if that works exactly, but somehow check every single package is at the exact same version?) This looks like some Julia error rather than anything platform specific.

Another possible source is can you see if it depends on the number of threads you started with? Turing takes slightly different paths for single vs. multithreaded maybe its something there?

@marius311
Copy link
Owner

I can reproduce your error (or something very similar) on Linux if I start Julia with >1 threads, my guess is that's it, will look into fixing it.

@thorek1
Copy link
Author

thorek1 commented Aug 8, 2023

ok, in the meantime I was exploring the Manifest.toml route but didn't get very far

@thorek1
Copy link
Author

thorek1 commented Aug 8, 2023

I can confirm the threads behaviour on macOS

@marius311
Copy link
Owner

See #12 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants