BQSKit / bqskit

Berkeley Quantum Synthesis Toolkit
Other
113 stars 32 forks source link

`CeresMinimizer` from `bqskitrs` requires `num_residuals`, which is neither documented nor properly implemented in the Python code #264

Open WolfLink opened 1 month ago

WolfLink commented 1 month ago

CeresMinimizer from bqskitrs makes a call to num_residuals on DifferentiableResidualsFunction objects. The string num_residuals is not present anywhere in the Python bqskit repo, making it unclear that this is a requirement for DifferentiableCostFunction.

Also HilbertSchmidtResiduals does not implement num_residuals, which is problematic for what I am trying to do (I'm writing a residuals function that modifies another residuals function).

WolfLink commented 1 month ago

A workaround I have come up with: a wrapper class that implements num_residuals by saving the parameters from the circuit passed in gen_cost, passing those parameters to get_residuals, and counting the number of residuals that come out of it.