Skip to content

Change interface for nak_torch#29

Draft
dannys4 wants to merge 64 commits into
mainfrom
dannys4/main_loop
Draft

Change interface for nak_torch#29
dannys4 wants to merge 64 commits into
mainfrom
dannys4/main_loop

Conversation

@dannys4
Copy link
Copy Markdown
Member

@dannys4 dannys4 commented Apr 24, 2026

This pull request introduces significant refactoring and modernization to the example scripts and algorithm API usage in the project. The main changes involve updating the usage of particle-based inference algorithms to use new class-based APIs, centralizing the execution logic through a new nak function, and improving reproducibility and clarity in the examples. There are also minor improvements and cleanups in type usage and plotting.

Refactor and API Modernization

  • Updated all example scripts (examples/gaussian.py, examples/himmelblau.py) to use the new class-based APIs for algorithms such as MSIP, SVGD, GradALDI, GradFreeALDI, CBS, and EKS, replacing previous function-based calls. The new nak function is now used as a central entry point for running these algorithms, leading to more consistent and maintainable code. [1] [2] [3] [4]

  • Now use explicit random number generators (torch.Generator) for reproducibility, and initialization of particles and random seeds is more explicit and consistent. [1] [2]

Type and Interface Cleanups

  • Several type hints and batch evaluation interfaces are improved, with more consistent use of batched log-density and gradient evaluators. [1] [2]

  • Minor type and import cleanups, such as using DeviceLike from the project’s types module instead of redefining it in examples/pyro_tools.py.

Miscellaneous

  • Minor changes to plotting and function signatures to support the new interfaces and improve code clarity, such as making auxiliary arguments explicit in functions and cleaning up unused code. [1] [2] [3]

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.

1 participant