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
344 stars 145 forks source link

Noise Scaling for LRE #2347

Closed purva-thakre closed 2 days ago

purva-thakre commented 2 months ago

Fixes #2307

Description


License

Before opening the PR, please ensure you have completed the following where appropriate.

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 98.34%. Comparing base (b58f029) to head (bfe07bd). Report is 34 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #2347 +/- ## ========================================== + Coverage 98.22% 98.34% +0.11% ========================================== Files 87 89 +2 Lines 4056 4105 +49 ========================================== + Hits 3984 4037 +53 + Misses 72 68 -4 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

purva-thakre commented 3 weeks ago

@cosenal @vprusso This is ready for a review up to using layerwise folding on cirq circuits.

I am working on figuring out why layerwise folding on a pyquil circuit raises errors. Once this is fixed, laywerise folding for non-cirq circuits will be added.

purva-thakre commented 1 week ago

I think it's better to limit this PR to Cirq circuits only because I need to spend some more time understanding how the Mitiq interface decorators work. I have used the default args for the decorators in the past without any issues. This PR requires using the optional arguments.

Two different ways to implement the optional args led to errors. Either the one_to_many argument was ignored (first code block) or _pop_measurement was used on a Qiskit circuit instead of converting the circuit to a cirq circuit first (second code block).

@accept_qprogram_and_validate
def multivariate_layer_scaling( input_circuit, degree, ............, one_to_many = True)

Similar to how the optional arg is used in PEC, I also tried changing multivariate_layer_scaling to _cirq_multivariate_layer_scaling such that the new multivariate_layer_scaling only accepted a QPROGRAM as input.

 noise_scaling_func = accept_qprogram_and_validate(
      _cirq_multivariate_layer_scaling,
      one_to_many=True,
  )
  scaled_circuits = noise_scaling_func(
      input_circuit, degree, fold_multiplier, num_chunks, folding_method
  )
 return scaled_circuits
jordandsullivan commented 1 week ago

Sounds good Purva, we can limit this PR for Cirq for now.

purva-thakre commented 1 week ago

Except for 1 unresolved comment https://github.com/unitaryfund/mitiq/pull/2347#discussion_r1633632306, this PR is ready for another review.

purva-thakre commented 4 days ago

This PR is ready to be merged once all checks pass.

As of 1:45 pm CST, not all checks are being run after I pushed the latest commit to this PR.

image

Looks like Github is aware of the issues and they are working on fixing it. https://www.githubstatus.com/

image