Skip to content

Auto generate - #68

Open
Ziaeemehr wants to merge 82 commits into
mainfrom
auto_generate
Open

Auto generate#68
Ziaeemehr wants to merge 82 commits into
mainfrom
auto_generate

Conversation

@Ziaeemehr

@Ziaeemehr Ziaeemehr commented May 21, 2026

Copy link
Copy Markdown
Collaborator

Context

This is a major update that introduces the new main simulator pipeline. Existing workflows are intended to remain functional, while this new stack gradually replaces older implementations as validation and examples mature.

Summary

This PR adds the new VBI simulator stack built around backend-agnostic model specifications, generated backend implementations, validation tests, and example workflows.

Changes

  • Add vbi.simulator API with SimulationSpec, ModelSpec, coupling, integrator, monitor, sweep, and stimulus specs.
  • Add NumPy, Numba, C++, JAX, and CUDA backend support for single simulations and parameter sweeps.
  • Add generated neural mass model specs, including MPR, Jansen-Rit, Wilson-Cowan, Kuramoto, VEP, GHB, SL, and related models.
  • Add feature extraction pipeline updates and JAX/Numba utility implementations.
  • Add validation tests across models, backends, sweeps, BOLD, and feature pipelines.
  • Add simulator examples, benchmarks, backend validation scripts, equation notebook, and stimulation demo.
  • Update packaging, docs, CI workflow, pytest markers, and contribution notes.

Notes

  • origin/main was used as the comparison base.
  • The latest commits add external stimulation support through StimSpec, including NumPy and Numba backend handling.

Ziaeemehr and others added 30 commits March 16, 2026 11:26
- Added test_features_utils.py (52 tests): is_sequence, make_mask,
  prepare_input_ts, get_intrah_mask, get_interh_mask, get_masks,
  set_k_diagonals, if_symmetric

- Added test_features_utils_ext.py (75 tests): autocorr_norm,
  create_symmetric_matrix, lpc, kde, gaussian, calc_ecdf,
  compute_time, calc_fft, max_frequency, max_psd, spectral_centroid,
  spectral_spread, km_order, normalize_signal, seizure_onset_indicator,
  nat2bit, median_frequency, fundamental_frequency, spectral_distance

- Improved docstrings for median_frequency, nat2bit

All 230 tests pass (103 existing + 127 new).

Closes #64
…JAX-compatible version with comprehensive tests for backward compatibility and overlap functionality.
- Implemented NumpySimulator class for running simulations using NumPy.
- Created NumpySweeper class for parameter sweeps with support for pipelines.
- Defined model specifications for MontbrioPopulationRate (MPR) including state variables and parameters.
- Established simulation specifications including integrator, coupling, and monitor configurations.
- Added support for various monitor types (raw, subsample, tavg, gavg, bold) to capture simulation data.
- Developed tests for validating the functionality of the NumPy backend, including deterministic and stochastic scenarios.
- Ensured consistency between sweeper results and direct simulator runs.
- Mark M0 milestone as complete and detail implemented components.
- Defer backend-specific feature extraction variants to respective milestones.
- Refactor imports in `__init__.py` and `utils.py` to handle exceptions more gracefully.
- Add validation tests for TVB reference in `test_mpr_numpy.py`.
… noise amplitude; add test for noise amplitude resolution based on style
- Added code generation for model-specific Numba functions in `codegen.py`.
- Implemented the `NumbaSimulator` class for single-run simulations in `simulator.py`.
- Created `NumbaSweeperCPU` for parallel parameter sweeps in `sweeper.py`.
- Developed validation tests for the Numba backend in `test_mpr_numba.py`, ensuring results match the NumPy backend to specified tolerances.
- Included support for deterministic and stochastic simulations, as well as handling of delays and monitor outputs.
…for consistency across Numba and NumPy backends
Ziaeemehr added 28 commits May 19, 2026 16:44
…andling and performance

- Updated CudaSimulator to support coalesced memory layout and optional sparse connectivity.
- Introduced automatic detection of sparse vs dense connectivity based on matrix density.
- Enhanced parameter handling in CudaSweeperGPU to streamline device memory transfers.
- Improved documentation for clarity on connectivity options and usage.
- Adjusted kernel launch parameters to accommodate new data structures and layouts.
- Added memory guard to warn about potential GPU memory issues during simulation.
- Updated `validate_sweep_backends.py` to include JAX as a backend for numerical consistency checks, with adjustable tolerance levels for JAX.
- Enhanced JAX integration in `jax_/simulator.py` to support float64 precision and noise handling.
- Modified `IntegratorSpec` to allow specification of JAX data types (float32 or float64).
- Updated `SweepSpec` to include a `same_noise` parameter for controlling noise realization consistency across JAX runs.
- Added comprehensive tests in `test_mpr_jax.py` and `test_new_models_jax.py` to validate JAX outputs against NumPy, ensuring deterministic and stochastic behaviors are correctly implemented.
…h LaTeX support

- Created a new Jupyter notebook `model_equations.ipynb` to describe equations for all models in `vbi.simulator.models`.
- Enhanced `ModelSpec` to include `dfun_latex` for LaTeX representations of differential equations.
- Updated existing models to provide LaTeX strings for their equations, improving documentation and usability in Jupyter notebooks.
- Added supplementary notes in LaTeX format for clarity on model parameters and equations.
- Enhanced C++ backend to support Kuramoto coupling alongside linear coupling.
- Updated JAX, Numba, and CUDA backends to implement Kuramoto coupling with phase frustration.
- Modified coupling specifications to include an alpha parameter for phase offset.
- Added tests to validate Kuramoto dynamics and ensure consistency across backends.
@Ziaeemehr
Ziaeemehr requested a review from Copilot May 21, 2026 14:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

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