Skip to content

fix(messages): keep the full covariance through coupled transforms in from_mode - #1572

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/transformed-from-mode-coupled-covariance
Sep 7, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/transformed-from-mode-coupled-covariance

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Closes #1569. Finding 3 of the Codex review of the phase-2 EP fixes (#1560 introduced the path; umbrella #1405).

Problem

TransformedMessage.from_mode reduced a LinearOperator covariance to its diagonal before pushing it through the transform Jacobians. jac.quad contracts a 1-D argument as a vector, J(Jᵀv), not as diag(v), so a coupled Jacobian (MultinomialLogitTransform's ShermanMorrison, used by MultiLogitNormalMessage) lost the off-diagonal J Σ Jᵀ mass that belongs on the diagonal. Pre-#1560 this path raised; #1560 made it silently wrong. Scalar transforms have diagonal Jacobians where both contractions coincide, which is why every campaign test passed.

Σ input form before after delta method
diag(0.02, 0.03) ndarray [1.2222, 1.2431] [1.2222, 1.2431] [1.2222, 1.2431]
diag(0.02, 0.03) MatrixOperator / DiagonalMatrix [2.3611, 2.1875] [1.2222, 1.2431]
non-diagonal MatrixOperator [2.3611, 2.1875] [1.5778, 1.5542] [1.5778, 1.5542]

Fix

Keep the dense matrix (to_dense(), the existing accessor) through the Jacobian loop when transforms are present; take the diagonal only in the no-transform case. No new methods, no guards.

Impact

Defensive path only: the sole in-library caller, MeanField.from_mode_covariance, passes dense ndarrays. MultiLogitNormalMessage has no workspace usage.

API Changes

None.

Tests

  • New test__coupled_jacobian_keeps_the_full_covariance in test_autofit/messages/test_transformed_from_mode.py: operator forms match the ndarray form (rel 1e-6) and the ndarray form matches an independent delta-method diag(J Σ Jᵀ) (rel 1e-4), over a diagonal and a non-diagonal Σ.
  • test_autofit/messages: 95 passed. test_autofit/graphical: 265 passed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Gu4YysuvpQ4k6zkQjiwabd

… from_mode (#1569)

`TransformedMessage.from_mode` reduced a LinearOperator covariance to its
diagonal before applying the transform Jacobians, so a coupled Jacobian
(MultinomialLogitTransform's ShermanMorrison, used by MultiLogitNormalMessage)
contracted the vector as J(Jᵀv) instead of diag(J Σ Jᵀ): operator inputs gave
[2.3611, 2.1875] where the equivalent ndarray gave [1.2222, 1.2431]. Keep the
dense matrix through the Jacobian loop when transforms are present; take the
diagonal only in the no-transform case. Scalar transforms are unchanged.
Pre-#1560 this path raised; #1560 made it silently wrong. Codex review of the
phase-2 fixes, finding 3.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gu4YysuvpQ4k6zkQjiwabd
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Sep 7, 2026
@Jammy2211
Jammy2211 merged commit 31f13c1 into main Sep 7, 2026
4 checks passed
@Jammy2211
Jammy2211 deleted the feature/transformed-from-mode-coupled-covariance branch September 7, 2026 21:32
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Sep 26, 2026
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.

fix(messages): keep the full covariance through coupled transforms in from_mode

1 participant