Skip to content

Add DYSCO for aligned repeated-trial dynamics - #317

Draft
myscience wants to merge 9 commits into
AdaptiveMotorControlLab:mainfrom
myscience:codex/dysco-aligned-trials
Draft

myscience wants to merge 9 commits into
AdaptiveMotorControlLab:mainfrom
myscience:codex/dysco-aligned-trials

Conversation

@myscience

@myscience myscience commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

This draft adds a scikit-learn entry point for DYSCO, the multi-view dynamics method of Muratore and Mathis. It targets regularly sampled repetitions in a shared observation space, with optional observed inputs. Feedback on the trial contract and the solver interface would help before we finalize this for release. Paper · Standalone implementation and examples

import cebra

# Each array has shape (time, feature). Trials with the same ID already align.
model = cebra.DYSCO(output_dimension=2, sample_interval=0.05)
model.fit(trials, alignment_ids=condition_ids)
z = model.transform(trials[0])
forecast = model.rollout(z[0], num_steps=10)
print(*model.equations(), sep="\n")

The loader samples synchronized windows across distinct repetitions. A shared encoder and a continuous-time polynomial field generate forward and backward RK4 trajectories. The criterion implements the submitted three-block loss with CEBRA’s full-denominator InfoNCE reduction. The estimator exposes embedding, field evaluation, equation inspection, rollout and checkpoint continuation. The offline oscillator and Lorenz examples generate their own observations.

Dependency. This branch includes the exact checkpoint commits from #312. They preserve the auxiliary reference model, which owns DCL dynamics. Once that PR lands we can update this branch against main. The DYSCO-specific changes start at 5526c10.

Review and validation

  • Frozen reference cases compare loss values and gradients with the submitted implementation. Coverage also includes window boundaries, observed-control interpolation in both time directions, analytic fields, checkpoint round trips, and continuation with the private samplers.
  • On the final commit, the full local CPU suite passed 3,364 tests, with 110 skipped and 6,965 dataset-dependent cases deselected. The focused run passed 96 tests and skipped two accelerator cases. The last change preserves the prior model after an invalid refit and keeps forecasting on the sampling interval actually fitted.
  • A separate FP32 check matched an additive controlled quadratic field, four RK4 steps in both directions, encoded states, and random event draws across the public implementation and this branch. The scalar loss agreed exactly in this case. Maximum absolute differences were 1.2e-7 for the field and rollouts, 3.0e-7 for gradients with respect to encoded states, and 4.2e-9 for gradients with respect to controls.
  • On two recorded Lorenz runs with an unseen initial condition, transported field R² was 0.505–0.544. At 20 steps, forecast MSE was 0.305–0.326 times persistence MSE. Those examples use a smaller training regime, direct polynomial coefficients and a different observation setup from the reference experiments. Matching end-to-end recovery under the paper protocol remains open.
  • The current solver adapter carries trajectory tensors through CEBRA’s three batch slots. In particular, we would welcome feedback on introducing a named trajectory result and a shared loss hook. Broader accelerator/platform validation remains open.

Upstream CI. In the completed Python 3.14 / Torch 2.9.1 job, both DYSCO test modules passed. Two unchanged data-loading doctests failed when GitHub returned HTTP 503 for the DeepLabCut example HDF5 file. Both passed on a local retry. The matrix canceled its remaining jobs, and restarting it requires upstream admin rights. Failing job

I have signed the Contributor License Agreement.

@cla-bot cla-bot Bot added the CLA signed label Nov 26, 2026
@myscience myscience assigned stes and unassigned stes Nov 26, 2026
@myscience
myscience requested a review from stes November 26, 2026 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants