Skip to content

Conversation

@BichengYing
Copy link
Collaborator

@BichengYing BichengYing commented Nov 4, 2025

We should use the internal str style representation, it is natural to use cirq.q and cirq.Coupler in the analog construction.

@github-actions github-actions bot added the size: M 50< lines changed <250 label Nov 4, 2025
@codecov
Copy link

codecov bot commented Nov 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.37%. Comparing base (1deffd6) to head (fb178ff).
⚠️ Report is 1 commits behind head on main.

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.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions bot added size: L 250< lines changed <1000 and removed size: M 50< lines changed <250 labels Nov 5, 2025
Comment on lines +40 to +42
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]
Copy link
Collaborator

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?

Copy link
Collaborator Author

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:
Copy link
Collaborator

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.

Copy link
Collaborator Author

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
Copy link
Collaborator

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")

Copy link
Collaborator Author

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],
Copy link
Collaborator

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?

Copy link
Collaborator Author

@BichengYing BichengYing Nov 8, 2025

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
Copy link
Collaborator

Choose a reason for hiding this comment

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

Grammar: "coupler" --> "couplers"

Copy link
Collaborator Author

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
Copy link
Collaborator

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?

https://quantumai.google/reference/python/cirq/Duration

Copy link
Collaborator Author

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)

Copy link
Collaborator

@dstrain115 dstrain115 left a 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.

@BichengYing BichengYing added this pull request to the merge queue Nov 10, 2025
Merged via the queue into quantumlib:main with commit 2bdbea8 Nov 10, 2025
34 of 35 checks passed
@BichengYing BichengYing deleted the u/ybc/analog_traj_use_cirq_q branch November 10, 2025 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: L 250< lines changed <1000

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants