Repository navigation
feature / grouped EM for the Poisson LDS - #169
Open
harrisonritz wants to merge 9 commits into
Open
harrisonritz wants to merge 9 commits into
harrisonritz wants to merge 9 commits into
Conversation
harrisonritz
force-pushed
the
claude/split-pr-165-incremental-t8k2s5-3
branch
from
August 13, 2026 23:04
635129b to
b21a602
Compare
harrisonritz
force-pushed
the
claude/split-pr-165-incremental-t8k2s5-4
branch
from
August 13, 2026 23:05
e5143f7 to
3ee52cd
Compare
harrisonritz
force-pushed
the
claude/split-pr-165-incremental-t8k2s5-3
branch
from
August 13, 2026 23:26
b21a602 to
8be149a
Compare
harrisonritz
force-pushed
the
claude/split-pr-165-incremental-t8k2s5-4
branch
from
August 13, 2026 23:26
3ee52cd to
378f37c
Compare
harrisonritz
force-pushed
the
claude/split-pr-165-incremental-t8k2s5-3
branch
from
August 13, 2026 23:33
8be149a to
91f13b5
Compare
harrisonritz
force-pushed
the
claude/split-pr-165-incremental-t8k2s5-4
branch
from
August 13, 2026 23:33
378f37c to
74f1932
Compare
harrisonritz
force-pushed
the
claude/split-pr-165-incremental-t8k2s5-3
branch
from
August 14, 2026 11:15
91f13b5 to
f4a73c3
Compare
harrisonritz
force-pushed
the
claude/split-pr-165-incremental-t8k2s5-4
branch
from
August 14, 2026 11:15
74f1932 to
207c902
Compare
Extends condition-dependent parameters (#165) to the Poisson model family: `fit!`, `smooth` and `elbo` now honour a Poisson LDS's `depends_on` instead of rejecting it. The state side is identical to the Gaussian path — per-cell Laplace E-step, pooled sufficient statistics per parameter version — so it reuses `grouped_em.jl` unchanged. Only the emission differs: the Poisson likelihood is non-conjugate and has no sufficient-statistic form, so the M-step runs one LBFGS solve per version of `[C d D]`, over the trials of every cell that shares that version. A `[C d D]` shared across cells is therefore still fit from all of their data. The ELBO mirrors `_grouped_estep_elbo_gaussian!` with the observation-side Q-term left as the per-trial loop extracted in the first PR of this series, and adds one prior term per distinct `[C d D]` — the bare quadratic the LBFGS emission objective penalizes, since a Poisson emission has no noise covariance to pair the MN prior with. The SLDS keeps the interim guard until its own follow-up. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MgmEbyHewqUYTJLFegAoK5
harrisonritz
force-pushed
the
claude/split-pr-165-incremental-t8k2s5-3
branch
from
August 14, 2026 11:35
f4a73c3 to
a3f54f4
Compare
harrisonritz
force-pushed
the
claude/split-pr-165-incremental-t8k2s5-4
branch
from
August 14, 2026 11:35
207c902 to
f0b8efb
Compare
This reverts 072a465. The change calls `_prepare_cell!(sws_pool, state, ...)` with `sws_pool::Vector{SmoothWorkspace{T}}`, but the `Vector` method of `_prepare_cell!` does not exist yet on this branch — it arrives with the per-cell workspace pools in the stitching PR. Only the scalar method is defined here, so the call is a MethodError the moment a grouped Poisson fit reaches the emission M-step: MethodError: no method matching _prepare_cell!(::Vector{SmoothWorkspace{Float64}}, ...) Closest candidates are: _prepare_cell!(::SmoothWorkspace, ::GroupedFitState, ::Int64) which is what fails "Ancillary parameter dependencies / Poisson fitting" on all three test jobs here. The change itself is right, just a PR too early; it is re-landed on the stitching branch, where the pooled `_prepare_cell!` it needs is defined. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014wJNTtEFZwFUUFvgKbq4F7
Runs JuliaFormatter v1.0.62 (the version test/Project.toml pins, blue style with always_use_return) over the tree, so the "Code Formatting" test passes. Whitespace only, no logic changes. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014wJNTtEFZwFUUFvgKbq4F7
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## claude/split-pr-165-incremental-t8k2s5-3 #169 +/- ##
============================================================================
+ Coverage 96.71% 96.79% +0.07%
============================================================================
Files 20 20
Lines 4018 4084 +66
============================================================================
+ Hits 3886 3953 +67
+ Misses 132 131 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Patch coverage here was 88.40%, in two gaps that mirror the Gaussian driver's. A Poisson emission has no noise covariance, so its `[C d D]` prior cannot be the conjugate matrix-normal update the Gaussian side uses — it enters the objective as a bare quadratic penalty, once per version of `[C d D]`, and nothing exercised it. The test drives it from the outside rather than asserting the term's value: with `M₀ = 0`, tightening `Λ` across 0, 10 and 200 has to pull every group's emission monotonically towards zero and cost ELBO for doing so. Both orderings are checked, so a penalty that was evaluated but not actually applied would fail. The Laplace-EM loop's early return — `finish!` the meter, truncate `elbos` to the iterations actually run — needed a fit converging before `max_iter`, and `progress=true` needed any caller at all. Adds two shared helpers (`pd_grouped_poisson_data`, `pd_grouped_poisson_lds`) for the grouped-Poisson truth these use. Ancillary parameter dependencies 132 -> 145 assertions. Patch coverage of the files this PR touches: 69/69 added executable lines. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014wJNTtEFZwFUUFvgKbq4F7
harrisonritz
marked this pull request as ready for review
August 23, 2026 16:32
# Conflicts: # test/LinearDynamicalSystems/ParameterDependencies.jl
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
4 of 5 — splitting #165 into reviewable pieces. Stacked on #168; the diff here is only this PR's changes.
fit!,smoothandelbonow honour a Poisson LDS'sdepends_oninstead of rejecting it. The smallest PR in the series: the state side is entirely reused from #168.What is and isn't new
The state side — per-cell Laplace E-step, pooled sufficient statistics per parameter version,
x0/P0/[A b B]/Qupdates — is identical to the Gaussian path and reusesgrouped_em.jlunchanged. So the only genuinely new logic is the emission:The Poisson emission is non-conjugate, with no sufficient-statistic form, so it cannot be pooled the way the Gaussian regression is. Instead the M-step runs one LBFGS solve per version of
[C d D], over the trials of every cell that shares that version — so a[C d D]shared across cells is still fit from all of their data, and a per-session[C d D]is fit only from that session's.The ELBO mirrors
_grouped_estep_elbo_gaussian!, with the observation-side Q-term left as the per-trial loop extracted in #166. Its prior term adds one contribution per distinct[C d D]: the bare quadratic that the LBFGS objective penalizes, since a Poisson emission has no noise covariance for the MN prior to pair with.Tests
test_grouped_poisson_fit— a two-session ground truth with genuinely different emissions per session, fitted from a shared starting point: the ELBO is finite and increases, the two sessions come out with different[C d], andelbo/smoothwork on the fitted grouped model.Follow-up in this series
depends_on: declare, validate, and read back per-group parameters #167 is gone entirely.Generated by Claude Code