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

Dbi non classical simulation #1330

Draft
wants to merge 6 commits into
base: DBI-transpiling-into-Hamiltonian-Simulation
Choose a base branch
from
Draft
24 changes: 24 additions & 0 deletions src/qibo/models/dbi/double_bracket_evolution_oracles.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from enum import Enum, auto
from math import ceil

import hyperopt
import numpy as np
Expand Down Expand Up @@ -165,6 +166,29 @@ def check_accuracy(n_steps):
assert np.linalg.norm(combined_circuit.unitary() - target_unitary) < eps
return combined_circuit

def non_classical_bound(self, s, epsilon):
"""
We assume h has more than 2 terms.
This is meant for the setting where classical simulation is not possible.
We use the bound sum ||h||s^2 <= C_h s^2 N where Ch = max(h)
and hence we set N= epsilon/(Chs^2) and then we round it up.
commutator_loss takes in a symbolic hamiltonian and compute the norm.
epsilon is the error tolerance level that we set.
we return the step size required
"""

# decompose the terms
def commutator_norm(a, b):
a_mat = a.matrix
b_mat = b.matrix
return np.linalg.norm(a_mat @ b_mat - b_mat @ a_mat)

terms = self.h.terms
# find the maximum norm
n = len(terms)
Ch = max([commutator_norm(terms[i], terms[i + 1]) for i in range(n - 1)])
return ceil(epsilon / (Ch * s**2))


class FrameShiftedEvolutionOracle(EvolutionOracle):
def __init__(
Expand Down
Loading