-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Use cirq.q instead of str in analog #7736
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
Use cirq.q instead of str in analog #7736
Conversation
cirq-google/cirq_google/experimental/analog_experiments/analog_trajectory_util.py
Outdated
Show resolved
Hide resolved
cirq-google/cirq_google/experimental/analog_experiments/generic_analog_circuit_test.py
Outdated
Show resolved
Hide resolved
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7736 +/- ##
==========================================
- Coverage 99.38% 99.37% -0.01%
==========================================
Files 1091 1091
Lines 97919 97935 +16
==========================================
+ Hits 97313 97327 +14
- Misses 606 608 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| def _coupler_name(coupler: cgc.Coupler) -> str: | ||
| q1, q2 = sorted(coupler.qubits) | ||
| return f"c_q{q1.row}_{q1.col}_q{q2.row}_{q2.col}" # type: ignore[attr-defined] |
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.
Do we need this function?
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.
Yeah, that is because analog code is still quite close to the internal code. The str coupler representation is still needed in the low-level gates implementation. (We don't wanna to introduce the circular import issue there)
| gac._to_grid_qubit("q1") | ||
|
|
||
|
|
||
| def test_coupler_name_from_qubit_pair() -> None: |
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.
I think the name of this should change. Also, we may not need the function that it is testing.
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.
Done
| Args: | ||
| sparse_trajectory: A list of tuples, where each tuple defines a `FrequencyMap` | ||
| and contains three elements: (duration, qubit_freqs, coupling_strengths). | ||
| `duration` is a tunits value, `qubit_freqs` is a dictionary mapping qubit strings |
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.
Please fix doc string ("qubit strings")
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.
Done
| qubits: list[str], | ||
| pairs: list[tuple[str, str]], | ||
| qubits: list[cirq.Qid], | ||
| pairs: list[cgc.Coupler], |
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.
Maybe call it couplers instead of pairs?
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.
Yeah, modified.
| to detuning frequencies, and `coupling_strengths` is a dictionary mapping qubit | ||
| pairs to their coupling strength. This format is considered "sparse" because each | ||
| to detuning frequencies, and `coupling_strengths` is a dictionary mapping | ||
| coupler to their coupling strength. This format is considered "sparse" because each |
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.
Grammar: "coupler" --> "couplers"
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.
Done
| Args: | ||
| sparse_trajectory: A list of tuples, where each tuple defines a `FrequencyMap` | ||
| and contains three elements: (duration, qubit_freqs, coupling_strengths). | ||
| `duration` is a tunits value, `qubit_freqs` is a dictionary mapping qubit strings |
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.
Should we also accept cirq.Duration? If not, should we deprecate cirq.Duration?
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 yse tu.Value here is requested by Trond because "duration" here is parameterized commonly. Resolving it into cirq.Duration is awkward but to t-units: it is simply cirq.Point("t_r", [1,2,3,4,5]*tu.ns)
dstrain115
left a comment
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.
Backwards incompatible change, but no one is using this functionality yet, so it's fine. Better to get this correct before usage begins.
We should use the internal str style representation, it is natural to use cirq.q and cirq.Coupler in the analog construction.