Repository navigation
Description
An AI-assisted audit of autofit/mapper/prior/ and autofit/messages/ (follow-up to the LogUniform fix, #1329) found 9 real bugs plus refactor ideas. Every finding has now been independently re-verified on main @ 0f26ff2d8 — reproductions and full detail in #1330. This issue is the decision hub: maintainer guidance + contributor input wanted, especially from anyone with exponential-family / EP background (@rhayes777).
Will fix as one batch — no decision needed
LogGaussianPrior.with_limitscrashes on first call (TypeError: passeslower_limit/upper_limitkwargs the ctor doesn't accept);_new_for_base_messagealso broken. Fix: drop the kwargs — a log-Gaussian has support (0, ∞).UniformPrior.logpdffails on array input (scalar-only boundary snap, acknowledged# TODO). Fix: vectorise withnp.where.TruncatedNormalMessage.log_partitionis missing the Gaussian term — via the generic exponential-family interface the pdf integrates to 2.27, not 1.0 (error factor exactly σ·exp(μ²/2σ²)). Sampling andlog_prior_from_valueare unaffected; the wrong path is the one the EP machinery consumes. Fix: add the Gaussian log-partition (asNormalMessagealready does).FixedMessage.logpdf_cacheis an unbounded class-level dict that also returns an aliased mutable array (mutating a result corrupts later calls). Fix:np.zeros_like(x), no cache.
Decisions wanted (my recommendation in bold)
- Beta projection clamp is a no-op (
inv_beta_suffstatsclamps into a local that's immediately overwritten, so negative α, β escape with only a warning). When Newton–Raphson goes negative: raise (a failed projection shouldn't be silently patched to 0.5), or make the clamp work as originally intended? NormalMessageaccepts negative sigma (the assert is commented out;TruncatedNormalMessagerejects it, so the two disagree). Enforce reject σ ≤ 0 strictly, or reject only σ < 0 and permit a σ = 0 point-mass?GammaMessage.from_mode(mode, V)builds the wrong variance — inversely wrong: request var 0.25, get 2.0; request 4.0, get 0.235 (α = 1 + m²·Vhas V upside-down). Which invariant shouldfrom_modepreserve: match mean + variance (α = m²/V, β = m/V — consistent with the Normal family), the α ≥ 1-guaranteed variant (α = 1 + m²/V), or solve the quadratic to match mode + variance exactly?log_prior_from_valuenormalisation is inconsistent: Uniform/LogUniform/Gaussian/LogGaussian drop their additive constants; TruncatedNormal returns the fully normalised density. Posterior shape is unaffected either way, but evidence/Bayes-factor arithmetic andlogpdfusers see silently different conventions. Option A: drop constants everywhere, document it as the contract, add an optional per-prior log-normaliser hook — or Option B: fully normalised density everywhere (scipy convention, touches every prior + JAX paths)?RelativeWidthModifier(the default prior-passing width, 0.5·mean) yields σ = 0 for means at zero and σ < 0 for negative means — silently, until (2) lands. Scope: minimal — use abs(mean) with an optional configurable absolute floor, mandatory floor with config migration, or a full width-modifier redesign?
Parked (design work, sequenced behind the EP framework review)
Property-based prior tests (after the fixes land), TransformedMessage semantics documentation, the single-source-of-truth density refactor, the Prior/Message hierarchy collapse, and bijector-library migration. These will be shaped by the EP statistics review now underway and get their own design issues later.
🤖 Generated with Claude Code
Activity
Jammy2211 commentedon Jul 10, 2026
Status update — fixes are landing.
c0b6c94b8via fix(priors): correctness batch — crashes, log-partition, projections #1345, tracker fix(priors): correctness batch — crashes, log-partition, projections #1344 closed): the 4 no-decision fixes plus Decisions 1 (Beta clamp → raise), 3 (Gammafrom_modematches mean+variance), and 4 (Option A — drop-constants contract documented everywhere,TruncatedNormalbrought into line, newPrior.log_normalisation()hook recovers the constant for evidence users). Statistics independently re-verified on Fable; full suite 1437/14; Emcee bias-check smoke confirms posteriors unchanged.RelativeWidthModifier→abs(mean)+ opt-inabsolute_floor, strict σ ≤ 0 rejection on both message classes, and a parameter-namedPriorExceptionwhen a chained width still comes out ≤ 0. This is the only leg that changes sampling behaviour in chained fits (for the better); split out and sequenced deliberately.TransformedMessagesemantics doc (11 — code half shipped in Phase 1's docstrings), single-source density refactor (12), Prior/Message collapse (13), bijector migration (14).Jammy2211 commentedon Jul 14, 2026
Resolved — all 9 bugs fixed, all 5 decisions taken (2026-07-10)
Recording the outcome so this hub reflects reality. Everything below is merged and verified live on
main(2026-07-14).Batch fixes (no decision) — PR #1345
LogGaussianPrior.with_limitscrash — fixed (bad ctor kwargs dropped;_new_for_base_messagerepaired)UniformPrior.logpdfarray input — vectorised withnp.whereTruncatedNormalMessage.log_partition(pdf integrated to 2.27) — Gaussian cumulant added → integrates to 1.0; EPlog_normtelescope identity holdsFixedMessage.logpdf_cachealiasing — cache removed, returns freshnp.zeros_like(x)Decisions — PRs #1345 (1, 3, 4) and #1348 (2, 5)
ValueErroron negative Newton–Raphson projection (no silent escape).latentsimple_model_for_kwargs,from_mode(covariance=0),model_centred_relative). The two message classes now agree. Strict would require a first-class point-mass representation first (separate design prompt on request).from_mode→ match mean+variance (α = m²/V, β = m/V), consistent with the Normal family. α < 1 now reachable when V > m² (accepted trade).log_prior_from_valuenormalisation → Option A: drop additive constants everywhere as the documented contract, plus an opt-inPrior.log_normalisation()hook recovering the constant for evidence/Bayes-factor users.abs(mean)+ optionalabsolute_floor; the default prior-passing path now raises a parameter-namedPriorExceptionon a non-positive computed width instead of silently freezing the parameter.Regression coverage:
test_priors_messages_fixes_1331.py(12) +test_prior_width_safety.py(11); full suite green (1447 passed / 14 skipped).Leaving this issue open only for the parked design items (property-based prior tests,
TransformedMessagesemantics docs, single-source density refactor, Prior/Message hierarchy collapse, bijector migration), which are sequenced behind the EP framework review (#1332).Jammy2211 commentedon Aug 18, 2026
Parked-items status (2026-08-18) — the design backlog this hub stayed open for is now fully in motion:
Priorfamily, plus the remainingLinearShiftTransformdocstring half of item 11 (its reversal-convention half shipped in docs: formal Bayesian specification of autofit.graphical (EP review phase 2) #1334). All properties numerically validated against main before being committed as assertions.TransformedMessage.logpdf/pdfomit the transform Jacobian (UniformPrior(0,1).message.pdfintegrates to 1/(2√π), not 1) whilefactor()is correct — same shape as item 04's generic-path failure. Filed separately with full reproduction; needs a contract adjudication.__getattr__, incl.log_prior_from_value; the EP-only vs user-facing consumer split) and a staged migration proposal. Decisions requested there.Once #1499 merges and #1500 has a direction, everything this hub tracks is either shipped or has its own live issue — it can then close in favour of #1500.
Generated by Claude Code