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

Simplify cbloq.to_cirq_circuit() with sensible defaults and add cbloq.to_cirq_circuit_and_quregs() #927

Merged
merged 7 commits into from
May 9, 2024

Conversation

tanujkhattar
Copy link
Collaborator

More often than not, we construct a composite bloq corresponding to an algorithm / primitive in Qualtran and then wish to convert it to a cirq circuit. The CompositeBloq.to_cirq_circuit api is unnecessarily complex for this use case.

This PR refactors the api s.t. the previous API for CompositeBloq.to_cirq_circuit() is now renamed to CompositeBloq.to_cirq_circuit_and_quregs() and the new CompositeBloq.to_cirq_circuit() simply returns a cirq.FrozenCircuit. It also doesn't need you to provide the input quregs and can use sensible defaults using get_named_qubits(self.signature.lefts()).

Therefore, to get a cirq circuit from a composite bloq, users can now simply do circuit = cbloq.to_cirq_circuit() for a reasonable default and can provide the input quregs explicitly or call cbloq.to_cirq_circuit_and_quregs for more advanced use cases.

@mpharrigan mpharrigan merged commit 433a288 into quantumlib:main May 9, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants