-
Notifications
You must be signed in to change notification settings - Fork 54
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
base: master
Are you sure you want to change the base?
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 <edoardo.pedicillo@gmail.com>
@@ -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.
def decompose_into_Pauli_basis(h_matrix: np.array, pauli_operators: list): | |
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.
Thanks for the updates.
I'm sorry for the late review, I was busy with other projects.
For the notebooks a general comment, we recently changed the way we set the backend in qibo. Now set_backend("qibojit", "numba")
will not work anymore you need to specify the second argument set_backend("qibojit", platform="numba")
.
Also I feel like there are too many notebooks, maybe some of them we should keep for internal debugging purposes. Having a look at the other folders under example I don't know if it is the best idea to use just notebooks. I would prefer if we switch to an approach where we document the code properly through sphinx and code examples. We could discuss about this later.
Regarding the PR I still have a few suggestions. Make sure that there are no conflicts and that tests are passing. Let me know if you need any help.
…into dbi_magnetic_field_ising_model
…nts moved to utils_analytical
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
ca52a55
to
d45cdce
Compare
[No action required] Note for future: The next commit will remove the analytical approaches to optimizing |
Features include:
Changes in
double_bracket.py
which has new cost functionssee https://github.com/qiboteam/qibo/blob/4d4c45295499fd7ccf559bdff63ab494a0bc0c3e/src/qibo/models/dbi/double_bracket.py#L152
see https://github.com/qiboteam/qibo/blob/4d4c45295499fd7ccf559bdff63ab494a0bc0c3e/src/qibo/models/dbi/double_bracket.py#L166
https://github.com/qiboteam/qibo/blob/4d4c45295499fd7ccf559bdff63ab494a0bc0c3e/src/qibo/models/dbi/double_bracket.py#L223
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