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

Simplified _Queue append #1255

Merged
merged 6 commits into from
Mar 11, 2024
Merged

Simplified _Queue append #1255

merged 6 commits into from
Mar 11, 2024

Conversation

BrunoLiegiBastonLiegi
Copy link
Contributor

@BrunoLiegiBastonLiegi BrunoLiegiBastonLiegi commented Mar 8, 2024

This PR removes the qibo.models.Circuit._Queue.append() method that was overloading the list.append(). The generation of the moments and the calculation of the number of measurements in the circuit is therefore delayed to when it's actually needed. This was mainly motivated by the random_clifford function that appends a lot of gates to the circuit, but I believe it is in general useful for speeding up all the functions that make heavily use of the Circuit.add() method, even though the difference in most cases is probably negligible.

Checklist:

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

Copy link

codecov bot commented Mar 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.95%. Comparing base (bbae1aa) to head (400e163).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1255   +/-   ##
=======================================
  Coverage   99.95%   99.95%           
=======================================
  Files          72       72           
  Lines       10454    10454           
=======================================
  Hits        10449    10449           
  Misses          5        5           
Flag Coverage Δ
unittests 99.95% <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.

@BrunoLiegiBastonLiegi BrunoLiegiBastonLiegi marked this pull request as ready for review March 8, 2024 14:57
src/qibo/models/circuit.py Show resolved Hide resolved
src/qibo/models/circuit.py Show resolved Hide resolved
@BrunoLiegiBastonLiegi
Copy link
Contributor Author

Thanks @stavros11, made them properties once again.

@renatomello renatomello added this to the Qibo 0.2.6 milestone Mar 11, 2024
@renatomello renatomello added the enhancement New feature or request label Mar 11, 2024
@property
def moments(self):
moments = [self.nqubits * [None]]
moment_index = self.nqubits * [0]
Copy link
Contributor

Choose a reason for hiding this comment

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

Before, users had access to moment_index and now they don't. I don't know if this is the intended behaviour or not.

return len([1 for gate in self if isinstance(gate, gates.M)])

@property
def moments(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Both properties are missing docstrings

@BrunoLiegiBastonLiegi BrunoLiegiBastonLiegi added this pull request to the merge queue Mar 11, 2024
Merged via the queue into master with commit a603ddd Mar 11, 2024
21 checks passed
@renatomello renatomello deleted the qinfo_jit branch March 12, 2024 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants