From fab68e93d88355582839de6f95b9ce5eaa88cde2 Mon Sep 17 00:00:00 2001 From: TimWeaving Date: Tue, 28 Nov 2023 14:48:12 +0000 Subject: [PATCH 1/4] Changed target_sqp in QubitTapering from X to Z --- symmer/projection/qubit_tapering.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/symmer/projection/qubit_tapering.py b/symmer/projection/qubit_tapering.py index 150d7885..011dfd40 100644 --- a/symmer/projection/qubit_tapering.py +++ b/symmer/projection/qubit_tapering.py @@ -21,7 +21,7 @@ class QubitTapering(S3_projection): """ def __init__(self, operator: PauliwordOp, - target_sqp: str = 'X' + target_sqp: str = 'Z' ) -> None: """ Input the PauliwordOp we wish to taper. From 872b67d5bca54f1e3d598727593b5cee6564fb93 Mon Sep 17 00:00:00 2001 From: TimWeaving Date: Tue, 28 Nov 2023 14:56:09 +0000 Subject: [PATCH 2/4] Fixed test after switching target_sqp X->Z in QubitTapering --- tests/test_projection/test_contextual_subspace.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_projection/test_contextual_subspace.py b/tests/test_projection/test_contextual_subspace.py index 8449a213..24bd448e 100644 --- a/tests/test_projection/test_contextual_subspace.py +++ b/tests/test_projection/test_contextual_subspace.py @@ -150,7 +150,7 @@ def test_project_state_onto_subspace(up_method): CS.update_stabilizers(3, aux_operator=CC_taper, strategy='aux_preserving') CS.project_onto_subspace() projected_state = CS.project_state_onto_subspace(QT.tapered_ref_state) - assert projected_state == QuantumState([[0,0,0]], [1]) + assert projected_state == QuantumState([[0,0,0]], [-1]) def test_project_state_onto_subspace_before_operator(): CS = ContextualSubspace(H_taper, noncontextual_strategy='StabilizeFirst') From 4c877cc100b49585fcd1e1d5bff02ee2157a79f1 Mon Sep 17 00:00:00 2001 From: TimWeaving Date: Tue, 28 Nov 2023 14:56:44 +0000 Subject: [PATCH 3/4] Renamed S3_projection -> S3Projection --- symmer/projection/__init__.py | 2 +- symmer/projection/base.py | 2 +- symmer/projection/contextual_subspace.py | 8 ++++---- symmer/projection/qubit_tapering.py | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/symmer/projection/__init__.py b/symmer/projection/__init__.py index 1790f83f..edac9846 100644 --- a/symmer/projection/__init__.py +++ b/symmer/projection/__init__.py @@ -1,6 +1,6 @@ """init for projection.""" from .utils import * -from .base import S3_projection +from .base import S3Projection from .qubit_tapering import QubitTapering from .contextual_subspace import ContextualSubspace from .qubit_subspace_manager import QubitSubspaceManager \ No newline at end of file diff --git a/symmer/projection/base.py b/symmer/projection/base.py index f0943337..3a7bdc05 100644 --- a/symmer/projection/base.py +++ b/symmer/projection/base.py @@ -4,7 +4,7 @@ from symmer.evolution import trotter, Had from functools import reduce -class S3_projection: +class S3Projection: """ Base class for enabling qubit reduction techniques derived from the Stabilizer SubSpace (S3) projection framework, such as tapering diff --git a/symmer/projection/contextual_subspace.py b/symmer/projection/contextual_subspace.py index f191cc82..51f9733f 100644 --- a/symmer/projection/contextual_subspace.py +++ b/symmer/projection/contextual_subspace.py @@ -4,11 +4,11 @@ update_eigenvalues, StabilizerIdentification, ObservableBiasing, stabilizer_walk, # get_noncon_generators_from_commuting_stabilizers ) -from symmer.projection import S3_projection +from symmer.projection import S3Projection from symmer.evolution import trotter from typing import List, Union, Optional -class ContextualSubspace(S3_projection): +class ContextualSubspace(S3Projection): """ Class for performing contextual subspace methods as per https://quantum-journal.org/papers/q-2021-05-14-456/. Reduces the number of qubits in the problem while aiming to control the systematic error incurred along the way. @@ -21,7 +21,7 @@ class ContextualSubspace(S3_projection): NOTE: the order in which (1) and (2) are performed depends on the noncontextual strategy specified 3. Apply unitary partitioning (either sequence of rotations or linear combination of unitaries) to collapse noncontextual cliques - The remaining steps are handled by the parent S3_projection class: + The remaining steps are handled by the parent S3Projection class: 4. rotate each stabilizer onto a single-qubit Pauli operator, 5. drop the corresponding qubits from the Hamiltonian whilst 6. fixing the +/-1 eigenvalues @@ -320,7 +320,7 @@ def project_onto_subspace(self, operator_to_project:PauliwordOp=None) -> Pauliwo # if there are no stabilizers, return the input operator if self.stabilizers is None: return operator_to_project - # instantiate the parent S3_projection class that handles the subspace projection + # instantiate the parent S3Projection class that handles the subspace projection super().__init__(self.stabilizers) self.S3_initialized = True # perform unitary partitioning diff --git a/symmer/projection/qubit_tapering.py b/symmer/projection/qubit_tapering.py index 011dfd40..f6e68da8 100644 --- a/symmer/projection/qubit_tapering.py +++ b/symmer/projection/qubit_tapering.py @@ -3,10 +3,10 @@ import numpy as np from typing import List, Union from cached_property import cached_property -from symmer.projection import S3_projection +from symmer.projection import S3Projection from symmer.operators import PauliwordOp, IndependentOp, QuantumState -class QubitTapering(S3_projection): +class QubitTapering(S3Projection): """ Class for performing qubit tapering as per https://arxiv.org/abs/1701.08213. Reduces the number of qubits in the problem whilst preserving its energy spectrum by: @@ -17,7 +17,7 @@ class QubitTapering(S3_projection): 4. dropping the corresponding qubits from the Hamiltonian whilst 5. fixing the +/-1 eigenvalues - Steps 1-2 are handled in this class whereas we defer to the parent S3_projection for 3-5. + Steps 1-2 are handled in this class whereas we defer to the parent S3Projection for 3-5. """ def __init__(self, operator: PauliwordOp, @@ -57,7 +57,7 @@ def taper_it(self, """ Finally, once the symmetry generators and sector have been identified, we may perform a projection onto the corresponding stabilizer subspace via - the parent S3_projection class. + the parent S3Projection class. This method allows one to input an auxiliary operator other than the internal operator itself to be tapered consistently with the identified symmetry. This is @@ -90,7 +90,7 @@ def taper_it(self, else: operator_to_taper = self.operator.copy() - # taper the operator via S3_projection.perform_projection + # taper the operator via S3Projection.perform_projection tapered_operator = self.perform_projection( operator=operator_to_taper, ref_state=ref_state, From 39570b20256f6441953475399243280a8bd371fb Mon Sep 17 00:00:00 2001 From: TimWeaving Date: Tue, 28 Nov 2023 14:58:22 +0000 Subject: [PATCH 4/4] Added name attribute to subspace classes for reference --- symmer/projection/contextual_subspace.py | 2 ++ symmer/projection/qubit_tapering.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/symmer/projection/contextual_subspace.py b/symmer/projection/contextual_subspace.py index 51f9733f..2ae82900 100644 --- a/symmer/projection/contextual_subspace.py +++ b/symmer/projection/contextual_subspace.py @@ -26,6 +26,8 @@ class ContextualSubspace(S3Projection): 5. drop the corresponding qubits from the Hamiltonian whilst 6. fixing the +/-1 eigenvalues """ + name = 'contextual_subspace' # for reference in QubitSubspaceManager + def __init__(self, operator: PauliwordOp, noncontextual_strategy: str = 'diag', diff --git a/symmer/projection/qubit_tapering.py b/symmer/projection/qubit_tapering.py index f6e68da8..45e645fa 100644 --- a/symmer/projection/qubit_tapering.py +++ b/symmer/projection/qubit_tapering.py @@ -19,6 +19,8 @@ class QubitTapering(S3Projection): Steps 1-2 are handled in this class whereas we defer to the parent S3Projection for 3-5. """ + name = 'qubit_tapering' # for reference in QubitSubspaceManager + def __init__(self, operator: PauliwordOp, target_sqp: str = 'Z'