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

TuringLang / JuliaBUGS.jl / 14523911609
84%

Build:
DEFAULT BRANCH: main
Ran 17 Apr 2025 08:25PM UTC
Jobs 1
Files 83
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

17 Apr 2025 08:06PM UTC coverage: 83.081% (+1.1%) from 81.988%
14523911609

push

github

web-flow
Generating Julia function for log density evaluation (#278)

### Motivation

JuliaBUGS compiles BUGS programs into a directed probabilistic graphical
model (PGM), which implicitly defines the dependency structure between
variables. While this graph allows for execution strategies like
topological traversal and parallelization, a significant challenge
arises from the BUGS language semantics: every element within an array
can be treated as an individual random variable.

This fine-grained dependency structure means that a naive way to
generate Julia source based on the variable-level graph would often
require fully unrolling all loops. This approach is infeasible,
especially for large datasets or complex models, and poses significant
difficulties for automatic differentiation (AD) tools to analyze the
program.

### Proposed Changes

This PR introduces an initial implementation for generating a
specialized Julia function dedicated to computing the log density of the
model. The core idea is to operate on a higher level of abstraction than
individual variable nodes.

The algorithm proceeds as follows:

1. **Statement-Level Dependence Graph:** Construct a dependence graph
where nodes represent the *statements* in the BUGS program, rather than
individual random variables. Edges represent dependencies between these
statements.
2. **Acyclicity Check:** Verify if this statement-level graph contains
any cycles (including self-loops).
3. **Topological Sort & Loop Fission:** If the graph is acyclic, perform
a topological sort on the statements. Based on this order, restructure
the program, applying full loop fission. This separates loops operating
on different variables, ensuring that computations occur in a valid
dependency order.
4. **Code Generation:** Generate a Julia function based on the
topologically sorted and fissioned sequence of statements. Specialized
code is generated for:
    * Deterministic assignments (`=`).
    * Stochastic assignments / Priors (`... (continued)

300 of 349 new or added lines in 4 files covered. (85.96%)

1 existing line in 1 file now uncovered.

2028 of 2441 relevant lines covered (83.08%)

130365.16 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
2
84.62
-15.38% src/logdensityproblems.jl
3
95.14
1.05% src/compiler_pass.jl
5
80.34
-0.1% src/model.jl
39
87.66
src/source_gen.jl

Uncovered Existing Lines

Lines Coverage ∆ File
1
80.34
-0.1% src/model.jl
Jobs
ID Job ID Ran Files Coverage
1 14523911609.1 17 Apr 2025 08:25PM UTC 83
83.08
GitHub Action Run
Source Files on build 14523911609
  • Tree
  • List 83
  • Changed 18
  • Source Changed 0
  • Coverage Changed 18
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • ae083dc7 on github
  • Prev Build on main (#14512975435)
  • Next Build on main (#14662759000)
  • 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

© 2026 Coveralls, Inc