You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Keep ensemble defaults unchanged when a component rejects an observation #2198
On main, EnsemblePosterior.set_default_x() in sbi/inference/posteriors/ensemble_posterior.py can partially update the ensemble when a later component rejects the new observation. The ensemble validates using the first component's event shape, assigns its own default, and then updates each component in order. A successful component update also clears its cached MAP.
Example
Use an ensemble whose first component has an unknown observation event shape and whose later direct component expects event shape (1, 2). Set a valid default with shape (1, 1, 2), then try to set a tensor with shape (2, 2). The ensemble and first component accept the new tensor, but the later component rejects its shape. The ensemble and earlier component retain the rejected default, and later calls without an explicit x can fail.
Required change
Validate the proposed default for every component before changing any default or invalidating caches. Preserve the existing defaults and caches if any component rejects the observation.
Acceptance criteria
Add a regression test for a later component rejecting an observation that the ensemble and an earlier component accept.
After the rejection, assert that the ensemble and all component defaults and existing caches remain unchanged.
Confirm that a valid observation still updates all defaults and performs the appropriate cache invalidation.
@BHARATH0153 thanks, I can confirm this on main: after a rejected set_default_x(), the ensemble and its first component keep the new x, and later calls without x fail.
The cause is the same as in issue #2199: the ensemble checks x against the shape of its first component only. Checking the shapes of all components when the ensemble is built fixes both issues, see my comment there.
Please add the fix to PR #2193. We will review it next week.
done in PR #2193EnsemblePosterior.set_default_x() now validates the proposed observation with every component via _process_x() before mutating any default or clearing a MAP cache, so a rejection leaves the ensemble and all components unchanged. A valid observation still updates all defaults and clears the caches. The shared build-time shape resolution from #2199 prevents this mismatch at the ensemble boundary. Added fast regression tests for the rejected default, unchanged defaults/caches, and the valid update.
Activity
janfb commentedon Nov 19, 2026
@BHARATH0153 thanks, I can confirm this on
main: after a rejectedset_default_x(), the ensemble and its first component keep the newx, and later calls withoutxfail.The cause is the same as in issue #2199: the ensemble checks
xagainst the shape of its first component only. Checking the shapes of all components when the ensemble is built fixes both issues, see my comment there.Please add the fix to PR #2193. We will review it next week.
thanks, Jan
BHARATH0153 commentedon Nov 19, 2026
done in PR #2193
EnsemblePosterior.set_default_x()now validates the proposed observation with every component via_process_x()before mutating any default or clearing a MAP cache, so a rejection leaves the ensemble and all components unchanged. A valid observation still updates all defaults and clears the caches. The shared build-time shape resolution from #2199 prevents this mismatch at the ensemble boundary. Added fast regression tests for the rejected default, unchanged defaults/caches, and the valid update.BHARATH0153 commentedon Nov 20, 2026
fixed in #2193
test: keep the tests that catch silent regressions, move ensemble tests
test: keep the tests that catch silent regressions, move ensemble tests
fix!: amortized VI sample() and log_prob() take one observation (sbi-…