Skip to content

fix: warn when pyro posterior params fall back to uniform - #23

Merged
nceglia merged 1 commit into
mainfrom
fix/pyro-params-empty-store-warning
Jun 2, 2026
Merged

fix: warn when pyro posterior params fall back to uniform#23
nceglia merged 1 commit into
mainfrom
fix/pyro-params-empty-store-warning

Conversation

@nceglia

@nceglia nceglia commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • _ensure_pyro_posterior_params re-initialized q_p_ct_raw to a uniform 1/P simplex whenever the Pyro param store lacked it — silently. This masked failed or missing param-store loads, so downstream posterior metrics ran on an uninformative prior with no signal to the caller.
  • Emit a RuntimeWarning before the fallback, naming the affected metrics (joint_distribution_posterior, phenotypic/clonotypic entropy, mutual information) and the likely cause (param store not persisted/restored).
  • The early-return path (when q_p_ct_raw is already present) stays silent — no behavior change on the happy path.

Why

The fallback originally existed because PyTorch >= 2.6 weights_only=True made pyro.get_param_store().load() throw silently; the caught exception left metrics running on a uniform prior with no error. With the torch>=2.6 load fixed, this fallback should now only fire on a genuinely empty/missing store — and a re-initialized (uniform) posterior is almost never what the caller wanted, so it should be loud.

Tests

  • NUMBA_CACHE_DIR=... MPLCONFIGDIR=... pytest tests/test_pyro_params.py -v -> 2 passed
  • Full suite -> 23 passed

New tests/test_pyro_params.py: warns on empty store (and still populates the param so callers can proceed), silent when already present. Both snapshot/restore the global Pyro param store to avoid cross-test leakage.

Closes Notion #24.

🤖 Generated with Claude Code

_ensure_pyro_posterior_params silently re-initialized 'q_p_ct_raw' to a
uniform 1/P simplex whenever the Pyro param store lacked it. That masked
failed/missing param-store loads: downstream posterior metrics then ran on
an uninformative prior with no signal to the caller (Notion #24).

Emit a RuntimeWarning before the fallback, naming the affected metrics and
the likely cause (param store not persisted/restored). Behavior is otherwise
unchanged; the early-return path when 'q_p_ct_raw' is present stays silent.

Adds tests/test_pyro_params.py: warns on empty store (and still populates the
param), silent when already present. Tests snapshot/restore the global Pyro
param store to avoid cross-test leakage.

Closes Notion #24.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@nceglia
nceglia marked this pull request as ready for review June 2, 2026 04:50
@nceglia
nceglia merged commit 042c3ec into main Jun 2, 2026
2 checks passed
@nceglia
nceglia deleted the fix/pyro-params-empty-store-warning branch June 2, 2026 05:17
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