Skip to content

Fixed transformations#1327

Merged
penelopeysm merged 30 commits intobreakingfrom
py/transforms
Apr 8, 2026
Merged

Fixed transformations#1327
penelopeysm merged 30 commits intobreakingfrom
py/transforms

Conversation

@penelopeysm
Copy link
Copy Markdown
Member

@penelopeysm penelopeysm commented Mar 17, 2026

Closes #1249. I'll write more here later, but you can see the changelog for a good overview of this PR.

Things to do

  • Generalise LinkedVecTransformAccumulator to something that's more like FixedTransformAccumulator
  • Add a convenience function for 'static'-fying an LDF (?)
  • Add tests for new behaviour
  • Add dev docs on FixedTransform

Possibly in a separate PR:

  • Look at the Turing VI interface to see what it needs from bijector(model), and whether that can be removed (though, note also VI interface is too low-level Turing.jl#2783)
    • I have looked at this and it doesn't need bijector(model). It runs perfectly fine with dynamic transforms and can be made to work with fixed transforms as well, which would potentially provide perf benefits but otherwise not much difference is required in the API

Some scripts to use to benchmark:

using DynamicPPL, Distributions, LogDensityProblems, Random, Chairmarks, ForwardDiff, ADTypes, LinearAlgebra

# @model function esc(J, y, sigma)
#     mu ~ Normal(0, 5)
#     tau ~ truncated(Cauchy(0, 5); lower=0)
#     theta ~ MvNormal(fill(mu, J), tau^2 * I)
#     for i in 1:J
#         y[i] ~ Normal(theta[i], sigma[i])
#     end
# end
# J = 8
# y = [28, 8, -3, 7, -1, 1, 18, 12]
# sigma = [15, 10, 16, 11, 9, 11, 10, 18]
# m = esc(J, y, sigma)

@model function f()
    x ~ product_distribution([Beta(2,2), Uniform(4, 5), Normal()])
end
m = f()

ldf1 = LogDensityFunction(m, getlogjoint_internal, LinkAll(); adtype=AutoForwardDiff(), fix_transforms=true);
p = rand(Xoshiro(468), ldf1);
@b LogDensityProblems.logdensity(ldf1 ,p)
@b LogDensityProblems.logdensity_and_gradient(ldf1 ,p)

ldf2 = LogDensityFunction(m, getlogjoint_internal, LinkAll(); adtype=AutoForwardDiff());
p = rand(Xoshiro(468), ldf2);
@b LogDensityProblems.logdensity(ldf2 ,p)
@b LogDensityProblems.logdensity_and_gradient(ldf2 ,p)

@penelopeysm penelopeysm changed the base branch from main to breaking March 17, 2026 19:19
@penelopeysm penelopeysm reopened this Mar 17, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 17, 2026

Benchmark Report

  • this PR's head: aba492292d7d891744a0564a430d15dcc217e026
  • base branch: e01fbd60d5a54a3b314b5bc5ea6654cefcba34a0

Computer Information

Julia Version 1.11.9
Commit 53a02c0720c (2026-02-06 00:27 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

┌───────────────────────┬───────┬─────────────┬────────┬───────────────────────────────┬────────────────────────────┬─────────────────────────────────┐
│                       │       │             │        │       t(eval) / t(ref)        │     t(grad) / t(eval)      │        t(grad) / t(ref)         │
│                       │       │             │        │ ─────────┬──────────┬──────── │ ───────┬─────────┬──────── │ ──────────┬───────────┬──────── │
│                 Model │   Dim │  AD Backend │ Linked │     base │  this PR │ speedup │   base │ this PR │ speedup │      base │   this PR │ speedup │
├───────────────────────┼───────┼─────────────┼────────┼──────────┼──────────┼─────────┼────────┼─────────┼─────────┼───────────┼───────────┼─────────┤
│               Dynamic │    10 │    mooncake │   true │   262.69 │   272.83 │    0.96 │   8.46 │    8.19 │    1.03 │   2223.34 │   2233.61 │    1.00 │
│                   LDA │    12 │ reversediff │   true │  2359.28 │  2606.68 │    0.91 │   2.52 │    2.06 │    1.23 │   5950.20 │   5361.53 │    1.11 │
│   Loop univariate 10k │ 10000 │    mooncake │   true │ 29273.85 │ 30459.81 │    0.96 │   6.91 │    7.16 │    0.97 │ 202319.53 │ 218006.69 │    0.93 │
├───────────────────────┼───────┼─────────────┼────────┼──────────┼──────────┼─────────┼────────┼─────────┼─────────┼───────────┼───────────┼─────────┤
│    Loop univariate 1k │  1000 │    mooncake │   true │  3718.48 │  3108.48 │    1.20 │   5.44 │    6.92 │    0.79 │  20243.17 │  21523.87 │    0.94 │
│      Multivariate 10k │ 10000 │    mooncake │   true │ 29763.37 │ 32148.10 │    0.93 │  10.38 │   10.21 │    1.02 │ 309077.57 │ 328330.23 │    0.94 │
│       Multivariate 1k │  1000 │    mooncake │   true │  3224.81 │  3438.04 │    0.94 │   9.59 │    9.61 │    1.00 │  30935.40 │  33026.56 │    0.94 │
├───────────────────────┼───────┼─────────────┼────────┼──────────┼──────────┼─────────┼────────┼─────────┼─────────┼───────────┼───────────┼─────────┤
│ Simple assume observe │     1 │ forwarddiff │  false │     0.81 │     0.88 │    0.92 │  10.57 │   10.25 │    1.03 │      8.59 │      9.05 │    0.95 │
│           Smorgasbord │   201 │ forwarddiff │  false │   887.33 │   958.72 │    0.93 │ 145.97 │  140.90 │    1.04 │ 129525.17 │ 135082.99 │    0.96 │
│           Smorgasbord │   201 │      enzyme │   true │  1211.30 │  1313.78 │    0.92 │   5.01 │    4.80 │    1.04 │   6065.31 │   6302.19 │    0.96 │
├───────────────────────┼───────┼─────────────┼────────┼──────────┼──────────┼─────────┼────────┼─────────┼─────────┼───────────┼───────────┼─────────┤
│           Smorgasbord │   201 │ forwarddiff │   true │  1195.61 │  1302.76 │    0.92 │  71.77 │   70.53 │    1.02 │  85814.58 │  91884.00 │    0.93 │
│           Smorgasbord │   201 │    mooncake │   true │  1196.99 │  1311.29 │    0.91 │   5.09 │    5.09 │    1.00 │   6093.00 │   6669.28 │    0.91 │
│           Smorgasbord │   201 │ reversediff │   true │  1192.79 │  1308.30 │    0.91 │ 128.69 │  127.52 │    1.01 │ 153505.37 │ 166840.23 │    0.92 │
├───────────────────────┼───────┼─────────────┼────────┼──────────┼──────────┼─────────┼────────┼─────────┼─────────┼───────────┼───────────┼─────────┤
│              Submodel │     1 │    mooncake │   true │     0.81 │     0.88 │    0.93 │  28.98 │   28.93 │    1.00 │     23.54 │     25.37 │    0.93 │
└───────────────────────┴───────┴─────────────┴────────┴──────────┴──────────┴─────────┴────────┴─────────┴─────────┴───────────┴───────────┴─────────┘

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 17, 2026

Codecov Report

❌ Patch coverage is 79.03226% with 52 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.06%. Comparing base (61eda05) to head (aba4922).
⚠️ Report is 8 commits behind head on breaking.

Files with missing lines Patch % Lines
src/transformed_values.jl 52.54% 28 Missing ⚠️
src/varinfo.jl 87.27% 7 Missing ⚠️
src/abstract_varinfo.jl 33.33% 4 Missing ⚠️
src/accumulators/vector_values.jl 63.63% 4 Missing ⚠️
src/contexts/default.jl 40.00% 3 Missing ⚠️
src/accumulators/fixed_transforms.jl 85.71% 2 Missing ⚠️
src/contexts/init.jl 88.88% 2 Missing ⚠️
src/accumulators/raw_values.jl 93.33% 1 Missing ⚠️
src/test_utils/ad.jl 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           breaking    #1327      +/-   ##
============================================
+ Coverage     78.13%   79.06%   +0.93%     
============================================
  Files            50       50              
  Lines          3590     3559      -31     
============================================
+ Hits           2805     2814       +9     
+ Misses          785      745      -40     

☔ 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.

@github-actions
Copy link
Copy Markdown
Contributor

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

penelopeysm and others added 21 commits March 30, 2026 11:25
Since accumulators are threadsafe (or to be precise, DynamicPPL can make
them threadsafe when the user calls `setthreadsafe`), any functionality
in DynamicPPL that only uses accumulators is automatically threadsafe.
This means that, for example, you can sample random variables in
parallel:

```julia
@model function threaded_assume()
    x = zeros(10)
    Threads.@threads for i in eachindex(x)
        x[i] ~ Normal()
    end
end
model = setthreadsafe(threaded_assume(), true)

julia> rand(model)
VarNamedTuple
└─ x => PartialArray size=(10,) data::Vector{Float64}
        ├─ (1,) => 0.7076777209105218
        ├─ (2,) => -1.0664996275655731
        │  ⋮ (7 more set indices)
        └─ (10,) => 0.6552123596028697
```

This functionality has always existed (since #1284). I didn't realise at
the time that that meant that even LogDensityFunction is now fully
threadsafe. This PR just adds tests to verify that.
Closes #987

Uncovered a bug in the test suite ....
final changes to close #1157

---------

Co-authored-by: hardik-xi11 <hardiklaha@gmail.com>
While investigating TuringLang/Turing.jl#2798,
I found that the issue was with a `tilde_assume!!` call in the Gibbs
code. In the process of fixing it I realised that:

1. The Turing code uses what's now called
`DynamicPPL.prefix_and_strip_contexts`, which performs a similar thing
to the present `extract_prefixes`, but is a bit less general;
2. `prefix_and_strip_contexts` needed an API change;
3. `prefix_and_strip_contexts` was not public (so Turing was misusing
it! -- probably my fault...)

This PR therefore fixes all of these issues by creating a more general
version and exporting it.
Probably a good idea to check ...
Bumps
[codecov/codecov-action](https://github.com/codecov/codecov-action) from
5 to 6.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/codecov/codecov-action/releases">codecov/codecov-action's
releases</a>.</em></p>
<blockquote>
<h2>v6.0.0</h2>
<h2>⚠️ This version introduces support for node24 which make cause
breaking changes for systems that do not currently support node24.
⚠️</h2>
<h2>What's Changed</h2>
<ul>
<li>Revert &quot;Revert &quot;build(deps): bump actions/github-script
from 7.0.1 to 8.0.0&quot;&quot; by <a
href="https://github.com/thomasrockhu-codecov"><code>@​thomasrockhu-codecov</code></a>
in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1929">codecov/codecov-action#1929</a></li>
<li>Th/6.0.0 by <a
href="https://github.com/thomasrockhu-codecov"><code>@​thomasrockhu-codecov</code></a>
in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1928">codecov/codecov-action#1928</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/codecov/codecov-action/compare/v5.5.4...v6.0.0">https://github.com/codecov/codecov-action/compare/v5.5.4...v6.0.0</a></p>
<h2>v5.5.4</h2>
<p>This is a mirror of <code>v5.5.2</code>. <code>v6</code> will be
released which requires <code>node24</code></p>
<h2>What's Changed</h2>
<ul>
<li>Revert &quot;build(deps): bump actions/github-script from 7.0.1 to
8.0.0&quot; by <a
href="https://github.com/thomasrockhu-codecov"><code>@​thomasrockhu-codecov</code></a>
in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1926">codecov/codecov-action#1926</a></li>
<li>chore(release): 5.5.4 by <a
href="https://github.com/thomasrockhu-codecov"><code>@​thomasrockhu-codecov</code></a>
in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1927">codecov/codecov-action#1927</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/codecov/codecov-action/compare/v5.5.3...v5.5.4">https://github.com/codecov/codecov-action/compare/v5.5.3...v5.5.4</a></p>
<h2>v5.5.3</h2>
<h2>What's Changed</h2>
<ul>
<li>build(deps): bump actions/github-script from 7.0.1 to 8.0.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1874">codecov/codecov-action#1874</a></li>
<li>chore(release): bump to 5.5.3 by <a
href="https://github.com/thomasrockhu-codecov"><code>@​thomasrockhu-codecov</code></a>
in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1922">codecov/codecov-action#1922</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/codecov/codecov-action/compare/v5.5.2...v5.5.3">https://github.com/codecov/codecov-action/compare/v5.5.2...v5.5.3</a></p>
<h2>v5.5.2</h2>
<h2>What's Changed</h2>
<ul>
<li>check gpg only when skip-validation = false by <a
href="https://github.com/maxweng-sentry"><code>@​maxweng-sentry</code></a>
in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1894">codecov/codecov-action#1894</a></li>
<li>chore: <code>disable_search</code> alignment by <a
href="https://github.com/freemanzMrojo"><code>@​freemanzMrojo</code></a>
in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1881">codecov/codecov-action#1881</a></li>
<li>chore(release): 5.5.2 by <a
href="https://github.com/thomasrockhu-codecov"><code>@​thomasrockhu-codecov</code></a>
in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1902">codecov/codecov-action#1902</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a
href="https://github.com/maxweng-sentry"><code>@​maxweng-sentry</code></a>
made their first contribution in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1894">codecov/codecov-action#1894</a></li>
<li><a
href="https://github.com/freemanzMrojo"><code>@​freemanzMrojo</code></a>
made their first contribution in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1881">codecov/codecov-action#1881</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/codecov/codecov-action/compare/v5.5.1...v5.5.2">https://github.com/codecov/codecov-action/compare/v5.5.1...v5.5.2</a></p>
<h2>v5.5.1</h2>
<h2>What's Changed</h2>
<ul>
<li>build(deps): bump ossf/scorecard-action from 2.4.1 to 2.4.2 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1833">codecov/codecov-action#1833</a></li>
<li>build(deps): bump github/codeql-action from 3.28.18 to 3.29.9 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1861">codecov/codecov-action#1861</a></li>
<li>Document a <code>codecov-cli</code> version reference example by <a
href="https://github.com/webknjaz"><code>@​webknjaz</code></a> in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1774">codecov/codecov-action#1774</a></li>
<li>docs: fix typo in README by <a
href="https://github.com/datalater"><code>@​datalater</code></a> in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1866">codecov/codecov-action#1866</a></li>
<li>fix: update to use local app/ dir by <a
href="https://github.com/thomasrockhu-codecov"><code>@​thomasrockhu-codecov</code></a>
in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1872">codecov/codecov-action#1872</a></li>
<li>build(deps): bump github/codeql-action from 3.29.9 to 3.29.11 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1867">codecov/codecov-action#1867</a></li>
<li>build(deps): bump actions/checkout from 4.2.2 to 5.0.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1868">codecov/codecov-action#1868</a></li>
<li>fix: overwrite pr number on fork by <a
href="https://github.com/thomasrockhu-codecov"><code>@​thomasrockhu-codecov</code></a>
in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1871">codecov/codecov-action#1871</a></li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md">codecov/codecov-action's
changelog</a>.</em></p>
<blockquote>
<h2>v5.5.2</h2>
<h3>What's Changed</h3>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/codecov/codecov-action/compare/v5.5.1..v5.5.2">https://github.com/codecov/codecov-action/compare/v5.5.1..v5.5.2</a></p>
<h2>v5.5.1</h2>
<h3>What's Changed</h3>
<ul>
<li>fix: overwrite pr number on fork by <a
href="https://github.com/thomasrockhu-codecov"><code>@​thomasrockhu-codecov</code></a>
in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1871">codecov/codecov-action#1871</a></li>
<li>build(deps): bump actions/checkout from 4.2.2 to 5.0.0 by
<code>@​app/dependabot</code> in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1868">codecov/codecov-action#1868</a></li>
<li>build(deps): bump github/codeql-action from 3.29.9 to 3.29.11 by
<code>@​app/dependabot</code> in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1867">codecov/codecov-action#1867</a></li>
<li>fix: update to use local app/ dir by <a
href="https://github.com/thomasrockhu-codecov"><code>@​thomasrockhu-codecov</code></a>
in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1872">codecov/codecov-action#1872</a></li>
<li>docs: fix typo in README by <a
href="https://github.com/datalater"><code>@​datalater</code></a> in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1866">codecov/codecov-action#1866</a></li>
<li>Document a <code>codecov-cli</code> version reference example by <a
href="https://github.com/webknjaz"><code>@​webknjaz</code></a> in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1774">codecov/codecov-action#1774</a></li>
<li>build(deps): bump github/codeql-action from 3.28.18 to 3.29.9 by
<code>@​app/dependabot</code> in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1861">codecov/codecov-action#1861</a></li>
<li>build(deps): bump ossf/scorecard-action from 2.4.1 to 2.4.2 by
<code>@​app/dependabot</code> in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1833">codecov/codecov-action#1833</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/codecov/codecov-action/compare/v5.5.0..v5.5.1">https://github.com/codecov/codecov-action/compare/v5.5.0..v5.5.1</a></p>
<h2>v5.5.0</h2>
<h3>What's Changed</h3>
<ul>
<li>feat: upgrade wrapper to 0.2.4 by <a
href="https://github.com/jviall"><code>@​jviall</code></a> in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1864">codecov/codecov-action#1864</a></li>
<li>Pin actions/github-script by Git SHA by <a
href="https://github.com/martincostello"><code>@​martincostello</code></a>
in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1859">codecov/codecov-action#1859</a></li>
<li>fix: check reqs exist by <a
href="https://github.com/joseph-sentry"><code>@​joseph-sentry</code></a>
in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1835">codecov/codecov-action#1835</a></li>
<li>fix: Typo in README by <a
href="https://github.com/spalmurray"><code>@​spalmurray</code></a> in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1838">codecov/codecov-action#1838</a></li>
<li>docs: Refine OIDC docs by <a
href="https://github.com/spalmurray"><code>@​spalmurray</code></a> in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1837">codecov/codecov-action#1837</a></li>
<li>build(deps): bump github/codeql-action from 3.28.17 to 3.28.18 by
<code>@​app/dependabot</code> in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1829">codecov/codecov-action#1829</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/codecov/codecov-action/compare/v5.4.3..v5.5.0">https://github.com/codecov/codecov-action/compare/v5.4.3..v5.5.0</a></p>
<h2>v5.4.3</h2>
<h3>What's Changed</h3>
<ul>
<li>build(deps): bump github/codeql-action from 3.28.13 to 3.28.17 by
<code>@​app/dependabot</code> in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1822">codecov/codecov-action#1822</a></li>
<li>fix: OIDC on forks by <a
href="https://github.com/joseph-sentry"><code>@​joseph-sentry</code></a>
in <a
href="https://redirect.github.com/codecov/codecov-action/pull/1823">codecov/codecov-action#1823</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/codecov/codecov-action/compare/v5.4.2..v5.4.3">https://github.com/codecov/codecov-action/compare/v5.4.2..v5.4.3</a></p>
<h2>v5.4.2</h2>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/codecov/codecov-action/commit/57e3a136b779b570ffcdbf80b3bdc90e7fab3de2"><code>57e3a13</code></a>
Th/6.0.0 (<a
href="https://redirect.github.com/codecov/codecov-action/issues/1928">#1928</a>)</li>
<li><a
href="https://github.com/codecov/codecov-action/commit/f67d33dda8a42b51c42a8318a1f66468119e898b"><code>f67d33d</code></a>
Revert &quot;Revert &quot;build(deps): bump actions/github-script from
7.0.1 to 8.0.0&quot;&quot;...</li>
<li>See full diff in <a
href="https://github.com/codecov/codecov-action/compare/v5...v6">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=codecov/codecov-action&package-manager=github_actions&previous-version=5&new-version=6)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Penelope Yong <penelopeysm@gmail.com>
[//]: # (dependabot-start)
⚠️  **Dependabot is rebasing this PR** ⚠️ 

Rebasing might not happen immediately, so don't worry if this takes some
time.

Note: if you make any changes to this PR yourself, they will take
precedence over the rebase.

---

[//]: # (dependabot-end)

Bumps [julia-actions/cache](https://github.com/julia-actions/cache) from
2 to 3.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/julia-actions/cache/releases">julia-actions/cache's
releases</a>.</em></p>
<blockquote>
<h2>v3.0.0 - Cache on failure (with override)</h2>
<h2>What's Changed</h2>
<h3>Breaking Changes</h3>
<ul>
<li>Caching will now happen when the job fails, with an override to
restore the previous behavior via <code>save-always: false</code></li>
</ul>
<h3>Changes</h3>
<ul>
<li>Javascript version of existing action which also saves if job fails
by <a
href="https://github.com/jkrumbiegel"><code>@​jkrumbiegel</code></a> <a
href="https://github.com/penelopeysm"><code>@​penelopeysm</code></a> <a
href="https://github.com/IanButterworth"><code>@​IanButterworth</code></a>
in <a
href="https://redirect.github.com/julia-actions/cache/pull/198">julia-actions/cache#198</a>
<a
href="https://redirect.github.com/julia-actions/cache/pull/190">julia-actions/cache#190</a></li>
<li>Fix retry on failure/cancelled example by <a
href="https://github.com/IanButterworth"><code>@​IanButterworth</code></a>
in <a
href="https://redirect.github.com/julia-actions/cache/pull/174">julia-actions/cache#174</a></li>
</ul>
<h3>Maintenance</h3>
<ul>
<li>Bump pyTooling/Actions from 4.2.2 to 4.3.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/julia-actions/cache/pull/176">julia-actions/cache#176</a></li>
<li>Bump dcarbone/install-jq-action from 3.1.1 to 3.2.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/julia-actions/cache/pull/178">julia-actions/cache#178</a></li>
<li>Bump actions/cache from 4.2.3 to 4.2.4 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/julia-actions/cache/pull/180">julia-actions/cache#180</a></li>
<li>Bump actions/checkout from 4.2.2 to 5.0.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/julia-actions/cache/pull/182">julia-actions/cache#182</a></li>
<li>Bump pyTooling/Actions from 4.3.0 to 5.4.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/julia-actions/cache/pull/181">julia-actions/cache#181</a></li>
<li>Bump actions/cache from 4.2.4 to 4.3.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/julia-actions/cache/pull/184">julia-actions/cache#184</a></li>
<li>Bump pyTooling/Actions from 5.4.0 to 6.2.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/julia-actions/cache/pull/183">julia-actions/cache#183</a></li>
<li>Remove trailing whitespaces from <code>README.md</code> by <a
href="https://github.com/giordano"><code>@​giordano</code></a> in <a
href="https://redirect.github.com/julia-actions/cache/pull/186">julia-actions/cache#186</a></li>
<li>Bump pyTooling/Actions from 6.2.0 to 6.6.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/julia-actions/cache/pull/185">julia-actions/cache#185</a></li>
<li>Bump actions/checkout from 5.0.0 to 6.0.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/julia-actions/cache/pull/189">julia-actions/cache#189</a></li>
<li>Bump pyTooling/Actions from 6.6.0 to 6.7.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/julia-actions/cache/pull/188">julia-actions/cache#188</a></li>
<li>Update GitHub Actions checkout action version by <a
href="https://github.com/ViralBShah"><code>@​ViralBShah</code></a> in <a
href="https://redirect.github.com/julia-actions/cache/pull/187">julia-actions/cache#187</a></li>
<li>Bump actions/checkout from 6.0.0 to 6.0.1 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/julia-actions/cache/pull/191">julia-actions/cache#191</a></li>
<li>Bump actions/cache from 4.3.0 to 5.0.1 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/julia-actions/cache/pull/192">julia-actions/cache#192</a></li>
<li>Bump pyTooling/Actions from 6.7.0 to 7.2.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/julia-actions/cache/pull/193">julia-actions/cache#193</a></li>
<li>Bump actions/checkout from 6.0.1 to 6.0.2 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/julia-actions/cache/pull/194">julia-actions/cache#194</a></li>
<li>Bump actions/cache from 5.0.1 to 5.0.3 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/julia-actions/cache/pull/195">julia-actions/cache#195</a></li>
<li>Bump pyTooling/Actions from 7.2.0 to 7.4.2 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/julia-actions/cache/pull/196">julia-actions/cache#196</a></li>
<li>Bump pyTooling/Actions from 7.4.2 to 7.5.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/julia-actions/cache/pull/197">julia-actions/cache#197</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a
href="https://github.com/ViralBShah"><code>@​ViralBShah</code></a> made
their first contribution in <a
href="https://redirect.github.com/julia-actions/cache/pull/187">julia-actions/cache#187</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/julia-actions/cache/compare/v2.1.0...v3.0.0">https://github.com/julia-actions/cache/compare/v2.1.0...v3.0.0</a></p>
<h2>v2.1.0 - New outputs <code>cache-paths</code> and
<code>cache-key</code></h2>
<h2>What's Changed</h2>
<h3>New features</h3>
<ul>
<li>Output <code>cache-paths</code> and <code>cache-key</code> as well
by <a
href="https://github.com/penelopeysm"><code>@​penelopeysm</code></a> in
<a
href="https://redirect.github.com/julia-actions/cache/pull/169">julia-actions/cache#169</a></li>
</ul>
<h3>Maintenance</h3>
<ul>
<li>Bump actions/cache from 4.2.0 to 4.2.2 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/julia-actions/cache/pull/165">julia-actions/cache#165</a></li>
<li>Link to Github caching docs from README.md by <a
href="https://github.com/johnomotani"><code>@​johnomotani</code></a> in
<a
href="https://redirect.github.com/julia-actions/cache/pull/167">julia-actions/cache#167</a></li>
<li>Bump actions/cache from 4.2.2 to 4.2.3 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/julia-actions/cache/pull/172">julia-actions/cache#172</a></li>
<li>Bump dcarbone/install-jq-action from 3.0.1 to 3.1.1 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/julia-actions/cache/pull/171">julia-actions/cache#171</a></li>
<li>Bump pyTooling/Actions from 3.1.1 to 4.2.2 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/julia-actions/cache/pull/170">julia-actions/cache#170</a></li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/julia-actions/cache/commit/9a93c5fb3e9c1c20b60fc80a478cae53e38618a4"><code>9a93c5f</code></a>
chore: bump @actions/* deps to latest and convert source to ESM (<a
href="https://redirect.github.com/julia-actions/cache/issues/218">#218</a>)</li>
<li><a
href="https://github.com/julia-actions/cache/commit/c3e92b0efca5e74c06e7cc930f65825c926b6c9b"><code>c3e92b0</code></a>
Bump actions/setup-node from 6.1.0 to 6.3.0 (<a
href="https://redirect.github.com/julia-actions/cache/issues/211">#211</a>)</li>
<li><a
href="https://github.com/julia-actions/cache/commit/2d4cffa36efdd38eed4c8ef44bac3a2f0e2b7429"><code>2d4cffa</code></a>
Bump brace-expansion from 1.1.12 to 1.1.13 (<a
href="https://redirect.github.com/julia-actions/cache/issues/217">#217</a>)</li>
<li><a
href="https://github.com/julia-actions/cache/commit/e882f3e03ad4e47ee58eab75a040a6946b945a57"><code>e882f3e</code></a>
Bump actions/checkout from 6.0.1 to 6.0.2 (<a
href="https://redirect.github.com/julia-actions/cache/issues/212">#212</a>)</li>
<li><a
href="https://github.com/julia-actions/cache/commit/7eb2283d8cc0fd13d625c29d2069ddf4a8051d5b"><code>7eb2283</code></a>
chore: add npm ecosystem to dependabot (<a
href="https://redirect.github.com/julia-actions/cache/issues/213">#213</a>)</li>
<li><a
href="https://github.com/julia-actions/cache/commit/851ab0256a7c6a50d218086976d28a73a531fa40"><code>851ab02</code></a>
Fix pidfile exclusion: split brace expansion into separate globs (<a
href="https://redirect.github.com/julia-actions/cache/issues/210">#210</a>)</li>
<li><a
href="https://github.com/julia-actions/cache/commit/e97f6fc1a6e21c82253c85e269be7340376aa425"><code>e97f6fc</code></a>
Delete pidfiles. Skip Pkg.gc when not saving. Don't delete old caches if
no n...</li>
<li><a
href="https://github.com/julia-actions/cache/commit/09b9b25cd2299bc07850a3bc713245264c4b701e"><code>09b9b25</code></a>
Bump fast-xml-parser from 5.5.6 to 5.5.7 (<a
href="https://redirect.github.com/julia-actions/cache/issues/208">#208</a>)</li>
<li><a
href="https://github.com/julia-actions/cache/commit/b56ac815fc0bb3999501ca86291fa3d875c622ee"><code>b56ac81</code></a>
Add instructions for LLM coding agents (AGENTS.md and CLAUDE.md) (<a
href="https://redirect.github.com/julia-actions/cache/issues/206">#206</a>)</li>
<li><a
href="https://github.com/julia-actions/cache/commit/98ad0c96108a5cbce68768b00fc3a228892105bf"><code>98ad0c9</code></a>
Bump fast-xml-parser from 5.4.2 to 5.5.6 (<a
href="https://redirect.github.com/julia-actions/cache/issues/205">#205</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/julia-actions/cache/compare/v2...v3">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=julia-actions/cache&package-manager=github_actions&previous-version=2&new-version=3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@penelopeysm penelopeysm marked this pull request as ready for review April 2, 2026 14:36
@penelopeysm penelopeysm requested a review from sunxd3 April 2, 2026 14:37
@penelopeysm
Copy link
Copy Markdown
Member Author

penelopeysm commented Apr 2, 2026

@sunxd3 would you be able to take a look? Here's the TLDR and my overall thoughts on this:

  • src/transformed_values.jl -- There used to be UntransformedValue, VectorValue and LinkedVectorValue <: AbstractTransformedValue -- these are renamed to TransformedValue(val, NoTransform()), TransformedValue(val, Unlink()), and TransformedValue(val, DynamicLink()). A lot of the changes in this PR are just boilerplate resulting from this slightly different type hierarchy. Better names are also welcome, although renaming some of this might be breaking at this point.

  • The new type hierarchy lets us extend it to TransformedValue(val, FixedTransform(f)). The new types are breaking, and we could avoid this by instead making a new subtype, FixedTransformedValue(val, f). I'm still a bit uncertain about which way to go on this: I went with the overhaul, but I don't actually think that it's necessary, and part of me thinks that it would just be better to not break the old API. If you agree, I'll try to change it back.

  • The remaining question would be whether the general interface makes sense to you (we discussed this on Monday). I think the docs are the best place to read about the interface https://turinglang.org/DynamicPPL.jl/previews/PR1327/transforms_fixed/. The implementation of the interface is in src/accumulators/fixed_transforms.jl and src/logdensityfunction.jl, but that's all quite standard boilerplate, nothing particularly interesting.

Copy link
Copy Markdown
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.

I think the type hierarchy changes all makes sense. Although it is very breaking, even though I don't imagine a lot of people depend on the transformation interface, it might still worth giving some deprecation buffer (we can talk about this in the meeting).

The general interface also make sense to me.

Multivariate 10k has some performance regression on Mooncake, I wonder why.

Comment thread src/accumulators/fixed_transforms.jl
Comment thread src/abstract_varinfo.jl Outdated
Comment thread src/logdensityfunction.jl Outdated
Comment thread src/logdensityfunction.jl Outdated
@sunxd3
Copy link
Copy Markdown
Member

sunxd3 commented Apr 5, 2026

The biggest break from this might be the removal of vi[@varname]syntax. It just existed for quite a long time

@penelopeysm
Copy link
Copy Markdown
Member Author

Multivariate 10k has some performance regression on Mooncake, I wonder why

It's just CI flakiness, unfortunately I've found the numbers to vary by up to 50% even on a good day. I benchmarked locally to be sure, and there's no difference

Benchmarking code & results

code

using DynamicPPL, Distributions, ADTypes, Mooncake, LogDensityProblems, Chairmarks
@model function multivariate(num_dims, ::Type{TV}=Vector{Float64}) where {TV}
    a = TV(undef, num_dims)
    o = TV(undef, num_dims)
    a ~ product_distribution(fill(Normal(0, 1), num_dims))
    m = sum(a)
    o ~ product_distribution(fill(Normal(m, 1), num_dims))
    return (; a=a)
end
x = randn(10000);
model = multivariate(10000) | (; o = x);
ldf = LogDensityFunction(model, getlogjoint_internal, LinkAll(); adtype=AutoMooncake());
p = rand(ldf);
@be LogDensityProblems.logdensity($ldf, $p)
@be LogDensityProblems.logdensity_and_gradient($ldf, $p)

main

julia> @be LogDensityProblems.logdensity($ldf, $p)
Benchmark: 371 samples with 1 evaluation
 min    104.875 μs (28 allocs: 1.063 MiB)
 median 148.292 μs (28 allocs: 1.063 MiB)
 mean   256.189 μs (28 allocs: 1.063 MiB, 4.57% gc time)
 max    18.380 ms (28 allocs: 1.063 MiB, 98.90% gc time)

julia> @be LogDensityProblems.logdensity_and_gradient($ldf, $p)
Benchmark: 52 samples with 1 evaluation
 min    1.454 ms (59 allocs: 2.220 MiB)
 median 1.570 ms (59 allocs: 2.220 MiB)
 mean   1.947 ms (59 allocs: 2.220 MiB, 4.33% gc time)
 max    13.387 ms (59 allocs: 2.220 MiB, 87.35% gc time)

This PR

julia> @be LogDensityProblems.logdensity($ldf, $p)
Benchmark: 432 samples with 1 evaluation
 min    106.250 μs (28 allocs: 1.063 MiB)
 median 142.667 μs (28 allocs: 1.063 MiB)
 mean   183.366 μs (28 allocs: 1.063 MiB, 4.52% gc time)
 max    1.048 ms (28 allocs: 1.063 MiB, 86.68% gc time)

julia> @be LogDensityProblems.logdensity_and_gradient($ldf, $p)
Benchmark: 50 samples with 1 evaluation
 min    1.483 ms (59 allocs: 2.220 MiB)
 median 1.571 ms (59 allocs: 2.220 MiB)
 mean   2.020 ms (59 allocs: 2.220 MiB, 5.51% gc time)
 max    14.799 ms (59 allocs: 2.220 MiB, 88.62% gc time)

@penelopeysm
Copy link
Copy Markdown
Member Author

penelopeysm commented Apr 7, 2026

The biggest break from this might be the removal of vi[@varname] syntax. It just existed for quite a long time

Yup, I think I haven't done a changelog for this PR but that definitely needs to be mentioned upfront. There is a changelog. I was more hardworking than I thought I was!

The change is intentional on my part though:

  1. vi[vn] has never really been correct -- it's known that this breaks precisely in the case where the transforms are not constant.

  2. VarInfo can store variable values in multiple places -- there is the vi.values part itself, or it could have values stored in accumulators. It's not immediately obvious to someone reading the code that vi[vn] should read from one of those and not the others.

  3. More broadly speaking, something like e.g. unflatten!! changes the former but doesn't change the latter, and I don't like that it can very easily end up in a state that's inconsistent, and that we regularly abuse inconsistent VarInfos everywhere in Turing. Because of this, my medium-term intention is to remove VarInfo entirely anyway, so this is really just one step towards that.

@sunxd3
Copy link
Copy Markdown
Member

sunxd3 commented Apr 7, 2026

I saw the changelog and think the are clear. I agree with your judgement on this — it is probably impossible to make correct at the moment and removing makes sense. I was just mentioning because it's a pattern that was used a lot internally and externally.

Maybe we could leave a deprecate or error message?

@penelopeysm
Copy link
Copy Markdown
Member Author

I added this:

julia> vi[@varname(x)]
ERROR: ArgumentError: The method `varinfo[varname(s)]` has been removed in DynamicPPL v0.41: please see https://turinglang.org/DynamicPPL.jl/stable/migration/#Getting-parameter-values for information on how to update your code if needed.

@penelopeysm
Copy link
Copy Markdown
Member Author

I think the remaining question is whether to change the type hierarchy. As I see it, the main benefit of switching it over is that basically that we don't duplicate type info for the transform + transformed value (previously they would be separate things, now the latter wraps the former). I was a bit concerned about breakage, but I did a GitHub search and I think it only breaks Turing so maybe it's not too bad?

@sunxd3
Copy link
Copy Markdown
Member

sunxd3 commented Apr 8, 2026

My judgement is that the type hierarchy breaking is not a big deal — it was pretty new and somewhat of an "advanced" feature

@sunxd3 sunxd3 closed this Apr 8, 2026
@sunxd3 sunxd3 reopened this Apr 8, 2026
@penelopeysm
Copy link
Copy Markdown
Member Author

@sunxd3 Thanks! Are you happy with the PR, or are there more things you think need to be discussed?

Copy link
Copy Markdown
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.

happy happy

@penelopeysm penelopeysm merged commit c7c68bf into breaking Apr 8, 2026
42 of 43 checks passed
@penelopeysm penelopeysm deleted the py/transforms branch April 8, 2026 22:01
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.

Generalising link strategies to support StaticTransformation

4 participants