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
359 stars 157 forks source link

Add information about converting to and from non-Mitiq supported circuits #2409

Open purva-thakre opened 3 months ago

purva-thakre commented 3 months ago

Previously discussed here.

The Frontends section of the documentation only discusses circuits that have mitiq supported converters. Digging through the functions in mitiq/interface, there exists a function to let a user define a converter for an unsupported circuit as long as it follows the format defined in mitiq/typing.

https://github.com/unitaryfund/mitiq/blob/bf82e84410e1805437e15f1d26b0c5be8e8dcb8a/mitiq/interface/conversions.py#L37-L49

We want to describe this process in detail in a subsection of the Frontends portion of the documentation.

purva-thakre commented 3 months ago

Use this issue to also add functions to the API-doc. https://github.com/unitaryfund/mitiq/discussions/2408#discussioncomment-9776541

Not all functions in mitiq/interface/conversions will be used by a Mitiq user. Only add functions that will be required to register an interface not already in Mitiq.

For example, atomic_converter is more useful than accept_qprogram_and_validate

image

https://mitiq.readthedocs.io/en/stable/guide/zne-4-low-level.html#custom-noise-scaling-methods

purva-thakre commented 3 months ago

I do not think the register_mitiq_converters function is compatible with how we define SUPPORTED_PROGRAM_TYPES currently. So, this issue might also require a refactor of register_mitiq_converters.

The non-mitiq compatible frontend is utilized as a dictionary by register_mitiq_converters.

https://github.com/unitaryfund/mitiq/blob/20732a0d0f8174c311d90dfa6f94e196051cc7e4/mitiq/interface/conversions.py#L24 https://github.com/unitaryfund/mitiq/blob/20732a0d0f8174c311d90dfa6f94e196051cc7e4/mitiq/interface/conversions.py#L30

SUPPORTED_PROGRAM_TYPES is a class now and the older definition used a dictionary. I think register_mitiq_converters is based off of this previous version of SUPPORTED_PROGRAM_TYPES.

https://github.com/unitaryfund/mitiq/blob/20732a0d0f8174c311d90dfa6f94e196051cc7e4/mitiq/typing.py#L44-L45