Skip to content
Browse files

Upgrade tapering qubit function (#527)

* Update qubit tapering for stabilizers weight larger than operator, including test

* Update qubit tapering for stabilizers weight larger than operator, including test

* Modify NOTICE, README including myself
  • Loading branch information...
xabomon authored and babbush committed Jul 10, 2019
1 parent 8f91be8 commit 5b73977537269d8cbdb1c45a559b6af1126840f8
@@ -7,6 +7,7 @@ Kevin J. Sung (University of Michigan)
Ian Kivlichan (Harvard)

Dave Bacon (Google)
Xavier Bonet-Monroig (Leiden University)
Yudong Cao (Harvard)
Chengyu Dai (University of Michigan)
E. Schuyler Fried (Harvard)
@@ -132,6 +132,7 @@ Authors
`Kevin Sung <>`__ (University of Michigan),
`Ian Kivlichan <>`__ (Harvard),
`Dave Bacon <>`__ (Google),
`Xavier Bonet-Monroig <>`__ (Leiden University),
`Yudong Cao <>`__ (Harvard),
`Chengyu Dai <>`__ (University of Michigan),
`E. Schuyler Fried <>`__ (Harvard),
@@ -171,7 +172,7 @@ How to cite
When using OpenFermion for research projects, please cite:

Jarrod R. McClean, Kevin J. Sung, Ian D. Kivlichan, Yudong Cao,
Jarrod R. McClean, Kevin J. Sung, Ian D. Kivlichan, Xavier Bonet-Monroig, Yudong Cao,
Chengyu Dai, E. Schuyler Fried, Craig Gidney, Brendan Gimby,
Pranav Gokhale, Thomas Häner, Tarini Hardikar, Vojtĕch Havlíček,
Oscar Higgott, Cupjin Huang, Josh Izaac, Zhang Jiang, William Kirby, Xinle Liu,
@@ -451,7 +451,16 @@ def taper_off_qubits(operator, stabilizers, manual_input=False,
the remaining qubits have been moved up to
those indices.
n_qbits = count_qubits(operator)
if isinstance(stabilizers, (list, tuple, numpy.ndarray)):
n_qbits_stabs = 0
for ent in stabilizers:
if count_qubits(ent) > n_qbits_stabs:
n_qbits_stabs = count_qubits(ent)
n_qbits_stabs = count_qubits(stabilizers)

n_qbits = max(count_qubits(operator), n_qbits_stabs)

qbts_to_rm) = reduce_number_of_terms(operator,
@@ -19,7 +19,7 @@
from openfermion.hamiltonians import MolecularData
from openfermion.ops import QubitOperator
from openfermion.transforms import jordan_wigner, get_fermion_operator
from openfermion.utils import eigenspectrum
from openfermion.utils import eigenspectrum, count_qubits

from openfermion.utils import reduce_number_of_terms, taper_off_qubits
from openfermion.utils._qubit_tapering_from_stabilizer import (
@@ -331,7 +331,20 @@ def test_tapering_qubits_remove_positions(self):
fixed_positions=[0, 3],

tapered_spectrum = eigenspectrum(tapered_hamiltonian)

self.assertAlmostEqual(spectrum[0], tapered_spectrum[0])
self.assertEqual(positions, [0, 3])

def test_tappering_stabilizer_more_qubits(self):
"""Test for stabilizer with more qubits than operator."""
hamiltonian = QubitOperator('Y0 Y1', 1.0)
stab = QubitOperator('X0 X1 X2', -1.0)

num_qubits = max(count_qubits(hamiltonian),
tap_ham = taper_off_qubits(hamiltonian, stab)
num_qubits_tap = count_qubits(tap_ham)

self.assertFalse(num_qubits == num_qubits_tap)

0 comments on commit 5b73977

Please sign in to comment.
You can’t perform that action at this time.