Skip to content

New Bonsai.ML.Lds.Torch package to extract latents from high-dimensional data using TorchSharp#70

Merged
glopesdev merged 92 commits intobonsai-rx:mainfrom
ncguilbeault:dev/torch-lds
Mar 12, 2026
Merged

New Bonsai.ML.Lds.Torch package to extract latents from high-dimensional data using TorchSharp#70
glopesdev merged 92 commits intobonsai-rx:mainfrom
ncguilbeault:dev/torch-lds

Conversation

@ncguilbeault
Copy link
Collaborator

@ncguilbeault ncguilbeault commented Sep 29, 2025

Summary

This PR introduces a new package, Bonsai.ML.Lds.Torch, which implements linear dynamical systems (LDS) using TorchSharp for online filtering, smoothing, and parameter estimation in Bonsai. This package differs from the Bonsai.ML.LinearDynamicalSystems package in that it does not depend on Python, and the models parameters can be customised. A test was added to compare the output of the TorchSharp implementation with the output of the lds_python package following parameter estimation and filtering of neural recordings.

The PR in #77 should be merged first.

Refactoring the unit test to download the expected results instead of generating them with a Python script fixes #75

@ncguilbeault ncguilbeault added the feature New planned feature label Sep 29, 2025
@ncguilbeault ncguilbeault force-pushed the dev/torch-lds branch 3 times, most recently from 6b0e89b to 93a8db0 Compare September 30, 2025 16:06
@glopesdev
Copy link
Member

glopesdev commented Oct 10, 2025

Leaving here a summary of what we discussed earlier about deprecating the Bonsai.ML.LinearDynamicalSystems package and adopting back-end suffixes for systems with different implementations. In this case the steps would be:

  • Rename the package to Bonsai.ML.Lds.Torch
  • Rename Bonsai.ML.LinearDynamicalSystems to Bonsai.ML.Lds.Python
  • Deprecate the Bonsai.ML.LinearDynamicalSystems package

The one consideration we discussed was whether to "nest" namespaces, e.g. we could use the name Bonsai.ML.Torch.Lds to make it so that all types in Bonsai.ML.Torch would be automatically visible to ML packages using the Torch backend. In the end we decided to go with the suffix, and import functionality where needed, similar to what is done with most non-overlapping .NET namespaces.

@ncguilbeault
Copy link
Collaborator Author

Updating the namespace of the existing Bonsai.ML.LinearDynamicalSystems resulted in quite a few changes. Because of this, I decided to push these changes to a separate PR which we should merge first before this one. The new PR is here: #74

Copy link
Member

@glopesdev glopesdev left a comment

Choose a reason for hiding this comment

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

Looks good, left only a few minor comments to review.

@ncguilbeault ncguilbeault force-pushed the dev/torch-lds branch 3 times, most recently from d041405 to f857e16 Compare November 11, 2025 14:29
@ncguilbeault ncguilbeault force-pushed the dev/torch-lds branch 4 times, most recently from eeb66f6 to a237e2c Compare December 16, 2025 11:24
@ncguilbeault ncguilbeault force-pushed the dev/torch-lds branch 2 times, most recently from 4daa799 to cfd1e68 Compare January 13, 2026 12:32
…Observations` and `numStates` are not provided
…her than individual files which is more consistent with other `Bonsai.ML` packages
…ved validation logic outside of `KalmanFilter` module
…including moving devices, setting scalar types, and setting gradient tracking
…be loaded without explicitly setting type and fixed path support
@glopesdev glopesdev changed the title New package to extract latents from high-dimensional data using LDS and TorchSharp New Bonsai.ML.Lds.Torch package to extract latents from high-dimensional data using TorchSharp Mar 12, 2026
@glopesdev glopesdev added this to the v0.5.0 milestone Mar 12, 2026
@glopesdev glopesdev merged commit aadd5e4 into bonsai-rx:main Mar 12, 2026
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New planned feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GitHub Action Runner Failing Due to Out of Disk Space Exception During Unit Test Execution

2 participants