unitaryfund / mitiq

Mitiq is an open source toolkit for implementing error mitigation techniques on most current intermediate-scale quantum computers.
https://mitiq.readthedocs.io
GNU General Public License v3.0
358 stars 157 forks source link

Add IonQ native gates #1500

Closed yitchen-tim closed 1 year ago

yitchen-tim commented 1 year ago

Issue Description

Amazon Braket now supports verbatim compilation now for IonQ. But when I tired to run this example with verbatim compilation and native gates, I got the validation error that the gate does not exist.

ValueError: Unable to convert the instruction Instruction('operator': GPi('angle': 0.0, 'qubit_count': 1), 'target': QubitSet([Qubit(0)])) to Cirq. If you think this is a bug, you can open an issue on the Mitiq GitHub at https://github.com/unitaryfund/mitiq.

Proposed Solution

Add IonQ native gates, GPi, GPi2 and MS, as part of the supported gates of Mitiq.

Additional References

Amazon Braket's Developer Guide IonQ's doc

github-actions[bot] commented 1 year ago

Hello @yitchen-tim, 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.

andreamari commented 1 year ago

Hi @yitchen-tim, thanks for reporting this! Mitiq doesn't support GPi gates and many other platform-specific gates. I think there are two alternative paths that you could try:

yitchen-tim commented 1 year ago

Thanks for the pointers to alternatives. Adding compilation as the final step of execute function sounds like the best way for those who want to use Mitiq with IonQ native gates today. But, for long term, I feel like adding native gates is still the best solution. I am happy to contribute to add the gates. I already started to do so, but I ran into issue that the inverse of IonQ native gates are not implemented in Cirq. I am looking into how to solve this. Any idea how I can bypass this issue besides implementing the inverse method in Cirq?

andreamari commented 1 year ago

Thanks for the pointers to alternatives. Adding compilation as the final step of execute function sounds like the best way for those who want to use Mitiq with IonQ native gates today. But, for long term, I feel like adding native gates is still the best solution. I am happy to contribute to add the gates.

That would be great, thanks!

I already started to do so, but I ran into issue that the inverse of IonQ native gates are not implemented in Cirq. I am looking into how to solve this. Any idea how I can bypass this issue besides implementing the inverse method in Cirq?

I fear that defining the inverse is necessary since in Mitiq we need to call the inverse method of Cirq gates. E.g. all unitary folding functions in Mitiq requires the evaluation of inverse gates.

yitchen-tim commented 1 year ago

Opened a PR in Cirq to implement the inverse of these gates. Once Cirq is updated, I will implement the Braket-Cirq translation in Mitiq.

andreamari commented 1 year ago

Perfect! thanks @yitchen-tim

yitchen-tim commented 1 year ago

@andreamari The PR for gate conversion is out #1525 !

andreamari commented 1 year ago

This issue was actually closed by #1525