Skip to content

Add missing tovec methods for NamedTuple and Tuple. #939

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

Merged
merged 3 commits into from
May 27, 2025
Merged

Conversation

sunxd3
Copy link
Member

@sunxd3 sunxd3 commented May 26, 2025

sunxd3 and others added 2 commits May 26, 2025 08:17
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copy link
Contributor

github-actions bot commented May 26, 2025

Benchmark Report for Commit 40fba7e

Computer Information

Julia Version 1.11.5
Commit 760b2e5b739 (2025-04-14 06:53 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 4 × AMD EPYC 7763 64-Core Processor
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, znver3)
Threads: 1 default, 0 interactive, 1 GC (on 4 virtual cores)

Benchmark Results

|                 Model | Dimension |  AD Backend |      VarInfo Type | Linked | Eval Time / Ref Time | AD Time / Eval Time |
|-----------------------|-----------|-------------|-------------------|--------|----------------------|---------------------|
| Simple assume observe |         1 | forwarddiff |             typed |  false |                  9.5 |                 1.5 |
|           Smorgasbord |       201 | forwarddiff |             typed |  false |                772.3 |                32.8 |
|           Smorgasbord |       201 | forwarddiff | simple_namedtuple |   true |                361.2 |                53.2 |
|           Smorgasbord |       201 | forwarddiff |           untyped |   true |               1217.8 |                27.6 |
|           Smorgasbord |       201 | forwarddiff |       simple_dict |   true |               3327.4 |                24.2 |
|           Smorgasbord |       201 | reversediff |             typed |   true |               1464.6 |                29.3 |
|           Smorgasbord |       201 |    mooncake |             typed |   true |                974.0 |                 5.3 |
|    Loop univariate 1k |      1000 |    mooncake |             typed |   true |               5474.9 |                 4.2 |
|       Multivariate 1k |      1000 |    mooncake |             typed |   true |               1051.2 |                 8.6 |
|   Loop univariate 10k |     10000 |    mooncake |             typed |   true |              61824.2 |                 3.9 |
|      Multivariate 10k |     10000 |    mooncake |             typed |   true |               8937.9 |                 9.6 |
|               Dynamic |        10 |    mooncake |             typed |   true |                128.1 |                15.1 |
|              Submodel |         1 |    mooncake |             typed |   true |                 13.3 |                 7.0 |
|                   LDA |        12 | reversediff |             typed |   true |                478.1 |                 5.4 |

Copy link

codecov bot commented May 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.92%. Comparing base (a8a7026) to head (40fba7e).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #939   +/-   ##
=======================================
  Coverage   82.91%   82.92%           
=======================================
  Files          36       36           
  Lines        3962     3964    +2     
=======================================
+ Hits         3285     3287    +2     
  Misses        677      677           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sunxd3 sunxd3 requested a review from penelopeysm May 26, 2025 08:10
@sunxd3
Copy link
Member Author

sunxd3 commented May 26, 2025

Penny could you give it quick look?

I didn't try hard to make the test good and fit well in. So welcome to correct and also absolutely okay to fix directly.

@coveralls
Copy link

coveralls commented May 26, 2025

Pull Request Test Coverage Report for Build 15248584238

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • 80 unchanged lines in 10 files lost coverage.
  • Overall coverage increased (+0.009%) to 83.089%

Files with Coverage Reduction New Missed Lines %
ext/DynamicPPLForwardDiffExt.jl 1 63.64%
src/contexts.jl 2 74.79%
src/experimental.jl 3 0.0%
src/model.jl 3 84.17%
src/compiler.jl 4 85.25%
src/simple_varinfo.jl 4 75.14%
src/varinfo.jl 4 84.14%
ext/DynamicPPLJETExt.jl 16 0.0%
src/test_utils/ad.jl 21 0.0%
src/logdensityfunction.jl 22 50.0%
Totals Coverage Status
Change from base Build 15240387609: 0.009%
Covered Lines: 3287
Relevant Lines: 3956

💛 - Coveralls

1 similar comment
@coveralls
Copy link

coveralls commented May 26, 2025

Pull Request Test Coverage Report for Build 15248584238

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • 80 unchanged lines in 10 files lost coverage.
  • Overall coverage increased (+0.009%) to 83.089%

Files with Coverage Reduction New Missed Lines %
ext/DynamicPPLForwardDiffExt.jl 1 63.64%
src/contexts.jl 2 74.79%
src/experimental.jl 3 0.0%
src/model.jl 3 84.17%
src/compiler.jl 4 85.25%
src/simple_varinfo.jl 4 75.14%
src/varinfo.jl 4 84.14%
ext/DynamicPPLJETExt.jl 16 0.0%
src/test_utils/ad.jl 21 0.0%
src/logdensityfunction.jl 22 50.0%
Totals Coverage Status
Change from base Build 15240387609: 0.009%
Covered Lines: 3287
Relevant Lines: 3956

💛 - Coveralls

Copy link
Member

@penelopeysm penelopeysm left a comment

Choose a reason for hiding this comment

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

There are still issues with Bijectors

using Turing

@model function f(x = [1.5, 2.0])
    priors ~ product_distribution((m=Normal(), s=Beta(2, 2)))
    x .~ Normal(priors.m, sqrt(priors.s))
    return priors
end

sample(f(), NUTS(), 1000)

#=
ERROR: MethodError: no method matching bijector(::Distributions.ProductNamedTupleDistribution{(:m, :s), Tuple{Normal{…}, Beta{…}}, Continuous, Float64})
The function `bijector` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  bijector(::KSOneSided)
   @ Bijectors ~/.julia/packages/Bijectors/L7xKL/src/transformed_distribution.jl:125
  bijector(::Product{Continuous, T, Tdists} where {T<:Distribution{Univariate, Continuous}, Tdists<:(FillArrays.Fill{T, 1})})
   @ BijectorsDistributionsADExt ~/.julia/packages/Bijectors/L7xKL/ext/BijectorsDistributionsADExt.jl:28
  bijector(::Product{Discrete, T, V} where {T<:Distribution{Univariate, Discrete}, V<:AbstractVector{T}})
   @ Bijectors ~/.julia/packages/Bijectors/L7xKL/src/transformed_distribution.jl:79
  ...
=#

but I think on the DynamicPPL side this looks fine.

@penelopeysm
Copy link
Member

I edited the first comment to not close the issue, just so that we can keep track of it :)

@sunxd3 sunxd3 added this pull request to the merge queue May 27, 2025
Merged via the queue into main with commit bb0c857 May 27, 2025
19 of 20 checks passed
@sunxd3 sunxd3 deleted the sunxd/vec_for_nt branch May 27, 2025 11:14
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.

3 participants