- 
        Couldn't load subscription status. 
- Fork 36
Closed
Description
MWE:
using Turing
@model function mymodel(n)
    x ~ filldist(Normal(), n)
    return x[1]
end
for n in [10, 100, 1000, 10_000]
    mod = mymodel(n)
    chn = sample(mod, Prior(), 10)
    @time returned(mod, chn)
endgives
  0.000808 seconds (2.95 k allocations: 129.688 KiB)
  0.003559 seconds (14.14 k allocations: 1.431 MiB)
  0.114613 seconds (146.33 k allocations: 81.974 MiB)
  3.866223 seconds (1.66 M allocations: 7.510 GiB, 28.82% gc time)
For models with many parameters returned is basically unusable because of this.
Profview shows that all the computation time is happening in call to DynamicPPL.setval_and_resample! inside the loop that has a TODO
DynamicPPL.jl/ext/DynamicPPLMCMCChainsExt.jl
Lines 251 to 254 in ea6b6de
| # TODO: Use `fix` once we've addressed https://github.com/TuringLang/DynamicPPL.jl/issues/702. | |
| # Update the varinfo with the current sample and make variables not present in `chain` | |
| # to be sampled. | |
| DynamicPPL.setval_and_resample!(varinfo, chain, sample_idx, chain_idx) | 

Metadata
Metadata
Assignees
Labels
No labels