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

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

Open
purva-thakre opened this issue Jun 14, 2024 · 2 comments
Labels
documentation Improvements or additions to documentation feature-request A request for a feature, tool, or workflow in Mitiq.

Comments

@purva-thakre
Copy link
Contributor

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.

def register_mitiq_converters(
package_name: str,
*,
convert_to_function: Callable[[cirq.Circuit], Any],
convert_from_function: Callable[[Any], cirq.Circuit],
) -> None:
"""Registers converters for unsupported circuit types.
Args:
package_name: A quantum circuit module name that is not currently
supported by Mitiq. Note: this name should be the same as the
return from "circuit".__module__.
See mitiq.SUPPORTED_PROGRAM_TYPES.

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

@purva-thakre purva-thakre added documentation Improvements or additions to documentation feature-request A request for a feature, tool, or workflow in Mitiq. labels Jun 14, 2024
@purva-thakre
Copy link
Contributor Author

purva-thakre commented Jun 20, 2024

Use this issue to also add functions to the API-doc. #2408 (reply in thread)

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
Copy link
Contributor Author

purva-thakre commented Jun 26, 2024

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.

FROM_MITIQ_DICT: Dict[str, Callable[[cirq.Circuit], Any]]

TO_MITIQ_DICT: Dict[str, Callable[[Any], cirq.Circuit]]

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.

mitiq/mitiq/typing.py

Lines 44 to 45 in 20732a0

# This is for backwards compatibility with the old representation
# of SUPPORTED_PROGRAM_TYPES, which was a dictionary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation feature-request A request for a feature, tool, or workflow in Mitiq.
Projects
None yet
Development

No branches or pull requests

1 participant