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

Error mitigation functions taking batches of circuits #2656

Open
cosenal opened this issue Feb 3, 2025 · 0 comments
Open

Error mitigation functions taking batches of circuits #2656

cosenal opened this issue Feb 3, 2025 · 0 comments
Labels
feature-request A request for a feature, tool, or workflow in Mitiq. needs/agreed-design Needs a plan of action that is agreed upon to complete.

Comments

@cosenal
Copy link
Contributor

cosenal commented Feb 3, 2025

Issue Description

At the moment, Mitiq's users can apply error mitigation functions only to a single circuit, e.g., zne.execute_with_zne(circuit: QPROGRAM, ...).

Proposed Solution

The proposal here is to allow users to apply error mitigation functions to a list of circuits instead, e.g.,

zne.execute_with_zne([circuit1, circuit2, ..., circuit_n]: list[QPROGRAM], ...)`.

The idea is that such a function would return n expectation values (one for each of the input circuits), each estimated with the QEM technique at hand (zne in the example.)

Why?

How is it different from running

expectation_values: list[float] = [zne.execute_with_zne(circuit, ...) for circuit in [circuit1, circuit2, ..., circuit_n]]

The idea is to modify how those functions work under the hood, so that the intermediate circuits coming from all the qem execution calls of the circuits are batched together, and are sent as a batch to the executor (and eventually to the backend). This will improve the time of dispatching and executing jobs for those backend devices that support batch jobs.

Example

Let's consider the simplest non-trivial case of running ZNE on two circuits circuit1, circuit2 with a scale factor of $2$, and let's see what would happen under the hood when running zne.execute_with_zne([circuit1, circuit2], ...) after this feature is implemented.
Let's say circuit1_a, circuit1_b and circuit2_a, circuit2_b are the intermediate circuits that are generated by ZNE.
Then the full batch of 4 circuits [circuit1_a, circuit1_b, circuit2_a, circuit2_b] is sent to the backend, and the results are mapped back to the extrapolation functions in order to produce 2 expectation values. This is beneficial since most of the backends can optimize batch execution of circuits.

Note

Mitiq already supports batch execution of the intermediate circuits generated by error mitigation of a single circuits, see https://mitiq.readthedocs.io/en/stable/guide/executors.html#batched-execution (mind the difference with what this feature request is about.)

Additional References

Discord thread with Sanket at https://discord.com/channels/764231928676089909/1331001652928446665
Old discussion (with @andreamari) on the topic: #1460

@cosenal cosenal added feature-request A request for a feature, tool, or workflow in Mitiq. needs/agreed-design Needs a plan of action that is agreed upon to complete. labels Feb 3, 2025
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. needs/agreed-design Needs a plan of action that is agreed upon to complete.
Projects
None yet
Development

No branches or pull requests

1 participant