Skip to content

Stop presizing the marginalization memo to a million entries - #571

Draft
shravanngoswamii wants to merge 1 commit into
mainfrom
sg/marginal-memo-hint
Draft

shravanngoswamii wants to merge 1 commit into
mainfrom
sg/marginal-memo-hint

Conversation

@shravanngoswamii

Copy link
Copy Markdown
Member

The hint reserved room for a million entries on every evaluation of a model with more than 20 discrete latents.
That is about 50 MiB a call, and several hundred MiB a ForwardDiff gradient since the cached values are duals.
A ForwardDiff gradient of Eye Tracking drops from 94 to 39 ms, and of Cervix from 148 to 91 ms.

@github-actions

Copy link
Copy Markdown
Contributor

Benchmark Results

Julia 1.13.4 on Intel(R) Xeon(R) 6975P-C (Linux)

Ratio = JuliaBUGS/Stan (lower is better for JuliaBUGS)

# Params shows Stan / JuliaBUGS when parameter counts differ.

Log Density uses generated evaluation. Gradient columns measure log density + gradient.

McRvs = Mooncake reverse mode with generated evaluation; FwdDiff = ForwardDiff with graph evaluation.

Model # Params Log Density Ratio McRvs Ratio FwdDiff Ratio
rats 65 0.47x 2.06x 86.95x
pumps 12 1.88x 2.11x 17.17x
bones 13 0.73x 3.55x 1.16x
oxford 244 1.58x 4.41x 575.23x
epil 303 0.47x 1.61x 988.53x
lsat 1006 0.65x 1.96x 1446.85x
schools 133 0.29x 1.84x 66.47x
beetles 2 2.47x 4.98x 11.70x
air 5 2.18x 1.94x 13.62x

Note: Stan benchmarks use hand-optimized Stan models, not direct BUGS translations. Comparison is illustrative only.

@github-actions

Copy link
Copy Markdown
Contributor

JuliaBUGS.jl documentation for PR #571 is available at:
https://TuringLang.github.io/JuliaBUGS.jl/previews/PR571/

@codecov

codecov Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.11%. Comparing base (5fd788c) to head (09de0a5).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #571      +/-   ##
==========================================
- Coverage   88.49%   88.11%   -0.38%     
==========================================
  Files          30       30              
  Lines        3851     3846       -5     
==========================================
- Hits         3408     3389      -19     
- Misses        443      457      +14     
Flag Coverage Δ
callbacks 28.43% <ø> (-0.07%) ⬇️
compilation_model 50.06% <ø> (+0.06%) ⬆️
compilation_source_gen 44.91% <ø> (+0.05%) ⬆️
distributed_sampling 38.60% <ø> (+0.05%) ⬆️
elementary 27.93% <ø> (+0.03%) ⬆️
frontend 47.08% <ø> (+0.06%) ⬆️
gibbs 39.68% <ø> (+0.05%) ⬆️
graphs 21.17% <ø> (+0.02%) ⬆️
inference_chains 37.01% <ø> (-0.06%) ⬇️
inference_flexichains ?
inference_hmc 29.94% <ø> (+0.03%) ⬆️
inference_marginalization 31.01% <ø> (-0.10%) ⬇️
inference_mh 35.50% <ø> (+0.04%) ⬆️
inference_slice_sampling 26.31% <ø> (+0.03%) ⬆️
log_density 59.09% <ø> (-0.06%) ⬇️
model_operations 42.96% <ø> (-0.05%) ⬇️
parallel_sampling ?
params_with_stats 38.13% <ø> (-0.06%) ⬇️
serialization 34.32% <ø> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

This branch has not been deployed

No deployments
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