Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callback function is not being called for TrainableModels when using optimizers that don't inherit from SciPyOptimizer #893

Open
matheoxz opened this issue Feb 11, 2025 · 0 comments
Labels
type: bug 🐞 Something isn't working
Milestone

Comments

@matheoxz
Copy link

Environment

  • Qiskit Machine Learning version: 0.8.2
  • Python version: 3.1.1
  • Operating system: Windows 11

What is happening?

Callback function is not being called for TrainableModels when using optimzers that don't inherit from SciPyOptimizer

Around 2 months ago a commit named "Fix callback compatibility for trainable_model" introduced an if clause for the callback calling in the _get_objective method, checking if the optimizer is a SciPyOptimizer instance to then execute the callback function.

But some of the optimizers in the repo are not inheriting from SciPyOptimizer, but from Optimizer, causing a bug where the callback function does not execute since the if clause is false.

ADAM, AQGD, GradientDescent, GSLS, SPSA and UMDA are not SciPyOptimizers, but it is important for any to have the callback function executed at each iteraction.

How can we reproduce the issue?

  • Train a VQC or any TrainableModel implementation
    -- with any callback function
    -- with any of the following optimizers: ADAM, AQGD, GradientDescent, GSLS, SPSA or UMDA
    -- with any data, feature_map and ansatz

What should happen?

The callback function is never executed.

Any suggestions?

No response

@matheoxz matheoxz changed the title Callback function is not being called for TrainableModels when using optimzers that don't inherit from SciPyOptimizer Callback function is not being called for TrainableModels when using optimizers that don't inherit from SciPyOptimizer Feb 11, 2025
@edoaltamura edoaltamura added the type: bug 🐞 Something isn't working label Feb 20, 2025
@edoaltamura edoaltamura added this to the v.0.8.3 milestone Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐞 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants