Skip to content

varinfo: require recorded values for container queries - #1541

Merged
yebai merged 1 commit into
mainfrom
varinfo-queries
Nov 19, 2026
Merged

yebai merged 1 commit into
mainfrom
varinfo-queries

Conversation

@yebai

@yebai yebai commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Split of #1529 (part 2 of 12). Without a VectorValueAccumulator, keys, haskey, length, values and isempty on a VarInfo reported an empty collection, and is_transformed(vi) returned false. On main this is a silently wrong answer: after init!!(model, VarInfo(), ...), keys(vi) returns () even though the model has just sampled its variables. They now throw an ArgumentError, because a missing accumulator is not an empty collection. For example, keys(VarInfo()) returned () and now throws; use VarInfo(VectorValueAccumulator(), DynamicPPL.default_accumulators()...) to record values.

Tests cover the throwing queries, including under ThreadSafeVarInfo; the subset example now runs as a doctest. HISTORY lists the change as breaking.

@github-actions

Copy link
Copy Markdown
Contributor

DynamicPPL.jl documentation for PR #1541 is available at:
https://TuringLang.github.io/DynamicPPL.jl/previews/PR1541/

@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.07%. Comparing base (fd8f8a6) to head (9c26048).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1541   +/-   ##
=======================================
  Coverage   85.07%   85.07%           
=======================================
  Files          52       52           
  Lines        4663     4663           
=======================================
  Hits         3967     3967           
  Misses        696      696           

☔ View full report in Codecov by Harness.
📢 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.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Benchmarks

Performance Ratio: gradient time divided by log-density time.

For very small models these ratios are noisy across runs and machines; raw primal and gradient timings are more reliable. The benchmarks are aimed at DynamicPPL developers and mainly catch obvious allocation or type-stability regressions. See benchmark notes for details.

Primal times: main fd8f8a6, PR 9c26048

================================================================================================================================
                                                                     primal                            gradient                 
                                                             ----------------------  -------------------------------------------
Model                                         dim    linked        main          PR     FwdDiff    RvsDiff    Mooncake    Enzyme
--------------------------------------------------------------------------------------------------------------------------------
Simple assume observe*                          1     false     4.54 ns     4.17 ns       10.46    1201.56       11.02      9.44
Simple assume observe*                          1      true     4.55 ns     4.18 ns       10.42    1229.28       10.59      9.67
Smorgasbord                                   201     false     5.55 μs     4.18 μs       97.50     134.91        5.69      1.28
Smorgasbord                                   201      true     6.57 μs     4.95 μs      100.24     167.19        6.06      1.48
Smorgasbord fixed                             100     false      2.1 μs     2.15 μs       68.05     156.86        6.08      1.30
Smorgasbord fixed                             100      true     2.56 μs     2.46 μs       71.38     176.54        7.43      1.55
NamedTuple-field LHS variable*                  1     false     4.55 ns     4.18 ns       10.32    1326.21       11.06     10.22
NamedTuple-field LHS variable*                  1      true     4.56 ns     4.18 ns       10.44    1345.23       11.02      8.20
MvNormal argument-supplied observation*         1     false     92.2 ns     68.4 ns        2.46     540.61        2.61      2.57
MvNormal argument-supplied observation*         1      true     89.7 ns     68.5 ns        2.45     597.12        2.85      2.31
Loop univariate 1k                           1000     false     12.6 μs     12.8 μs     1351.04     348.26        3.60      0.87
Loop univariate 1k                           1000      true     16.1 μs     14.2 μs     1665.63     303.80        3.22      0.86
Multivariate 1k                              1000     false     1.77 μs     1.08 μs     3068.71     449.98        1.54      2.93
Multivariate 1k                              1000      true      1.5 μs      1.0 μs     3643.67     472.63        1.78      2.93
Loop univariate 10k                         10000     false    111.0 μs    120.0 μs    20239.77     410.28        3.65      0.74
Loop univariate 10k                         10000      true    156.0 μs    139.0 μs    19225.27     366.25        3.10      0.67
Multivariate 10k                            10000     false     16.7 μs     9.27 μs    49524.58     572.74        1.48      2.49
Multivariate 10k                            10000      true     15.7 μs     9.78 μs    42832.97     519.42        1.80      2.60
Dynamic                                       err     false     1.31 μs     1.12 μs         err      47.54       13.39      4.53
Dynamic                                        10      true      1.7 μs     1.48 μs        1.82      61.25       10.66      7.31
Submodel*                                       1     false     4.56 ns     4.17 ns       10.50    1426.39       11.04      9.87
Submodel*                                       1      true     4.55 ns     4.18 ns       10.45    1422.84       11.09      9.77
LDA                                             6      true     3.58 μs      2.9 μs        1.62      15.19       35.78     33.96
================================================================================================================================
Environment
Julia Version 1.13.4
Commit c1ac32ab733 (2026-11-13 17:30 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 4 × AMD EPYC 9V74 80-Core Processor
  WORD_SIZE: 64
  LLVM: libLLVM-20.1.8 (ORCJIT, znver4)
  GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 4 virtual cores)

Without a `VectorValueAccumulator`, `keys`, `haskey`, `length`,
`values` and `isempty` on a `VarInfo` reported an empty collection, and
`is_transformed(vi)` returned `false`. They now throw an
`ArgumentError`: an absent value accumulator is not an empty
collection.

The `subset` example gains its missing opening fence, so it now runs
as a doctest.

Assisted-by: Claude Code <noreply@anthropic.com>
@yebai
yebai merged commit 5b9b55f into main Nov 19, 2026
23 checks passed
@yebai
yebai deleted the varinfo-queries branch November 19, 2026 13:01
@shravanngoswamii

Copy link
Copy Markdown
Member

I have reviewed and everything looks good to me!

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