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

reset operator needed #2042

Open
Marsmmz opened this issue Oct 5, 2023 · 8 comments
Open

reset operator needed #2042

Marsmmz opened this issue Oct 5, 2023 · 8 comments
Assignees
Labels
feature-request A request for a feature, tool, or workflow in Mitiq.

Comments

@Marsmmz
Copy link

Marsmmz commented Oct 5, 2023

Issue Description

It would be really helpful if a "reset" operation could be supported by Mitiq which is corresponded to reset in Qiskit.

Additional References

@Marsmmz Marsmmz added the feature-request A request for a feature, tool, or workflow in Mitiq. label Oct 5, 2023
@github-actions
Copy link

github-actions bot commented Oct 5, 2023

Hello @Marsmmz, thank you for your interest in Mitiq!
If this is a bug report, please provide screenshots and/or minimum viable code to reproduce your issue, so we can do our best to help get it fixed. If you have any questions in the meantime, you can also ask us on the Unitary Fund Discord.

@purva-thakre
Copy link
Contributor

purva-thakre commented Oct 5, 2023

Hi @Marsmmz, thank you for opening this issue.

Mitiq uses a circuit converter to convert a Qiskit circuit to a Cirq circuit before implementing an error mitigation technique. When the first few error mitigation techniques were added, there was no Cirq equivalent to the Reset instruction in Qiskit.

It seems Cirq now has a reset gate (added 9 months ago). I think if all circuit representations allowed by mitiq have a reset gate equivalent, then adding this as a new feature will be a possibility.

Pinging others to correct me @andreamari @Misty-W @natestemen

@Misty-W
Copy link
Contributor

Misty-W commented Oct 5, 2023

Thanks @purva-thakre! In terms of conversions it should work, but we'd need to think carefully about how to handle reset gates in ZNE before introducing them into Mitiq.

@purva-thakre
Copy link
Contributor

purva-thakre commented Oct 18, 2023

Based on Andrea's comments from Oct 6 Community Call:

To close this issue,

  • Figure out if QASM Converter in Cirq has the ability to handle the conversion with a reset gate in the circuit.
  • Figure out if all allowed circuit representations in Mitiq have a reset gate.
  • If yes to both above, reset gate will be an exception to gate-level manipulations by mitiq techniques like unitary folding. (See comment about considering ZNE as an independent issue)
  • Will probably require an agreed-upon design to handle reset gates in ZNE (quoting Misty's comment above)

@natestemen natestemen added this to the 0.32.0 milestone Nov 10, 2023
@andreamari
Copy link
Member

about the first step: "Figure out if QASM Converter in Cirq has the ability to handle the conversion with a reset gate in the circuit."
The answer is no, the Reset gate is not supported by Cirq import function from QASM. See here for supported gates.

On the other hand, cirq has a Reset gate:

import cirq
from cirq.ops import reset

circuit = cirq.Circuit(reset(cirq.LineQubit(0)))
print(circuit)

0: ───R───

I'll investigate more on what we can do and I'll write any new update here.

@andreamari
Copy link
Member

About the sub-issue "Figure out if all allowed circuit representations in Mitiq have a reset gate:"

  • cirq, yes.
  • qiskit, yes.
  • pennylane, yes.
  • pyquil, yes.
  • braket, probably not. At least I couldn't find it.

I don't think it's a huge problems however. If you are using braket as a front end and you don't have reset gates you can still use mitiq as usual. So, all we need to do is supporting the reset gate only for the frontends in which it exist.

@andreamari
Copy link
Member

About the sub-issue " If yes to both above, reset gate will be an exception to gate-level manipulations by mitiq techniques like unitary folding."

Based on the current code, the user will get an error when trying to apply ZNE to a non-unitary circuit. This is due to the check_foldable function

def _check_foldable(circuit: Circuit) -> None:
which is called by noise scaling functions.

This is good since it avoids any unexpected behavior due to the potentially unintentional/unknown presence of reset gates somewhere in the circuit!

I think supporting a reset gate for ZNE is a further issue that could be considered as a second step. This is highly non-trivial.

As a first step we could focus on just supporting the reset gate for conversions: frontend->cirq->frontend.
If we have this, it should be easy to apply techniques like DDD, PEC, REM without too many further changes.

ZNE is a special case since it requires circuit inversions. So I would suggest to consider the potential support of ZNE + Reset as a different issue.

@natestemen natestemen removed this from the 0.32.0 milestone Dec 15, 2023
@andreamari
Copy link
Member

With #2128, PEC should become fully compatible with Cirq circuits containing reset gates.
This is just a small step towards full support of Reset gates.

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.
Projects
None yet
Development

No branches or pull requests

5 participants