Skip to content

Comments

add report callback class#14

Open
gauravmanmode wants to merge 38 commits intoapoorvalal:masterfrom
gauravmanmode:master
Open

add report callback class#14
gauravmanmode wants to merge 38 commits intoapoorvalal:masterfrom
gauravmanmode:master

Conversation

@gauravmanmode
Copy link

@gauravmanmode gauravmanmode commented Apr 13, 2025

I have created a copy of the Report class with following signature
PyReport( py::dict resultIn,
bool disableOutput = false,
const double iterationsPercentageIn = 0.1,
const size_t outputMatrixSizeIn = 4) :
this way we can store some extra info by passing a dict, and trigge output with disableOutput = false.
Also, I have made passing a PyReport class optional.
am i heading in the right direction?

apoorvalal and others added 30 commits November 18, 2024 00:35
frank wolfe with simplex constraints solver
…ystem

Split the monolithic _pyensmallen.cpp file into modular components:
- utils.hpp: Common utilities and wrapper classes
- newton_type.hpp: L-BFGS implementation
- constrained.hpp: Frank-Wolfe algorithm for constrained optimization
- first_order.hpp: Adam and its variants

Also updated the build system to use setuptools instead of meson for better compatibility.
Created benchmark_performance.py which:
- Generalizes the likelihood_comparison notebook into a reusable script
- Tests performance across different dataset sizes (n,k)
- Compares pyensmallen against other popular optimization libraries
- Generates visualizations and summary tables
- Includes command-line options for customization

This will help demonstrate pyensmallen's performance advantages.
Refactor C++ code into modular files and switch to setuptools build system. Add detailed benchmarks.
gmm implementation with autodiff-ed gradients and bootstrap
@gauravmanmode gauravmanmode marked this pull request as draft April 13, 2025 04:28
@gauravmanmode gauravmanmode marked this pull request as ready for review April 13, 2025 17:45
@janosg
Copy link

janosg commented Apr 29, 2025

Hi @apoorvalal, thanks again for making these great optimizers accessible in Python. @gauravmanmode is currently working on wrapping your package in optimagic and this PR would be really helpful to do so. Can you let us know if you are open to go into this direction?

@apoorvalal
Copy link
Owner

Hi, sorry I've fallen behind on this; excited to see progress and def happy to move forward with it. I'll have more bandwidth soon and will try to get this over the line.

@janosg
Copy link

janosg commented Apr 30, 2025

No worries. Thanks for the quick reply!

@gauravmanmode
Copy link
Author

Thanks, @apoorvalal , if you can review this PR and tell me if this is in the right direction?

@apoorvalal
Copy link
Owner

Specifically, you want to log both the criterion function value and coordinates to be able to make this figure

@janosg
Copy link

janosg commented May 19, 2025

Hi @apoorvalal, we collect the data for the figure you linked for every optimizer by modifying the user's objective function. So there is no need to support this in the low-level optimizer libraries. If you are interested in how it works you could look for example here in our `InternalOptimizationProblem.

What we mainly need from pyensmallen is the function value evaluated at the optimal parameters (without doing an additional evaluation ourselves).

@gauravmanmode gauravmanmode reopened this May 22, 2025
@apoorvalal apoorvalal requested a review from Copilot June 22, 2025 04:48
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new callback class to allow passing extra report information via a Python dictionary and updates the L-BFGS optimizer binding to accept an optional report parameter.

  • Added inclusion of "report.hpp" and Python binding for the new Report class.
  • Modified the optimize method for L-BFGS to incorporate a report callback with a default null value.
Comments suppressed due to low confidence (2)

pyensmallen/module.cpp:44

  • Ensure that adding the optional 'report' parameter to the optimize method matches the intended use cases and that the implementation correctly handles a nullptr value for report.
      .def("optimize", &PyL_BFGS::Optimize,

pyensmallen/module.cpp:254

  • [nitpick] Verify that exposing the C++ class 'PyReport' as 'Report' is intentional and clearly documented to avoid confusion among users regarding the class's origin.
      py::class_<ens::PyReport>(m, "Report")

@janosg
Copy link

janosg commented Jul 20, 2025

Hi @apoorvalal, we would like to complete the pyensmallen wrappers in optimagic during this year's google summer of code. The coding period will end in about 6 weeks. Do you think we could get this PR merged on time?

@gauravmanmode
Copy link
Author

gauravmanmode commented Aug 12, 2025

Hi @apoorvalal,
I have added some tests and a notebook explaining how to use it.
For our purpose, we do not need the optimizer history as it is collected here anyways. We just want the objective fun value and extra info. Doing an additional evaluation will add to the history which is not intended.
Here is the wrapper over L-BFGS optimizer from pyensmallen.

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