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

Improve ancilla detection in HighLevelSynthesis #13239

Closed
alexanderivrii opened this issue Sep 30, 2024 · 0 comments · Fixed by #13240
Closed

Improve ancilla detection in HighLevelSynthesis #13239

alexanderivrii opened this issue Sep 30, 2024 · 0 comments · Fixed by #13240
Assignees
Labels
type: feature request New feature or request
Milestone

Comments

@alexanderivrii
Copy link
Contributor

What should we add?

In #12911 we have added the ability to track the state of each qubit within the HighLevelSynthesis transpiler pass (i.e. whether the qubit is "clean" (in state $|0\rangle$) or "dirty" (in some other state)) and to automatically exploit clean/dirty ancilla qubits with the appropriate synthesis algorithms.

In the following snippet, a circuit with a single MCX-gate

qc = QuantumCircuit(10)
qc.mcx([3, 4, 5, 6, 7], 0)
basis_gates = ["u", "cx"]
tqc = HighLevelSynthesis(basis_gates=basis_gates)(qc)

is synthesized to a circuit with 24 CX-gates and 45 U-gates. Internally the MCX synthesis algorithm has access to $4$ clean ancilla qubits (1, 2, 8, 9).

However, an arguably identical circuit in the following snippet,

inner = QuantumCircuit(6)
inner.mcx([0, 1, 2, 3, 4], 5)
custom_gate = inner.to_gate()
qc = QuantumCircuit(10)
qc.append(custom_gate, [3, 4, 5, 6, 7, 0])
basis_gates = ["u", "cx"]
tqc = HighLevelSynthesis(basis_gates=basis_gates)(qc)

is synthesized to a worse circuit with 84 CX-gates and 127 U-gates. This is due to how the recursion is treated with HighLevelSynthesis, with the synthesis of custom_gate having no access to ancilla qubits outside of its definition.

This issue will be very soon followed by a PR addressing the problem above.

@alexanderivrii alexanderivrii added the type: feature request New feature or request label Sep 30, 2024
@alexanderivrii alexanderivrii added this to the 1.3.0 milestone Sep 30, 2024
@alexanderivrii alexanderivrii self-assigned this Sep 30, 2024
@raynelfss raynelfss changed the title Improve ancilla detection in HighLevenSynthesis Improve ancilla detection in HighLevelSynthesis Oct 18, 2024
@github-project-automation github-project-automation bot moved this from To do to done in Transpiler Oct 30, 2024
alexanderivrii added a commit to alexanderivrii/qiskit-terra that referenced this issue Oct 31, 2024
github-merge-queue bot pushed a commit that referenced this issue Nov 7, 2024
* py version for expand

* starting to write some code

* implementing

* cleanup

* cleanup

* expand fully & simplify lie trotter

* use examples that actually do not commute

* add plugin structure

* fixing global phase for all-I rotations

* fixes

* fixing plugin names

* minor

* removing a random print statement

* additional improvements

* improving rustiq plugin

* merge with #13239

* Adding pauli evolution plugins to docstrings

* adding documentation on rustiq plugin

* fixes after refactoring

* typo

* more merges with #13295; adding more Rustiq tests

* more efficient append_sx and append_sxdg gates for cliffords

* review comments

* moving the pauli network synthesis logic into a separate file

* some code review suggestions

* simplifying the code by merging the oredered and unorderd version of rotation injection

* more review comments

* adding python tests

* more code review suggestions

* more review comments

* more review comments

* test for preserve_order

* lint

* upgrading rustiq-core to 0.0.10

* clippy: removing mutable ref

* Improving PauliEvolution synthesis tests.

Making sure that the number of rotation gates in the synthesized
circuit equals the number of non-trivial Pauli rotation gates.

* documentation fixes after the merge

---------

Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request New feature or request
Projects
Status: done
Development

Successfully merging a pull request may close this issue.

1 participant