Repository navigation
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the change adding graph fallback for unsupported multivariate discrete latents.
No open issues 🎉
What changed in this PR
Fixes #561 by preventing JuliaBUGS auto-marginalization from treating latent multinomial counts as continuous parameters. Unsupported multivariate discrete latents now trigger a warning and fall back to UseGraph().
Changes:
- Adds explicit classification and fallback handling for multivariate discrete latents.
- Adds regression tests for latent fallback and continued acceptance of observed multinomial nodes.
- Updates documentation to clarify supported latents and fallback behavior.
| File | Description |
|---|---|
| JuliaBUGS/test/model/auto_marginalization.jl | Tests latent multinomial fallback and observed multinomial compatibility. |
| JuliaBUGS/src/model/evaluation.jl | Adds explicit multivariate discrete classification. |
| JuliaBUGS/src/model/bugsmodel.jl | Rejects unsupported multivariate discrete latents to trigger graph fallback. |
| JuliaBUGS/docs/src/inference/auto_marginalization.md | Documents supported latents and multinomial fallback behavior. |
Review effort: Balanced
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #574 +/- ##
==========================================
+ Coverage 88.49% 88.56% +0.06%
==========================================
Files 30 30
Lines 3851 3855 +4
==========================================
+ Hits 3408 3414 +6
+ Misses 443 441 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
shravanngoswamii
left a comment
There was a problem hiding this comment.
_require_continuous_gibbs_component still lets :discrete_multivariate through, so Gibbs accepts NUTS on a latent dmulti while it rejects it on a latent dpois (gibbs.jl#L86-L99).
Could it reject :discrete_multivariate too? cc @sunxd3
shravanngoswamii
left a comment
There was a problem hiding this comment.
Could this get a History.md entry under Bug Fixes? 0.18.1 is tagged, so it would go under a new 0.18.2 heading.
|
thanks for catching that. the Gibbs guard now rejects multivariate discrete variables for NUTS and slice sampling, and i added a regression test for each. i also added the bug fix entry under 0.18.2 in History.md. both test groups passed locally. |
Benchmark ResultsJulia 1.13.4 on Intel(R) Xeon(R) 6975P-C (Linux) Ratio = JuliaBUGS/Stan (lower is better for JuliaBUGS)
Log Density uses generated evaluation. Gradient columns measure log density + gradient. McRvs = Mooncake reverse mode with generated evaluation; FwdDiff = ForwardDiff with graph evaluation.
Note: Stan benchmarks use hand-optimized Stan models, not direct BUGS translations. Comparison is illustrative only. |
Fixes #561.
Auto-marginalization treated a latent
dmultinode as continuous. Classify multivariate discrete variables explicitly so unsupported latents warn and fall back toUseGraph(). Observed multinomial nodes can still be used in auto-marginalization mode.The two new warning and fallback assertions failed before the fix. All 5,309 assertions in
model/auto_marginalization.jlpassed afterward on Julia 1.12.7, including the observed multinomial case.