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.
Add base representation of
SparseObservable
This adds the base representation of `SparseObservable`, including the simple constructors from Python space and the ability to view the data buffers. This commit does not include the mathematical manipulations of the operators, nor some of the helper methods that will be used to manipulate the operators in the context of primitives execution. These will follow in subsequent patches. The design and implementation notes of `SparseObservable` are described in a Qiskit RFC that preceeded this patch series[^1], and it's best to consult that document for full details on the operator considerations. [^1]: https://github.com/Qiskit/RFCs/blob/7a74b08793475b7b0142d3a3f7142cabcfd33ab8/0021-sparse-observable.md
- Loading branch information
1 parent
9778462
commit 641d87f
Showing
10 changed files
with
2,641 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
32 changes: 32 additions & 0 deletions
32
releasenotes/notes/sparse-observable-7de70dcdf6962a64.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,32 @@ | ||
--- | ||
features_quantum_info: | ||
- | | ||
A new observable class has been added. :class:`.SparseObservable` represents observables as a | ||
sum of terms, similar to :class:`.SparsePauliOp`, but with two core differences: | ||
1. Each complete term is stored as (effectively) a series of ``(qubit, bit_term)`` pairs, | ||
without storing qubits that undergo the identity for that term. This significantly improves | ||
the memory usage of observables such as the weighted sum of Paulis :math:`\sum_i c_i Z_i`. | ||
2. The single-qubit term alphabet is overcomplete for the operator space; it can represent Pauli | ||
operators (like :class:`.SparsePauliOp`), but also projectors onto the eigenstates of the | ||
Pauli operators, like :math:`\lvert 0\rangle\langle 0\rangle`. Such projectors can be | ||
measured on hardware equally as efficiently as their corresponding Pauli operator, but | ||
:class:`.SparsePauliOp` would require an exponential number of terms to represent | ||
:math:`{\lvert0\rangle\langle0\rvert}^{\otimes n}` over :math:`n` qubits, while | ||
:class:`.SparseObservable` needs only a single term. | ||
You can construct and manipulate :class:`.SparseObservable` using an interface familiar to users | ||
of :class:`.SparsePauliOp`:: | ||
from qiskit.quantum_info import SparseObservable | ||
obs = SparseObservable.from_sparse_list([ | ||
("XZY", (2, 1, 0), 1.5j), | ||
("+-", (100, 99), 0.5j), | ||
("01", (50, 49), 0.5), | ||
]) | ||
:class:`.SparseObservable` is not currently supported as an input format to the primitives | ||
(:mod:`qiskit.primitives`), but we expect to expand these interfaces to include them in the | ||
future. |
Oops, something went wrong.