Skip to content

added slds support code - #279

Closed
anushri10 wants to merge 8 commits into
BasisResearch:mainfrom
anushri10:feature/add-slds
Closed

anushri10 wants to merge 8 commits into
BasisResearch:mainfrom
anushri10:feature/add-slds

Conversation

@anushri10

Copy link
Copy Markdown
  • Added MixedStateDistribution and SLDS components
  • Add RBPFConfig and cd-dynamax RBPF integration (this assumes cd-dynamax RBPF marginal_loglik support is integrated)
  • added a test script for SLDS with RBPF

@mattlevine22
mattlevine22 self-requested a review July 24, 2026 18:07
@mattlevine22

Copy link
Copy Markdown
Collaborator

Thanks Anushri! I'll review this and give feedback, but let's wait for #255 to clear before merging this.

@anushri10

Copy link
Copy Markdown
Author

Quick update -- working on it this week!

@mattlevine22

Copy link
Copy Markdown
Collaborator

Excellent! I think landing the SLDS updates in CD-Dynamax will be a big first step!

Comment thread dynestyx/distributions.py
return jnp.concatenate([z[..., None].astype(x.dtype), x], axis=-1)

def log_prob(self, value):
z = jnp.rint(value[..., 0]).astype(jnp.int32)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will round a category of 1.4 to 1 and proceed from there.

On one hand, that is "bad" because the log_prob should be -Inf for 1.4 (it is invalid).

  • So, we could do some checks here to fix that.

On the other hand, rounding could be advantageous if we later try to naively use a different filter with these distributions.

I'll open a PR on your repo to start filling in these suggestions



def _prepare_slds_rbpf_inputs(dynamics, obs_values, obs_times, ctrl_times, ctrl_values):
emissions = obs_values[:, None] if obs_values.ndim == 1 else obs_values

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look to see if we need these .ndim checks or if we can promise a single shape earlier on in the code

@mattlevine22
mattlevine22 self-requested a review October 8, 2026 04:16
@mattlevine22

Copy link
Copy Markdown
Collaborator

Overall status:

  1. I made a PR to @anushri10's branch for fixing some things Proposed improvements for SLDS code anushri10/dynestyx#1.
  • @anushri10 can you review that PR when you have chance?
  1. Once that is merged, we can reconcile the small merge conflicts above

  2. After that, I think I'm happy with merging this as-is.

However, there are some outstanding issues beyond what I addressed in the PR that I've gotten chatGPT to help me identify + summarize:

  1. RBPF posterior samples omit within-component uncertainty. The adapter computes the aggregate covariance correctly, but discards each particle’s conditional Gaussian covariance. Posterior sampling then treats conditional means as point masses, understating uncertainty in posterior draws and forecasts. Retain those covariances and sample from the weighted Gaussian components.
  2. Use a consistent distribution representation for mixed states. Initialization and transitions use MixedStateDistribution, while an RBPF posterior needs multiple Gaussian components that may share a discrete label. Consider generalizing the existing distribution to represent both cases, with correct sampling and log_prob. The CD-Dynamax initialization adapter must continue enforcing its narrower one-Gaussian-per-category requirement.
  3. Complete batch and plate support. MixedStateDistribution currently assumes no batch dimensions, and switching-model parameters receive inconsistent treatment during plate mapping and slicing. Category axes must remain distinct from plate axes, including when their sizes happen to match. Test both shared and plate-specific parameters.
  4. Reconcile CD-Dynamax filtering with simulation conventions. The review identified potential discrepancies in whether a transition precedes the first observation, whether initialization counts uncertainty twice, and which control input drives each transition. Confirm and resolve these so filtering and simulation describe the same model, with regression tests covering the initial observation and controlled transitions.

@DanWaxman

Copy link
Copy Markdown
Collaborator

Closing as superseded by #428.

@DanWaxman DanWaxman closed this Oct 21, 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.

3 participants