-
Notifications
You must be signed in to change notification settings - Fork 61
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
Dbi cost functions #1269
Dbi cost functions #1269
Conversation
…_scheduling_polynomial; test_double_bracket_iteration_scheduling_grid_hyperopt
for more information, see https://pre-commit.ci
…o dbi_magnetic_field
…o dbi_magnetic_field
…bi_magnetic_field
…bi_magnetic_field
…o dbi_magnetic_field
Co-authored-by: Edoardo Pedicillo <[email protected]>
first intro block for dbi doc
for more information, see https://pre-commit.ci
Add dbi notebooks to documentation
98f4b2f
to
5247508
Compare
5247508
to
fdf60de
Compare
src/qibo/models/dbi/utils.py
Outdated
@@ -162,3 +101,58 @@ def cs_angle_sgn(dbi_object, d): | |||
) | |||
) | |||
return np.sign(norm) | |||
|
|||
|
|||
def decompose_into_Pauli_basis(h_matrix: np.array, pauli_operators: list): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Sam-XiaoyueLi please check that including this will not impact some function using it?
@scarrazza that was a long one! :) Many thanks among others to @wrightjandrew for the initiative on adding cost functions that help gradient descent and to @Sam-XiaoyueLi for suggesting the new optimizers and implementing the strategies + tests (there's a lot of things that went into this multi branch PR). Also thanks @andrea-pasquale for helping us finalize the tests! |
Features include:
Changes in
double_bracket.py
which has new cost functionssee
qibo/src/qibo/models/dbi/double_bracket.py
Line 152 in 4d4c452
see
qibo/src/qibo/models/dbi/double_bracket.py
Line 166 in 4d4c452
qibo/src/qibo/models/dbi/double_bracket.py
Line 223 in 4d4c452
These are used via the loss function
qibo/src/qibo/models/dbi/double_bracket.py
Lines 211 to 221 in 4d4c452
Scheduling strategies for find the local minimum given a bracket$W=[D,H]$ .
These are implemented in
utils_scheduling.py
and include:grid_search_step
hyperopt_step
polynomial_step
simulated_annealing_step
Gradient descent methods for finding$D$ operators
This is done in$D$ .$D$ based on two possible choices of representing a matrix
utils_gradients.py
. There are 2 ways of finding gradients defined by how we parametrizeWe parametrize the ansatz for
More specifically we have the cases for parametrizing diagonal matrices$D$ as
The comutational basis ansatz is there for completeness, once an operator$D$ is found it has to be compiled and so in any case a Pauli basis representation will be used. We recommend using gradient descent directly in the Pauli basis representation. In principle the full optimization in the computational basis could allow for finding operators that outperform an Ising model ansatz but then the operator may be inefficient to compile.
For these parametrizations there is the associated gradient descent method to find the numerical values of the parameters$(B,J)$ or $(d)$
See https://github.com/qiboteam/qibo/blob/dbi_cost_functions/examples/dbi/dbi_cost_functions_and_d_gradients_tutorial.ipynb for results
gradient_descent_dbr_pauli_basis
- the naming convention reflects that we perform the gradient descent aiming to optimize a double-bracket rotation and we parametrized the ansatz in the Pauli basisd_opt, loss_opt, grad_opt, diags_opt = gradient_descent_dbr_computational_basis(dbi, params, 100,lr=1e-2, d_type = d_ansatz_type.element_wise)
Checklist:
Still some work to be done but just wanted to try how the pull request works and see if I'm doing things correctly