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 Clifford.to_circuit and Clifford.copy methods + initialization via circuits #1139

Merged
merged 29 commits into from
Jan 10, 2024

Conversation

renatomello
Copy link
Contributor

@renatomello renatomello commented Dec 18, 2023

Checklist:

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

@renatomello renatomello added documentation Improvements or additions to documentation enhancement New feature or request labels Dec 18, 2023
@renatomello renatomello added this to the Qibo 0.2.4 milestone Dec 18, 2023
@renatomello renatomello self-assigned this Dec 18, 2023
Copy link

codecov bot commented Dec 18, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (0eeb6ae) 100.00% compared to head (6844488) 100.00%.
Report is 6 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##            master     #1139    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           67        68     +1     
  Lines         9588      9764   +176     
==========================================
+ Hits          9588      9764   +176     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@renatomello renatomello marked this pull request as draft December 18, 2023 09:12
@renatomello renatomello changed the title Add Clifford.copy method and initialization via circuits Add Clifford.to_circuit and Clifford.copy methods + initialization via circuits Dec 19, 2023
@renatomello renatomello marked this pull request as ready for review December 19, 2023 05:44
@renatomello
Copy link
Contributor Author

@BrunoLiegiBastonLiegi @AlejandroSopena this should be ready for review (with some urgency) after passing tests

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 @renatomello I just finished giving this a first look and it's looking good. I have got just a couple of general comments.
The first one regards the ability to pass a circuit directly to the Clifford object constructor. From my perspective this is somewhat redundant as you can already do that with Clifford.from_circuit() and it's not really adding any additional functionality.
Secondly I wonder whether many of the clifford_utils functions should be moved to the CliffordBackend object. They are extensively making use of the backend through the Clifford object already, at this point they should probably just be part of it and called at need inside of the Clifford.
Finally, why do you need to store the circuit inside of the Clifford object? In general I would like to keep it as light as possible, keeping in mind that at some point we might want to create an abstract Result object from which both this Clifford, the QuantumState, MeasurementOutcomes, CircuitResult and all the possible future outcomes object inherit from.

@renatomello
Copy link
Contributor Author

Thanks @renatomello I just finished giving this a first look and it's looking good. I have got just a couple of general comments. The first one regards the ability to pass a circuit directly to the Clifford object constructor. From my perspective this is somewhat redundant as you can already do that with Clifford.from_circuit() and it's not really adding any additional functionality.

Redundancy is not necessarily a bad thing. For instance, we have Clifford.from_circuit(circuit) and CliffordBackend.execute_circuit(circuit). The question is what level of redundancy is acceptable and desirable. And to this point, I insist that Clifford(circuit) is the right level of redundancy and adds to UX. In my opinion, Clifford(circuit) is the most natural way of executing a circuit with the Clifford backend from a user's perspective. Moreover, other libraries, e.g. qiskit support this type of initialization, so it's also natural that users will expect us to support the same thing.

Secondly I wonder whether many of the clifford_utils functions should be moved to the CliffordBackend object. They are extensively making use of the backend through the Clifford object already, at this point they should probably just be part of it and called at need inside of the Clifford.

I have no objection to this. However, this sounds like a different PR.

Finally, why do you need to store the circuit inside of the Clifford object? In general I would like to keep it as light as possible, keeping in mind that at some point we might want to create an abstract Result object from which both this Clifford, the QuantumState, MeasurementOutcomes, CircuitResult and all the possible future outcomes object inherit from.

You are right that it can be memory intensive to store the circuit.queue in the Clifford object. I will roll that back.

Copy link
Contributor

@AlejandroSopena AlejandroSopena left a comment

Choose a reason for hiding this comment

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

Thanks @renatomello, everything looks good. I agree with @BrunoLiegiBastonLiegi 's comment to move some clifford_utils functions to the CliffordBackend.

src/qibo/quantum_info/_clifford_utils.py Outdated Show resolved Hide resolved
Co-authored-by: Alejandro Sopena <44305203+AlejandroSopena@users.noreply.github.com>
@MatteoRobbiati MatteoRobbiati added this pull request to the merge queue Jan 10, 2024
Merged via the queue into master with commit 2b7e4d8 Jan 10, 2024
21 checks passed
@renatomello renatomello deleted the to_circuit branch January 10, 2024 09:39
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