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

QubitOperator import from Tangelo, for better encapsulation #299

Merged
merged 27 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
23104ce
Integrate bug fix into main before release (#278) (#279)
ValentinS4t1qbit Feb 17, 2023
cf6f723
Depth function dramatically accelerated through breakthrough lookup d…
Feb 25, 2023
d77988d
Clean up
Feb 27, 2023
808e361
Merge branch 'goodchemistryco:develop' into develop
ValentinS4t1qbit Mar 8, 2023
940ed65
Merge branch 'goodchemistryco:develop' into develop
ValentinS4t1qbit Mar 17, 2023
e364a4d
Merge branch 'goodchemistryco:develop' into develop
ValentinS4t1qbit Apr 7, 2023
3729e94
Small fixes & exposing NoiseModel to a higher level
May 4, 2023
30c0707
QubitOperator imports focused on Tangelo, wip
May 4, 2023
fd080b4
Encapsulated get_sparse_op for both Fermion and QubitOperator. Small …
May 4, 2023
d8dcae0
Less ambiguous convertion to Openfermion, more homogeneous
May 4, 2023
c4d0a2a
Trim trivial qubits from circuit and Hamiltonian (#296)
elloyd-1qbit May 16, 2023
a503c39
Revert "Trim trivial qubits from circuit and Hamiltonian (#296)" (#301)
ValentinS4t1qbit May 17, 2023
6940f3b
Get_sparse_operator called externally by openfermion, after conversio…
May 23, 2023
be8d413
Get_sparse_operator called externally by openfermion, after conversio…
May 23, 2023
7332922
Get_sparse_operator called externally by openfermion, after conversio…
May 24, 2023
b5b0c41
Get_sparse_operator called externally by openfermion, after conversio…
May 24, 2023
c203131
boop.
Jun 6, 2023
c779327
Merge branch 'goodchemistryco:main' into small_stuff
ValentinS4t1qbit Jun 15, 2023
44dbc12
Merge branch 'small_stuff' of https://github.com/ValentinS4t1qbit/Tan…
Jun 15, 2023
4bd49ff
revert change
Jun 15, 2023
aab704f
revert change
Jun 15, 2023
b237bc5
openfermion qubitops can now be loaded into Tangelo ops directly
Jun 15, 2023
c93d990
openfermion qubitops can now be loaded into Tangelo ops directly
Jun 15, 2023
db46786
openfermion qubitops can now be loaded into Tangelo ops directly
Jun 15, 2023
ec7b7fd
openfermion qubitops can now be loaded into Tangelo ops directly
Jun 15, 2023
49038ee
openfermion qubitops can now be loaded into Tangelo ops directly
Jun 16, 2023
23145ac
openfermion qubitops can now be loaded into Tangelo ops directly
Jun 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tangelo/linq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
from .simulator import get_backend
from .target.backend import get_expectation_value_from_frequencies_oneterm
from .target import backend_info, Backend
from .noisy_simulation import NoiseModel
29 changes: 11 additions & 18 deletions tangelo/linq/target/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,18 @@
import numpy as np
from scipy import stats
from bitarray import bitarray
from openfermion.ops import QubitOperator

from tangelo.linq import Gate, Circuit
from tangelo.linq.helpers.circuits.measurement_basis import measurement_basis_gates
from tangelo.toolboxes.operators import QubitOperator


def get_expectation_value_from_frequencies_oneterm(term, frequencies):
"""Return the expectation value of a single-term qubit-operator, given
the result of a state-preparation.

Args:
term (openfermion-style QubitOperator object): a qubit operator, with
only a single term.
term (QubitOperator): a single-term qubit operator.
frequencies (dict): histogram of frequencies of measurements (assumed
to be in lsq-first format).

Expand Down Expand Up @@ -82,8 +81,7 @@ def get_variance_from_frequencies_oneterm(term, frequencies):
"""Return the variance of the expectation value of a single-term qubit-operator, given
the result of a state-preparation.
Args:
term (openfermion-style QubitOperator object): a qubit operator, with
only a single term.
term (QubitOperator): a single-term qubit operator.
frequencies (dict): histogram of frequencies of measurements (assumed
to be in lsq-first format).
Returns:
Expand Down Expand Up @@ -315,8 +313,7 @@ def get_expectation_value(self, qubit_operator, state_prep_circuit, initial_stat
actual QPU.

Args:
qubit_operator (openfermion-style QubitOperator class): a qubit
operator.
qubit_operator (QubitOperator): the qubit operator.
state_prep_circuit (Circuit): an abstract circuit used for state preparation.
initial_statevector (array): The initial statevector for the simulation
desired_meas_result (str): The mid-circuit measurement results to select for.
Expand Down Expand Up @@ -376,8 +373,7 @@ def get_variance(self, qubit_operator, state_prep_circuit, initial_statevector=N
actual QPU.

Args:
qubit_operator (openfermion-style QubitOperator class): a qubit
operator.
qubit_operator (QubitOperator): the qubit operator.
state_prep_circuit (Circuit): an abstract circuit used for state preparation.
initial_statevector (list/array) : A valid statevector in the format
supported by the target backend.
Expand Down Expand Up @@ -431,8 +427,7 @@ def get_standard_error(self, qubit_operator, state_prep_circuit, initial_stateve
actual QPU.

Args:
qubit_operator (openfermion-style QubitOperator class): a qubit
operator.
qubit_operator (QubitOperator): the qubit operator.
state_prep_circuit (Circuit): an abstract circuit used for state preparation.
initial_statevector (list/array): A valid statevector in the format
supported by the target backend.
Expand All @@ -452,7 +447,7 @@ def _get_expectation_value_from_statevector(self, qubit_operator, state_prep_cir
this function directly, please call "get_expectation_value" instead.

Args:
qubit_operator (openfermion-style QubitOperator class): a qubit operator.
qubit_operator (QubitOperator): the qubit operator.
state_prep_circuit (Circuit): an abstract circuit used for state preparation (only pure states).
initial_statevector (array): The initial state of the system

Expand Down Expand Up @@ -503,7 +498,7 @@ def _get_expectation_value_from_frequencies(self, qubit_operator, state_prep_cir
using the frequencies of observable states.

Args:
qubit_operator (openfermion-style QubitOperator class): a qubitoperator.
qubit_operator (QubitOperator): the qubit operator.
state_prep_circuit (Circuit): an abstract circuit used for state preparation.
initial_statevector (array): The initial state of the system
desired_meas_result (str): The mid-circuit measurement results to select for.
Expand Down Expand Up @@ -551,7 +546,7 @@ def _get_variance_from_frequencies(self, qubit_operator, state_prep_circuit, ini
using the frequencies of observable states.

Args:
qubit_operator (openfermion-style QubitOperator class): a qubit operator.
qubit_operator (QubitOperator): the qubit operator.
state_prep_circuit (Circuit): an abstract circuit used for state preparation.
initial_statevector (list/array) : A valid statevector in the format
supported by the target backend.
Expand Down Expand Up @@ -599,8 +594,7 @@ def get_expectation_value_from_frequencies_oneterm(term, frequencies):
the result of a state-preparation.

Args:
term (openfermion-style QubitOperator object): a qubit operator, with
only a single term.
term (QubitOperator): a single-term qubit operator
frequencies (dict): histogram of frequencies of measurements (assumed
to be in lsq-first format).

Expand All @@ -617,8 +611,7 @@ def get_variance_from_frequencies_oneterm(term, frequencies):
the result of a state-preparation.

Args:
term (openfermion-style QubitOperator object): a qubit operator, with
only a single term.
term (QubitOperator): a single-term qubit operator.
frequencies (dict): histogram of frequencies of measurements (assumed
to be in lsq-first format).

Expand Down