Skip to content

varnamedtuple: describe storage with AbstractPPL.of - #1547

Merged
yebai merged 1 commit into
mainfrom
vnt-of
Nov 21, 2026
Merged

yebai merged 1 commit into
mainfrom
vnt-of

Conversation

@yebai

@yebai yebai commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Split of #1529 (part 4.2 of 12; part 4 comes as nine PRs).

Adds AbstractPPL.of(vnt::VarNamedTuple), which describes a VarNamedTuple's storage as an AbstractPPL template. It supports numeric Arrays, nested fields, and scalars whose type of preserves. Other storage throws an ArgumentError; this includes values set by index without a template, whose shape is only inferred. Nothing uses the method yet: part 4.4 lets condition and fix take such templates. Errors name the failing field by its dotted path, such as a.x. Tests cover a partly filled array in a nested field, a scalar, and both error paths.

@codecov

codecov Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.34%. Comparing base (98bab95) to head (8c8bb4f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1547      +/-   ##
==========================================
+ Coverage   85.29%   85.34%   +0.04%     
==========================================
  Files          52       52              
  Lines        4700     4714      +14     
==========================================
+ Hits         4009     4023      +14     
  Misses        691      691              

☔ 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

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Nov 21, 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 98bab95, PR 8c8bb4f

================================================================================================================================
                                                                     primal                            gradient                 
                                                             ----------------------  -------------------------------------------
Model                                         dim    linked        main          PR     FwdDiff    RvsDiff    Mooncake    Enzyme
--------------------------------------------------------------------------------------------------------------------------------
Simple assume observe*                          1     false      2.7 ns     5.26 ns        9.82    1319.23       10.18      6.10
Simple assume observe*                          1      true     2.68 ns     5.26 ns        9.70    1389.98       10.23      6.89
Smorgasbord                                   201     false     2.97 μs     5.33 μs       80.82     139.84        5.31      1.29
Smorgasbord                                   201      true     3.46 μs     6.47 μs       76.08     167.14        5.52      1.44
Smorgasbord fixed                             100     false      1.6 μs     2.57 μs       52.65     166.63        6.64      1.26
Smorgasbord fixed                             100      true      1.7 μs     3.02 μs       61.24     188.36        6.73      1.45
NamedTuple-field LHS variable*                  1     false     2.66 ns     5.26 ns        9.79    1367.37       10.26      6.46
NamedTuple-field LHS variable*                  1      true     2.69 ns     5.26 ns        9.77    1364.59       10.21      6.13
MvNormal argument-supplied observation*         1     false     45.4 ns     74.3 ns        2.21     659.23        3.21      2.46
MvNormal argument-supplied observation*         1      true     48.1 ns     75.7 ns        2.30     657.69        3.19      2.31
Loop univariate 1k                           1000     false     7.98 μs     17.5 μs      838.81     298.00        2.82      0.83
Loop univariate 1k                           1000      true     10.2 μs     18.2 μs     1357.41     299.44        2.75      0.71
Multivariate 1k                              1000     false    729.0 ns    960.0 ns     1665.41     740.15        1.89      3.20
Multivariate 1k                              1000      true    705.0 ns      1.0 μs     1566.91     660.43        1.89      3.07
Loop univariate 10k                         10000     false     74.5 μs    164.0 μs    12693.42     376.46        3.00      0.72
Loop univariate 10k                         10000      true     97.5 μs    176.0 μs    13446.91     356.15        2.86      0.67
Multivariate 10k                            10000     false     5.59 μs     9.56 μs    27773.49     779.14        1.70      2.81
Multivariate 10k                            10000      true     5.25 μs     9.17 μs    26414.11     818.58        1.73      2.86
Dynamic                                       err     false    793.0 ns      1.4 μs         err      42.64       13.97      4.60
Dynamic                                        10      true     1.18 μs     1.92 μs        1.67      60.48       12.51      6.39
Submodel*                                       1     false     2.68 ns     5.26 ns        9.83    1605.31       10.22      5.62
Submodel*                                       1      true     2.67 ns     5.26 ns        9.83    1607.99        9.71      6.49
LDA                                             6      true     1.95 μs     3.56 μs        1.41      11.64       26.41     31.00
================================================================================================================================
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 7763 64-Core Processor
  WORD_SIZE: 64
  LLVM: libLLVM-20.1.8 (ORCJIT, znver3)
  GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 4 virtual cores)

@shravanngoswamii shravanngoswamii left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me!

Agent found this:
AbstractPPL added of in 0.15.3. So we should raise the minimum in DynamicPPL compat to 0.15.3

`of(vnt)` describes a VarNamedTuple's storage as an AbstractPPL
template. Nothing consumes it yet: the binding API added in a later
change accepts such templates in `condition` and `fix`.

Assisted-by: Claude Code <noreply@anthropic.com>
Assisted-by: Codex <codex@openai.com>
@sunxd3

sunxd3 commented Nov 21, 2026

Copy link
Copy Markdown
Member

Looks good to me

@yebai
yebai added this pull request to the merge queue Nov 21, 2026
Merged via the queue into main with commit 956dded Nov 21, 2026
23 checks passed
@yebai
yebai deleted the vnt-of branch November 21, 2026 19:56
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