forked from Qiskit/qiskit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
163 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
releasenotes/notes/pauli-apply-layout-cdcbc1bce724a150.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
features_quantum_info: | ||
- | | ||
Added a new :meth:`~.Pauli.apply_layout` method that is equivalent to | ||
:meth:`~.SparsePauliOp.apply_layout`. This method is used to apply | ||
a :class:`~.TranspileLayout` layout from the transpiler to a :class:~.Pauli` | ||
observable that was built for an input circuit. This enables working with | ||
:class:`~.BaseEstimator` / :class:`~.BaseEstimatorV2` implementations and | ||
local transpilation when the input is of type :class:`~.Pauli`. For example:: | ||
from qiskit.circuit.library import RealAmplitudes | ||
from qiskit.primitives import BackendEstimatorV2 | ||
from qiskit.providers.fake_provider import GenericBackendV2 | ||
from qiskit.quantum_info import Pauli | ||
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager | ||
psi = RealAmplitudes(num_qubits=2, reps=2) | ||
H1 = Pauli("XI") | ||
backend = GenericBackendV2(num_qubits=7) | ||
estimator = BackendEstimatorV2(backend=backend) | ||
thetas = [0, 1, 1, 2, 3, 5] | ||
pm = generate_preset_pass_manager(optimization_level=3, backend=backend) | ||
transpiled_psi = pm.run(psi) | ||
permuted_op = H1.apply_layout(transpiled_psi.layout) | ||
res = estimator.run([(transpiled_psi, permuted_op, thetas)]).result() | ||
where an input circuit is transpiled locally before it's passed to | ||
:class:`~.BaseEstimator.run`. Transpilation expands the original | ||
circuit from 2 to 7 qubits (the size of ``backend``) and permutes its layout, | ||
which is then applied to ``H1`` using :meth:`~.Pauli.apply_layout` | ||
to reflect the transformations performed by ``pm.run()``. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters