mitiq icon indicating copy to clipboard operation
mitiq copied to clipboard

reset operator needed

Open Muzhou-Ma opened this issue 1 year ago • 8 comments

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

Muzhou-Ma avatar Oct 05 '23 10:10 Muzhou-Ma

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.

github-actions[bot] avatar Oct 05 '23 10:10 github-actions[bot]

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

purva-thakre avatar Oct 05 '23 14:10 purva-thakre

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.

Misty-W avatar Oct 05 '23 19:10 Misty-W

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

To close this issue,

  • [x] Figure out if QASM Converter in Cirq has the ability to handle the conversion with a reset gate in the circuit.
  • [x] Figure out if all allowed circuit representations in Mitiq have a reset gate.
  • [x] 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)

purva-thakre avatar Oct 18 '23 00:10 purva-thakre

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 avatar Dec 01 '23 16:12 andreamari

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 avatar Dec 08 '23 16:12 andreamari

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 https://github.com/unitaryfund/mitiq/blob/ec3feb69133d4353e0f58cbdbce79ca8e408511e/mitiq/zne/scaling/folding.py#L58 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.

andreamari avatar Dec 08 '23 16:12 andreamari

With https://github.com/unitaryfund/mitiq/pull/2128, PEC should become fully compatible with Cirq circuits containing reset gates. This is just a small step towards full support of Reset gates.

andreamari avatar Dec 15 '23 17:12 andreamari