Skip to content

Warn when concretising a dynamic index on a GrowableArray & when creating a GrowableArray#1253

Merged
penelopeysm merged 5 commits intobreakingfrom
py/concrete-grow
Feb 4, 2026
Merged

Warn when concretising a dynamic index on a GrowableArray & when creating a GrowableArray#1253
penelopeysm merged 5 commits intobreakingfrom
py/concrete-grow

Conversation

@penelopeysm
Copy link
Copy Markdown
Member

@penelopeysm penelopeysm commented Feb 4, 2026

Closes #1241
Closes #1251

With this PR:

julia> using DynamicPPL

julia> vnt = @vnt begin
          x[1] := 1.0
       end
┌ Warning: Creating a growable `Base.Array` of dimension 1 to store values. This may not match the actual type or size of the actual `AbstractArray` that will be used inside the DynamicPPL model.
│
│  If this is not the type or size that you expect, please see: https://turinglang.org/docs/uri/growablearray
└ @ DynamicPPL.VarNamedTuples ~/ppl/dppl/src/varnamedtuple/partial_array.jl:823
VarNamedTuple
└─ x => PartialArray size=(1,) data::DynamicPPL.VarNamedTuples.GrowableArray{Float64, 1}
        └─ (1,) => 1.0

julia> vnt[@varname(x[end])]
┌ Warning: Returning a `Base.Array` with a presumed size based on the indices used to set values; but this may not be the actual type or size of the actual `AbstractArray` that was inside the DynamicPPL model. You should inspect the returned result to make sure that it has the correct value.
│
│ To find out how to avoid this warning, please see: https://turinglang.org/docs/uri/growablearray
└ @ DynamicPPL.VarNamedTuples ~/ppl/dppl/src/varnamedtuple/partial_array.jl:812
1.0

Previously neither of these would warn.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 4, 2026

Benchmark Report

  • this PR's head: 4c413f91264e7bef995a7ffa6198ac693840ffed
  • base branch: e14912c541b1a9301b261c5199cc3b964e99863c

Computer Information

Julia Version 1.11.8
Commit cf1da5e20e3 (2025-11-06 17:49 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 │   397.72 │   380.90 │    1.04 │  10.90 │   11.34 │    0.96 │   4336.91 │   4321.25 │    1.00 │
│                   LDA │    12 │ reversediff │   true │  2802.21 │  2728.02 │    1.03 │   4.96 │    4.89 │    1.01 │  13899.42 │  13343.23 │    1.04 │
│   Loop univariate 10k │ 10000 │    mooncake │   true │ 66982.16 │ 72380.60 │    0.93 │   5.06 │    5.09 │    0.99 │ 339095.46 │ 368616.21 │    0.92 │
├───────────────────────┼───────┼─────────────┼────────┼──────────┼──────────┼─────────┼────────┼─────────┼─────────┼───────────┼───────────┼─────────┤
│    Loop univariate 1k │  1000 │    mooncake │   true │  6666.86 │  8021.71 │    0.83 │   5.08 │    4.21 │    1.21 │  33883.89 │  33750.03 │    1.00 │
│      Multivariate 10k │ 10000 │    mooncake │   true │ 74629.73 │ 74777.68 │    1.00 │   4.49 │    4.42 │    1.02 │ 334827.40 │ 330366.53 │    1.01 │
│       Multivariate 1k │  1000 │    mooncake │   true │  3529.87 │  3663.39 │    0.96 │   9.50 │    9.20 │    1.03 │  33529.74 │  33685.06 │    1.00 │
├───────────────────────┼───────┼─────────────┼────────┼──────────┼──────────┼─────────┼────────┼─────────┼─────────┼───────────┼───────────┼─────────┤
│ Simple assume observe │     1 │ forwarddiff │  false │     2.67 │     2.61 │    1.02 │   3.87 │    3.95 │    0.98 │     10.32 │     10.32 │    1.00 │
│           Smorgasbord │   201 │ forwarddiff │  false │  1113.95 │  1100.72 │    1.01 │  68.75 │  133.81 │    0.51 │  76585.15 │ 147282.62 │    0.52 │
│           Smorgasbord │   201 │      enzyme │   true │  1518.26 │  1531.50 │    0.99 │   6.95 │    6.70 │    1.04 │  10547.81 │  10257.31 │    1.03 │
├───────────────────────┼───────┼─────────────┼────────┼──────────┼──────────┼─────────┼────────┼─────────┼─────────┼───────────┼───────────┼─────────┤
│           Smorgasbord │   201 │ forwarddiff │   true │  1549.09 │  1521.43 │    1.02 │  63.39 │   64.58 │    0.98 │  98195.46 │  98258.70 │    1.00 │
│           Smorgasbord │   201 │    mooncake │   true │  1607.22 │  1534.66 │    1.05 │   5.37 │    5.62 │    0.96 │   8631.13 │   8622.11 │    1.00 │
│           Smorgasbord │   201 │ reversediff │   true │  1512.20 │  1528.34 │    0.99 │ 103.07 │  100.27 │    1.03 │ 155861.67 │ 153252.74 │    1.02 │
├───────────────────────┼───────┼─────────────┼────────┼──────────┼──────────┼─────────┼────────┼─────────┼─────────┼───────────┼───────────┼─────────┤
│              Submodel │     1 │    mooncake │   true │     3.27 │     3.27 │    1.00 │  52.88 │   96.43 │    0.55 │    172.96 │    315.70 │    0.55 │
└───────────────────────┴───────┴─────────────┴────────┴──────────┴──────────┴─────────┴────────┴─────────┴─────────┴───────────┴───────────┴─────────┘

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.57%. Comparing base (e14912c) to head (4c413f9).
⚠️ Report is 2 commits behind head on breaking.

Additional details and impacted files
@@              Coverage Diff              @@
##           breaking    #1253       +/-   ##
=============================================
+ Coverage     36.98%   78.57%   +41.59%     
=============================================
  Files            46       46               
  Lines          3572     3608       +36     
=============================================
+ Hits           1321     2835     +1514     
+ Misses         2251      773     -1478     

☔ 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

github-actions bot commented Feb 4, 2026

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

@penelopeysm penelopeysm changed the title Warn when concretising a dynamic index on a GrowableArray Warn when concretising a dynamic index on a GrowableArray & when creating a GrowableArray Feb 4, 2026
@penelopeysm penelopeysm merged commit 8577d8d into breaking Feb 4, 2026
21 checks passed
@penelopeysm penelopeysm deleted the py/concrete-grow branch February 4, 2026 12:55
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.

1 participant