-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Micro-optimization for Gateset containment #7692
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
base: main
Are you sure you want to change the base?
Conversation
dstrain115
commented
Oct 2, 2025
- Check gate families with tags before doing instance GateFamily checks.
- This change will check cirq.GateFamily(cirq.ZPowGate, tags_to_accept=[PhysicalZ()]) before instance gate families.
- We generally want to avoid checking instance gate families if at all possible, since they can call protocols.equal_up_to_global_phase which is quite slow.
- Check gate families with tags before doing instance GateFamily checks. - This change will check cirq.GateFamily(cirq.ZPowGate, tags_to_accept=[PhysicalZ()]) before instance gate families. - We generally want to avoid checking instance gate families if at all possible, since they can call protocols.equal_up_to_global_phase which is quite slow.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7692 +/- ##
========================================
Coverage 99.38% 99.38%
========================================
Files 1089 1089
Lines 97414 97535 +121
========================================
+ Hits 96812 96934 +122
+ Misses 602 601 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
# Lastly, do a final exhaustive check to make sure this is not equivalent | ||
# to another type of gate. This will catch things like: | ||
# cirq.XPowGate(exponent=0) in cirq.GateFamily(cirq.I) | ||
return any(item in gate_family for gate_family in self._gates) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably do self._gates.difference(self._gate_families_with_tags)
because gfwt are already checked on line 451.
print(gateset._gate_families_with_tags) | ||
for g in gateset.gates: | ||
print(f"{g} {gate in g}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debug printouts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after addressing comments