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

Quantum Error Mitigation: Readout, Importance Clifford Sampling #1129

Merged
merged 55 commits into from
Jan 12, 2024

Conversation

AlejandroSopena
Copy link
Contributor

@AlejandroSopena AlejandroSopena commented Dec 11, 2023

General improvement of the code and docstrings.

This PR implements Iterative Bayesian Unfolding to avoid quasiprobabilities when using readout mitigation with the response matrix. It also implements the Importance Clifford Sampling method.

Checklist:

  • Reviewers confirm new code works as expected.
  • Tests are passing.
  • Coverage does not decrease.
  • Documentation is updated.

@renatomello
Copy link
Contributor

@AlejandroSopena maybe this is for a different PR, but we should aim to integrate these Clifford-based methods (e.g. ICS, CDR) with the new Clifford backend from @BrunoLiegiBastonLiegi as much as it is possible / worth it.

Copy link
Contributor

@MatteoRobbiati MatteoRobbiati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @AlejandroSopena for all these modifications and for the big refactoring of the mitigation module.

My only doubt here is about the usage of the apply_readout_mitigation. I agree with your choice, it lighten the code a lot and it is flexible enough to apply the desired readout mit technique, but I find it ambiguous when a mitigation method (e.g. CDR) is applied without applying readout mitigation, because still relying on apply_readout_mitigation.

What about renaming the apply_readout_mitigation function into something more generic like: apply_problem_configuration? Alternatively, we can make the two things explicit in a longer but clearer name: apply_problem_with_readout_conf.

A couple of minor comments follow.


Args:
circuit (qibo.models.Circuit): input circuit.
qubit_map (list): the qubit map. If ``None``, a list of range of circuit's qubits is used. Defaults to ``None``.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with keeping this qubit_map for now. I We also close to the #1121, so I think we can then exploit that new feature to fix the circuit on a given topology.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to adapt the "manual" transpilation process we use in RTQEM but using the qibo transpiler. Depending on what is missing in #1121, we can merge this and then open a small pull request, or wait.

src/qibo/models/error_mitigation.py Outdated Show resolved Hide resolved
@AlejandroSopena
Copy link
Contributor Author

Thanks a lot @AlejandroSopena for all these modifications and for the big refactoring of the mitigation module.

My only doubt here is about the usage of the apply_readout_mitigation. I agree with your choice, it lighten the code a lot and it is flexible enough to apply the desired readout mit technique, but I find it ambiguous when a mitigation method (e.g. CDR) is applied without applying readout mitigation, because still relying on apply_readout_mitigation.

What about renaming the apply_readout_mitigation function into something more generic like: apply_problem_configuration? Alternatively, we can make the two things explicit in a longer but clearer name: apply_problem_with_readout_conf.

A couple of minor comments follow.

I agree. I have changed it to apply_problem_with_readout_conf().

@AlejandroSopena
Copy link
Contributor Author

@AlejandroSopena maybe this is for a different PR, but we should aim to integrate these Clifford-based methods (e.g. ICS, CDR) with the new Clifford backend from @BrunoLiegiBastonLiegi as much as it is possible / worth it.

Yes, I agree @renatomello . I think we can implement this in a new PR because it only involves an improvement when running the training circuits but not the final result (although a very useful improvement).

@MatteoRobbiati MatteoRobbiati self-requested a review January 9, 2024 09:10
Copy link
Contributor

@BrunoLiegiBastonLiegi BrunoLiegiBastonLiegi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @AlejandroSopena, it looks good. I made some minor comments and in general I am not a huge fan of the two names of the functions _circuit_conf and apply_problem_with_readout_conf. I would probably prefer something like _execute_circuit and _get_expectation_val_with_readout_mitigation.

src/qibo/models/error_mitigation.py Outdated Show resolved Hide resolved
src/qibo/models/error_mitigation.py Outdated Show resolved Hide resolved
src/qibo/models/error_mitigation.py Outdated Show resolved Hide resolved
Comment on lines 675 to 689
if "ncircuits" in readout:
circuit_result, circuit_result_cal = apply_randomized_readout_mitigation(
circuit, noise_model, nshots, readout["ncircuits"], backend
)
else:
circuit_result = _circuit_conf(
circuit, qubit_map, noise_model, nshots, backend=backend
)

if "response_matrix" in readout:
circuit_result = apply_resp_mat_readout_mitigation(
circuit_result,
readout["response_matrix"],
readout.get("ibu_iters", None),
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, in principle one can consecutively apply randomized_readout and resp_mat_readout, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, one or the other. I have updated the code.

src/qibo/models/error_mitigation.py Outdated Show resolved Hide resolved
src/qibo/models/error_mitigation.py Outdated Show resolved Hide resolved
src/qibo/models/error_mitigation.py Show resolved Hide resolved
Copy link
Contributor

@MatteoRobbiati MatteoRobbiati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
A couple of comments and some minor suggestions follow.

src/qibo/models/error_mitigation.py Outdated Show resolved Hide resolved
src/qibo/models/error_mitigation.py Outdated Show resolved Hide resolved
src/qibo/models/error_mitigation.py Outdated Show resolved Hide resolved
src/qibo/models/error_mitigation.py Outdated Show resolved Hide resolved
src/qibo/models/error_mitigation.py Outdated Show resolved Hide resolved
src/qibo/models/error_mitigation.py Outdated Show resolved Hide resolved
@AlejandroSopena AlejandroSopena added this pull request to the merge queue Jan 12, 2024
Merged via the queue into master with commit 3a3dfaa Jan 12, 2024
21 checks passed
@scarrazza scarrazza deleted the cdr branch January 12, 2024 11:51
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 enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants