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

Support observable=None in Quantum Subspace Expansion (QSE) #1813

Open
andreamari opened this issue Apr 28, 2023 · 7 comments
Open

Support observable=None in Quantum Subspace Expansion (QSE) #1813

andreamari opened this issue Apr 28, 2023 · 7 comments
Assignees
Labels
feature-request A request for a feature, tool, or workflow in Mitiq. qse Quantum Subspace Expansion unitaryhack-bounty

Comments

@andreamari
Copy link
Member

andreamari commented Apr 28, 2023

This is an optional improvement to QSE:

  • support observabe=None by appending Paulis to circuits instead of absorbing them into the Observable object.

This is useful to apply QSE when the executor defined by the user returns an expectation value as float instead of bitstrings (MeasurementResult).

This is a sub-issue of #818

Useful links:
Mitiq documentation: https://mitiq.readthedocs.io/en/stable/guide/qse.html
Quantum Subspace Expansion paper: https://arxiv.org/pdf/1903.05786.pdf

@andreamari andreamari added feature-request A request for a feature, tool, or workflow in Mitiq. qse Quantum Subspace Expansion labels Apr 28, 2023
@FarLab FarLab self-assigned this Apr 5, 2024
@FarLab FarLab added this to the v0.36.0 milestone Apr 11, 2024
@FarLab
Copy link
Contributor

FarLab commented Apr 19, 2024

Regarding the adding observable=None in the QSE, I thought the approach would be as follows.

In this case, the executor returns a float (so it already returns some expectation value). In QSE, you solve a minimization problem for a projector $P_c = \sum_i c_i M_i$ where $M_i$ are check operators and $c_i$ are real numbers subject to some constraints. The QSE mitigated value is then $Tr(P_c \rho P_c^* O)$ where $O$ is some observable. Since the executor already returns the expectation value of $O$ given a state $\rho$, we have to modify the state (when observable is not None, you change the observable argument in the executor to $P_c^* O P_c$ as is done right now).

Write $\rho = \ket{\psi}\bra{\psi}$. Given the $c_i$ and $M_i$, we just compute the state $M_i\ket{\psi}$ and pass it to the executor that returns, say, $E_i$. We do this for each $i$ and the QSE mitigated value in this case would be $\sum_i c_i E_i$.

Does this make sense? @natestemen

@FarLab
Copy link
Contributor

FarLab commented Apr 21, 2024

The above approach looks to be incorrect, because $Tr(P_c\rho P_c^\dagger O) = \sum_{ij}c_ic_j^* Tr(M_i\rho M_j^\dagger O)$. So we need to compute for each $i,j$ the value $Tr(M_i\rho M_j^\dagger O)$.

@FarLab
Copy link
Contributor

FarLab commented Apr 29, 2024

Hi @bubakazouba, I know you have worked on implementing QSE in Mitiq and so I am curious about what you think about the above approach and if it makes sense at all. As QSE is implemented right now, you compute the expectation value $\langle P_cOP_c\rangle$ by passing it to the executor. However, if the executor doesn't accept an observable (because it already computes one) you need to pass a modified state to it, namely $P_c\rho P_c^*$. Since we want to pass a quantum circuit to the executor, one has to write this as a sum of pure states: $P_c\rho P_c^\dagger = \sum_ip_i\ket{\psi_i}\bra{\psi_i}$.
Once we have this expression, we pass the quantum circuits associated to $\ket{\psi_i}$ to the executor that returns the expectation value $Tr(\ket{\psi_i}\bra{\psi_i}O)$. The QSE mitigated value is then $\sum_i p_iTr(\ket{\psi_i}\bra{\psi_i}O)$.

I guess the hard part is obtaining the RHS of this expression $P_c\rho P_c^\dagger = \sum_ip_i\ket{\psi_i}\bra{\psi_i}$ in terms of the check operators $M_i$, $c_i$ and $\ket{\psi}$. Hope this makes sense.

@FarLab FarLab removed this from the v0.36.0 milestone Apr 30, 2024
@bubakazouba
Copy link
Contributor

hi @FarLab, sorry for the late reply. I haven't worked on this in a while so I can't remember all details of the implementation. But the general idea you wrote here makes sense. I'm not sure how you would obtain the projected state in terms of the $M_i$ operators.

@jordandsullivan jordandsullivan changed the title Support observable=None in QSE Support observable=None in Quantum Subspace Expansion (QSE) May 7, 2024
@Death0004
Copy link

Death0004 commented Jun 15, 2024

Based on this information, it seems like GSE resolves this issue and thus it might be easier to merge this feature request with the implementation of GSE...

Assuming that we want to compute the expectation value of some observable A, given by $Tr(P_c A P_c \rho) = Tr(A P_c \rho P_c)$, in the "power subspace" method of GSE we simply define the powers of a noisy state $\rho$ which eliminates the ambiguities surrounding what quantum state to pass. In GSE, the bases of the subspace are first restricted to powers of noisy quantum states $\rho^{(m)}$, and A is set to the identity matrix $I$.

According to the GSE paper, the most general subspace can then be implemented as
Screenshot 2024-06-15 at 00 46 04
where $β^{(i)}_k∈C$, and $U^{(i)}_k$, $V^{(i)}_k$ are general operators, and $\sigma_i$ is a basis element which spans the generalized subspace.

A basis element which spans the noisy subspace can then be constructed using these general operators, which can be used to construct the generalized subspace. The Ansatz for an error mitigated state is given in the form $\rho_{EM}$ by this equation:
Screenshot 2024-06-15 at 00 57 37
where $P=∑_i​α_i​σ_i$. To determine the coefficients $α_i$ we simply solve the generalized eigenvalue problem (just like in the current QSE implementation) and then compute the error-mitigated expectation value of any observable $O$ as:

$$⟨O⟩=∑_{ij}α^*_iα_jTr[σ^†_iAσ_jO]$$

Note how A is set to identity since the basis elements are powers of the noisy quantum state $\sigma_i = \rho^i$. This helps in exponentially suppressing stochastic errors and mitigating coherent errors, see paper for reference: https://arxiv.org/pdf/2107.02611

@jordandsullivan
Copy link
Contributor

And for reference, we already have an issue opened for Generalized Subspace Expansion: #2377.

@FarLab
Copy link
Contributor

FarLab commented Jun 24, 2024

Thanks @Death0004 for your comment. I need to read and and think in more detail about your approach, but I already have a few basic questions.

  1. You mention that you set $A$ to the identity matrix in the expression $$\langle O \rangle = \sum_{ij}\alpha_i^*\alpha_j Tr(\sigma_i^\dagger A\sigma_j O).$$
    What does the matrix $A$ represent actually?
  2. Assume $\rho = \ket{\psi}\bra{\psi}$ a pure state, then $\rho^i = \rho$ for any $i\geq 1$. If I understand correctly, assuming you know the constants $\alpha_i$ and setting $A=I$, we have $Tr(\sigma_i^\dagger A\sigma_j O) = Tr(\rho^{i \dagger} \rho^j O) = Tr(\rho O)$. This we can evaluate using an executor that returns a float/expectation value of $O$ given a pure state. But then the error-mitigated value is $\langle O \rangle = Tr(\rho O)\sum_{ij}\alpha_i^*\alpha_j$. Is this correct from your understanding of GSE?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A request for a feature, tool, or workflow in Mitiq. qse Quantum Subspace Expansion unitaryhack-bounty
Projects
None yet
Development

No branches or pull requests

6 participants