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

Fix for default AutoForwardDiff #581

Merged
merged 4 commits into from
Feb 29, 2024
Merged

Fix for default AutoForwardDiff #581

merged 4 commits into from
Feb 29, 2024

Conversation

torfjelde
Copy link
Member

By default, AutoForwardDiff() results in chunksize being nothing, not 0.

This then breaks our LogDensityProblemsAD.ADgradient constructor.

@torfjelde torfjelde requested review from devmotion, yebai and sunxd3 and removed request for devmotion February 27, 2024 11:33
@torfjelde
Copy link
Member Author

Should be a fairly simple merge

Copy link
Member

@sunxd3 sunxd3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@torfjelde
Copy link
Member Author

Okay so tests are failing because if a suuuper old bug it seems, but I'm now very confused as to why this was hit now rather than any time before?

@sunxd3
Copy link
Member

sunxd3 commented Feb 28, 2024

@yebai @torfjelde @devmotion turns out the issue is caused by TuringLang/Turing.jl#2170, when run sample(DynamicPPL.TestUtils.DEMO_MODELS[1], Prior(), 10) , it hit

return dot_tilde_assume(
then
return dot_tilde_assume(rng, NodeTrait(dot_tilde_assume, context), context, args...)
and no implementation after that.
Stack trace:

MethodError: no method matching dot_tilde_assume(::Random.TaskLocalRNG, ::DynamicPPL.IsLeaf, ::PriorContext{Nothing}, ::SampleFromPrior, ::InverseGamma{Float64}, ::Vector{Float64}, ::Vector{VarName{:s, Setfield.IndexLens{Tuple{Int64}}}}, ::UntypedVarInfo{DynamicPPL.Metadata{Dict{VarName, Int64}, Vector{Distribution}, Vector{VarName}, Vector{Real}, Vector{Set{DynamicPPL.Selector}}}, Float64})

Closest candidates are:
  dot_tilde_assume(!Matched::AbstractPPL.AbstractContext, ::Any...)
   @ DynamicPPL ~/DynamicPPL.jl/src/context_implementations.jl:288
  dot_tilde_assume(::Any, !Matched::AbstractPPL.AbstractContext, ::Any...)
   @ DynamicPPL ~/DynamicPPL.jl/src/context_implementations.jl:291
  dot_tilde_assume(!Matched::DynamicPPL.IsLeaf, ::Any, ::AbstractPPL.AbstractContext, ::Any, ::Any, ::Any, ::Any, ::Any)
   @ DynamicPPL ~/DynamicPPL.jl/src/context_implementations.jl:298
  ...

Closest candidates are:
  dot_tilde_assume(::AbstractPPL.AbstractContext, ::Any...)
   @ DynamicPPL ~/DynamicPPL.jl/src/context_implementations.jl:288
  dot_tilde_assume(::Any, ::AbstractPPL.AbstractContext, ::Any...)
   @ DynamicPPL ~/DynamicPPL.jl/src/context_implementations.jl:291
  dot_tilde_assume(::DynamicPPL.IsLeaf, ::Any, ::AbstractPPL.AbstractContext, ::Any, ::Any, ::Any, ::Any, ::Any)
   @ DynamicPPL ~/DynamicPPL.jl/src/context_implementations.jl:298
  ...

Stacktrace:
  [1] dot_tilde_assume(::Random.TaskLocalRNG, ::PriorContext{…}, ::SampleFromPrior, ::InverseGamma{…}, ::Vector{…}, ::Vector{…}, ::UntypedVarInfo{…})
    @ DynamicPPL ~/DynamicPPL.jl/src/context_implementations.jl:292
  [2] dot_tilde_assume(context::SamplingContext{…}, right::InverseGamma{…}, left::Vector{…}, vn::Vector{…}, vi::UntypedVarInfo{…})
    @ DynamicPPL ~/DynamicPPL.jl/src/context_implementations.jl:282
  [3] dot_tilde_assume!!(context::SamplingContext{…}, right::InverseGamma{…}, left::Vector{…}, vn::Vector{…}, vi::UntypedVarInfo{…})
    @ DynamicPPL ~/DynamicPPL.jl/src/context_implementations.jl:406
  [4] demo_dot_assume_dot_observe(__model__::Model{…}, __varinfo__::UntypedVarInfo{…}, __context__::SamplingContext{…}, x::Vector{…}, arg#360::Type{…})
    @ DynamicPPL.TestUtils ~/DynamicPPL.jl/src/test_utils.jl:340
  [5] _evaluate!!(model::Model{…}, varinfo::UntypedVarInfo{…}, context::SamplingContext{…})
    @ DynamicPPL ~/DynamicPPL.jl/src/model.jl:963
  [6] evaluate_threadunsafe!!(model::Model{…}, varinfo::UntypedVarInfo{…}, context::SamplingContext{…})
    @ DynamicPPL ~/DynamicPPL.jl/src/model.jl:936
  [7] evaluate!!(model::Model{…}, varinfo::UntypedVarInfo{…}, context::SamplingContext{…})
    @ DynamicPPL ~/DynamicPPL.jl/src/model.jl:889
  [8] step(rng::Random.TaskLocalRNG, model::Model{…}, sampler::Sampler{…}, state::Nothing; kwargs::@Kwargs{})
    @ Turing.Inference ~/.julia/dev/Turing/src/mcmc/Inference.jl:137
  [9] step(rng::Random.TaskLocalRNG, model::Model{…}, sampler::Sampler{…}, state::Nothing)
    @ Turing.Inference ~/.julia/dev/Turing/src/mcmc/Inference.jl:130
 [10] macro expansion
    @ ~/.julia/packages/AbstractMCMC/YrmkI/src/sample.jl:130 [inlined]
 [11] macro expansion
    @ ~/.julia/packages/ProgressLogging/6KXlp/src/ProgressLogging.jl:328 [inlined]
 [12] macro expansion
    @ ~/.julia/packages/AbstractMCMC/YrmkI/src/logging.jl:9 [inlined]
 [13] mcmcsample(rng::Random.TaskLocalRNG, model::Model{…}, sampler::Sampler{…}, N::Int64; progress::Bool, progressname::String, callback::Nothing, discard_initial::Int64, thinning::Int64, chain_type::Type, initial_state::Nothing, kwargs::@Kwargs{})
    @ AbstractMCMC ~/.julia/packages/AbstractMCMC/YrmkI/src/sample.jl:120
 [14] sample(rng::Random.TaskLocalRNG, model::Model{…}, sampler::Sampler{…}, N::Int64; chain_type::Type, resume_from::Nothing, initial_state::Nothing, kwargs::@Kwargs{})
    @ DynamicPPL ~/DynamicPPL.jl/src/sampler.jl:93
 [15] sample(rng::Random.TaskLocalRNG, model::Model{…}, sampler::Sampler{…}, N::Int64)
    @ DynamicPPL ~/DynamicPPL.jl/src/sampler.jl:83
 [16] sample(rng::Random.TaskLocalRNG, model::Model{…}, alg::Prior, N::Int64; kwargs::@Kwargs{})
    @ Turing.Inference ~/.julia/dev/Turing/src/mcmc/Inference.jl:219
 [17] sample(rng::Random.TaskLocalRNG, model::Model{…}, alg::Prior, N::Int64)
    @ Turing.Inference ~/.julia/dev/Turing/src/mcmc/Inference.jl:212
 [18] sample(model::Model{…}, alg::Prior, N::Int64; kwargs::@Kwargs{})
    @ Turing.Inference ~/.julia/dev/Turing/src/mcmc/Inference.jl:209
 [19] sample(model::Model{…}, alg::Prior, N::Int64)
    @ Turing.Inference ~/.julia/dev/Turing/src/mcmc/Inference.jl:203
 [20] entry-point

I am not familiar with the context implementations to instantly see a solution, but maybe you can.

@sunxd3
Copy link
Member

sunxd3 commented Feb 28, 2024

The reason it didn't surface is: the CI tests of #571 was run ahead of the merging of TuringLang/Turing.jl#2170.
And it seems there is no DynamicPPL/Turing integration tests for Turing's PR

Copy link

codecov bot commented Feb 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.47%. Comparing base (c33eeae) to head (2a4f83d).
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #581      +/-   ##
==========================================
+ Coverage   84.32%   84.47%   +0.14%     
==========================================
  Files          26       28       +2     
  Lines        3183     3207      +24     
==========================================
+ Hits         2684     2709      +25     
+ Misses        499      498       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yebai yebai enabled auto-merge February 29, 2024 17:33
@yebai yebai added this pull request to the merge queue Feb 29, 2024
Merged via the queue into master with commit a020171 Feb 29, 2024
13 of 14 checks passed
@yebai yebai deleted the torfjelde/forwarddiff-fix branch February 29, 2024 19:16
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

Successfully merging this pull request may close these issues.

4 participants