Create a new condition that allows easy control by bitmasks and Add a new classical Update the notebook for 'Classical control' to reflect new features"#7166
Merged
NoureldinYosri merged 21 commits intoquantumlib:mainfrom Mar 31, 2025
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7166 +/- ##
=======================================
Coverage 98.14% 98.14%
=======================================
Files 1100 1100
Lines 96147 96241 +94
=======================================
+ Hits 94365 94459 +94
Misses 1782 1782 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
daxfohl
approved these changes
Mar 22, 2025
dstrain115
approved these changes
Mar 30, 2025
Collaborator
dstrain115
left a comment
There was a problem hiding this comment.
LGTM minus some nits.
| def attrs_json_dict(obj: Any) -> Dict[str, Any]: | ||
| """Return a dictionary suitable for `_json_dict_` from an attrs dataclass.""" | ||
| attribute_names = [f.name for f in attrs.fields(type(obj))] | ||
| return obj_to_dict_helper(obj, attribute_names) |
Collaborator
There was a problem hiding this comment.
Can you add a unit test for this function?
| """A multiqubit classical control condition with a bitmask. | ||
|
|
||
| The control is based on a single measurement key and allows comparing equality or inequality | ||
| after taking the bitwise and with a bitmask. |
Collaborator
There was a problem hiding this comment.
Should we have a short blurb about the bit order of the measurement (or a reference to the measurement code that explains)?
| @staticmethod | ||
| def create_equal_mask( | ||
| key: 'cirq.MeasurementKey', bitmask: int, *, index: int = -1 | ||
| ) -> 'BitMaskKeyCondition': |
| @staticmethod | ||
| def create_not_equal_mask( | ||
| key: 'cirq.MeasurementKey', bitmask: int, *, index: int = -1 | ||
| ) -> 'BitMaskKeyCondition': |
This was referenced May 30, 2025
BichengYing
pushed a commit
to BichengYing/Cirq
that referenced
this pull request
Jun 20, 2025
… new classical Update the notebook for 'Classical control' to reflect new features" (quantumlib#7166) * Create a new condition that allows easy control by bitmasks * add tests * docstring * add missing files * swith from dataclasses to attrs * mypy * Update the notebook for 'Classical control' to reflect new features * nit * nit * tests * nit * fix doc regex * format * address comments * lint
This was referenced Aug 5, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR creates
BitMaskKeyConditiona condition that can be used to create multiqubit classical conditions with bitmasks. This will be much easier than using sympy indexedbasecc: @ikd-sci
Examples:
Any bit from 0, 2, 3 => 0b1101 = 13
Contains 0b1011 = 11 as bitmask
Doesn't contain 11 as a bitmask
update the notebook to reflect the upgraded sympy support from #6914 and the new bitmask condition from #7165