Repository navigation
Conversation
Contributor
|
DynamicPPL.jl documentation for PR #1548 is available at: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1548 +/- ##
==========================================
+ Coverage 85.34% 85.49% +0.14%
==========================================
Files 52 52
Lines 4714 4783 +69
==========================================
+ Hits 4023 4089 +66
- Misses 691 694 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
BenchmarksPerformance 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: EnvironmentJulia 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) |
A draw into the second element of `(0, 0)` left the mixed tuple
`(0, draw)`, so a later tilde into the first element threw when values
were recorded, and a `Float64` draw into
`Union{Missing,Int}[2^53 + 1, missing]` rounded the retained element.
Tilde writes now promote same-type tuples, and throw when promotion
would change a retained element.
`VarNamedTuple` storage now uses the same setter, so `x[] ~ dist` can
record values for zero-dimensional arrays. Keyword-index writes, such
as `x[X=2]` on a `DimArray`, keep the array type.
Assisted-by: Claude Code <noreply@anthropic.com>
Assisted-by: Codex <codex@openai.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split of #1529 (part 4.3 of 12; part 4 comes as nine PRs).
A tilde write into existing storage could leave it unusable for a later tilde, or silently change a value the model did not write:
x = (0, 0); x[2] ~ Normal(),xis the mixed tuple(0, draw), so a laterx[1] ~ Normal()throws "same-type tuples only" underrand,VarInfoorLogDensityFunction;Float64draw intoUnion{Missing,Int}[2^53 + 1, missing]rounds the retained2^53 + 1to2^53.Tilde writes now go through DynamicPPL's own setter instead of
Accessors.set. A write into a tuple whose elements share one type promotes every element, so the first example gives(0.0, draw)and the later tilde succeeds. A write throws anArgumentErrorif promotion would change a retained element, as in the second example, or if it would leave a tuple with mixed element types. Arrays with a plain isbits element type, such asVector{Int}, are not checked, including when nested, because their unset entries hold arbitrary bits; aFloat64draw into[2^53 + 1, 0]therefore still rounds the retained element, as onmain. Thread-safe evaluation, which accepts only in-place writes, keeps its existing path.The mixed-tuple check changes the result for tuple arguments. For
@model f(x) = (x[1] ~ Normal(); x), a plain callf((missing, missing))returned(draw, missing)and now throws; passUnion{Missing,Float64}[missing, missing]or a tuple of the draw's type instead. HISTORY lists these changes as breaking.The new setter also fixes three smaller cases:
x = fill(0.0); x[] ~ Normal()no longer throws underrandandLogDensityFunction, becauseVarNamedTuplestorage now uses the same setter;x[X=2] ~ Normal()on aDimArraynow writes in place, soxstays aDimArrayrather than becoming its parent array;rand(model)still throws for keyword indices, whichVarNamedTuplestorage does not accept;x[1] ~ Normal(), wherexismissingor anothingassigned in the model body, throws anArgumentErrornaming the variable instead of aMethodError.LogDensityFunctionevaluation and ForwardDiff gradients ofDynamicPPL.TestUtils.DEMO_MODELSare unchanged in inference, allocations and time.