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

New backend specialised for Hamming-weight-preserving circuits #1565

Draft
wants to merge 40 commits into
base: master
Choose a base branch
from

Conversation

renatomello
Copy link
Contributor

Checklist:

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

@renatomello renatomello self-assigned this Jan 25, 2025
@renatomello renatomello added this to the Qibo 0.2.16 milestone Jan 25, 2025
@renatomello renatomello added documentation Improvements or additions to documentation enhancement New feature or request labels Jan 25, 2025
@renatomello renatomello changed the base branch from master to hwk_encoder January 25, 2025 06:02
@renatomello
Copy link
Contributor Author

@BrunoLiegiBastonLiegi could you help me out with setting the correct engine from the name of the platform? I didn't understand what you did for the Clifford backend.

@renatomello renatomello changed the title New Hamming-weight-preserving backend New backend specialised for Hamming-weight-preserving circuits Jan 25, 2025
@renatomello renatomello deleted the branch master January 29, 2025 14:02
@renatomello
Copy link
Contributor Author

This was closed by mistake, so I'm reopening it.

@renatomello renatomello reopened this Jan 29, 2025
@scarrazza scarrazza modified the milestones: Qibo 0.2.16, Qibo 0.2.17 Feb 12, 2025
@AlejandroSopena AlejandroSopena self-assigned this Feb 28, 2025
@AlejandroSopena AlejandroSopena removed their request for review February 28, 2025 10:19
Copy link

codecov bot commented Feb 28, 2025

Codecov Report

Attention: Patch coverage is 10.00000% with 279 lines in your changes missing coverage. Please review.

Project coverage is 97.19%. Comparing base (5c93898) to head (860b91c).
Report is 14 commits behind head on master.

Files with missing lines Patch % Lines
src/qibo/backends/hamming_weight.py 9.01% 212 Missing ⚠️
src/qibo/quantum_info/hamming_weight.py 0.00% 60 Missing ⚠️
src/qibo/gates/measurements.py 12.50% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1565      +/-   ##
==========================================
- Coverage   99.58%   97.19%   -2.39%     
==========================================
  Files          76       78       +2     
  Lines       11322    11625     +303     
==========================================
+ Hits        11275    11299      +24     
- Misses         47      326     +279     
Flag Coverage Δ
unittests 97.19% <10.00%> (-2.39%) ⬇️

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.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +65 to +66
and not gate.__class__.__name__ == "M"
and not gate.__class__.__name__ == "Unitary"
Copy link
Contributor Author

@renatomello renatomello Mar 11, 2025

Choose a reason for hiding this comment

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

Suggested change
and not gate.__class__.__name__ == "M"
and not gate.__class__.__name__ == "Unitary"
and not isinstance(gate, (gates.M, gates.Unitary))

@@ -74,6 +74,11 @@ def clifford(self):
"""Return boolean value representing if a Gate is Clifford or not."""
return False

@property
def hamming_weight(self):
"""Return boolean value representing if a Gate is Hamming weight preserving or not."""
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
"""Return boolean value representing if a Gate is Hamming weight preserving or not."""
"""Return boolean value representing if a Gate is Hamming-weight-preserving or not."""

@@ -2545,6 +2698,10 @@ def __init__(
self.init_args = [qubits_in, qubits_out]
self.init_kwargs = {"theta": theta, "phi": phi, "trainable": trainable}

@property
def hamming_weight(self):
return len(self.init_args[0]) == len(self.init_args[1])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice

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