• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

TuringLang / JuliaBUGS.jl / 17583314660
84%

Build:
DEFAULT BRANCH: main
Ran 09 Sep 2025 01:19PM UTC
Jobs 1
Files 31
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

09 Sep 2025 12:56PM UTC coverage: 83.267% (+0.06%) from 83.204%
17583314660

push

github

web-flow
Add an argument to `condition` function to skip generating and evaling log density function (#394)

## Motivation
`condition` currently regenerates the log-density function on every
call, invoking MacroTools transforms and `eval`. This is too slow for
hot loops.

We want a fast path for repeated conditioning that:
- Avoids regeneration
- Lets users update observed values in-place without changing graph
structure
- Allows explicit regeneration later to regain compiled performance when
desired

## Summary of Changes
- `condition` now supports a fast path via a keyword flag:
- `condition(model, conditioning_spec;
regenerate_log_density::Bool=true)`
- When `false`: skips regeneration, nulls the compiled function, and
forces graph evaluation mode
- New helper for value updates without reconditioning:
  - `set_observed_values!(model, obs::Dict{<:VarName,<:Any})`
- Updates evaluation environment values of already-observed stochastic
variables in-place
  - Validates existence, stochasticity, and observation status
- New function to regenerate the compiled log-density function without
changing the evaluation mode:
  - `regenerate_log_density_function(model; force=false)`
- Re-generates for the model’s current graph + environment and refreshes
graph evaluation data
- Exports added:
- `set_observed_values!` and `regenerate_log_density_function` (from
`Model` module)

## Tiny Benchmark for Sanity Check
with 
```julia
@bugs begin
    for i in 1:N
        x[i] ~ Normal(0, 1)
    end
    y ~ Normal(sum(x[:]), 1)
end
```

```
BenchmarkTools results (N=100, iters=200):
  Single condition: regular = 13.96 ms, fast = 0.15 ms, speedup ≈ 92.3x
  Loop conditioning: regular = 28139.5 ms, fast(update only) = 0.2 ms, speedup ≈ 112840.1x
```

Interpretation:
- Single call to `condition`: ~90x faster when skipping regeneration
- Hot loop: one fast `condition` + repeated `set_observed_values!` is
~1e5x faster than repeatedly reconditioning

26 of 28 new or added lines in 1 file covered. (92.86%)

3130 of 3759 relevant lines covered (83.27%)

130875.52 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
2
95.56
-0.55% JuliaBUGS/src/model/abstractppl.jl
Jobs
ID Job ID Ran Files Coverage
1 17583314660.1 09 Sep 2025 01:19PM UTC 31
83.27
GitHub Action Run
Source Files on build 17583314660
  • Tree
  • List 31
  • Changed 2
  • Source Changed 2
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #17583314660
  • 61ed22dc on github
  • Prev Build on main (#17547593305)
  • Next Build on main (#17946015706)
  • Delete
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc