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 "mitiq.raw.execute"? #1006

Closed
rmlarose opened this issue Oct 29, 2021 · 2 comments · Fixed by #1047
Closed

Add "mitiq.raw.execute"? #1006

rmlarose opened this issue Oct 29, 2021 · 2 comments · Fixed by #1047
Labels
documentation Improvements or additions to documentation needs/agreed-design Needs a plan of action that is agreed upon to complete. priority/low A non-urgent issue to fix or idea to discuss.

Comments

@rmlarose
Copy link
Contributor

Without an observable, the canonical way to compute "raw results" (i.e., results without error mitigation) is execute(circuit).

However, with an observable, the interface is different:

  • Without error mitigation: Either Executor.evaluate(circuit, observable) or observable.expectation(circuit, executor).
  • With error mitigation: execute_with_xxx(circuit, executor, observable).

Should we (i) support a common interface? and (ii) do this by adding a "raw" module which does not do any error mitigation but exists solely for the purpose of having a common interface?

Pros

It would be really useful for documentation and examples. For example:

import cirq

from mitiq import Executor, Observable, PauliString, zne, raw
from mitiq.interface import mitiq_cirq

circuit = cirq.Circuit(cirq.H.on(cirq.LineQubit(0)) for _ in range(10))
executor = Executor(mitiq_cirq.compute_density_matrix)
observable = Observable(PauliString("Z"))
print(f"Problem: ⟨𝜓| {observable} |𝜓⟩ where |𝜓⟩ is given by", circuit, sep="\n\n")

# Without error mitigation.
raw_result = raw.execute(circuit, executor, observable)
print("\nRaw result:", raw_result)
print("Executed circuits:", *executor.executed_circuits, sep="\n")

# With error mitigation.
zne_result = zne.execute_with_zne(circuit, executor, observable)
print("\nZNE result:", zne_result)
print("Executed circuits:", *executor.executed_circuits[1:], sep="\n")
Problem: ⟨𝜓| Z(0) |𝜓⟩ where |𝜓⟩ is given by

0: ───H───H───H───H───H───H───H───H───H───H───

Raw result: 0.95
Executed circuits:
0: ───H───H───H───H───H───H───H───H───H───H───

ZNE result: 0.99
Executed circuits:
0: ───H───H───H───H───H───H───H───H───H───H───
0: ───H───H───H───H───H───H───H───H───H───H───H───H───H───H───H───H───H───H───H───H───
0: ───H───H───H───H───H───H───H───H───H───H───H───H───H───H───H───H───H───H───H───H───H───H───H───H───H───H───H───H───H───H───

Cons

It doesn't really have a use beyond documentation. One may misinterpret mitiq.raw to do error mitigation.

@rmlarose rmlarose added discuss@mitiq-meeting documentation Improvements or additions to documentation needs/agreed-design Needs a plan of action that is agreed upon to complete. priority/low A non-urgent issue to fix or idea to discuss. labels Oct 29, 2021
@rmlarose
Copy link
Contributor Author

From Mitiq meeting: Should it be a module or just a function?

@github-actions
Copy link

This issue had no activity for 2 months, and will be closed in one week unless there is new activity. Cheers!

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 needs/agreed-design Needs a plan of action that is agreed upon to complete. priority/low A non-urgent issue to fix or idea to discuss.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants