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

First version of default UCC #10

Merged
merged 4 commits into from
Sep 18, 2024
Merged

First version of default UCC #10

merged 4 commits into from
Sep 18, 2024

Conversation

sonikaj
Copy link
Collaborator

@sonikaj sonikaj commented Sep 10, 2024

This version of the UCC compiler works for fully connected backends which support single qubit Pauli rotations and CX gates. Currently the runtimes are better than the default Qiskit transpiler, which is mainly achieved by compiling all operations in the beginning to a small, fixed gate set. This is then utilized to speed up commutation checking in various ways.

The number of 1 qubit gates is currently worse by a factor of 4 while the number of 2 qubit gates should be about similar for most circuits compared to the default Qiskit compiler. A new transpiler pass needs to be written to optimize the 1Q gates. Note that in terms of user experience, 1Q gates are typically fast and high-fidelity, and also hardware vendors will typically quickly optimize them, so this may be a lower priority than passes for mapping and reducing 2Q gates.

UCC relies on Qiskit for the DAG manipulation, but all code used from qiskit.transpiler.passes is now in the local transpiler_passes folder. Note there is currently a lot of unused code in these passes. After a mapping pass is added for finite connectivity backends, any overall unused code in transpiler_passes will be removed.

Next, to-do is to add an efficient mapping pass and CX gate pass.

@jordandsullivan jordandsullivan linked an issue Sep 10, 2024 that may be closed by this pull request
Copy link
Collaborator

@jordandsullivan jordandsullivan left a comment

Choose a reason for hiding this comment

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

Looks good, thanks Sonika. Just a couple minor comments.

class UCCTranspiler:
@staticmethod
def transpile(qasm_code: str):
def transpile(qasm_code: str, mode: str = 'qiskit', draw = False, get_gate_counts = False) -> str:
"""
transpiles the given QASM code using Qiskit's transpile function.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please edit this docstring to reflect the current functionality.

def _error(self, circuit, qubit):
"""
Calculate a rough error for a `circuit` that runs on a specific
`qubit` of `target` (`circuit` can either be an OneQubitGateSequence
Copy link
Collaborator

Choose a reason for hiding this comment

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

You seem to be referring to target as a variable, but I don't see it defined in 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.

Not currently using this as it wasn't working well for the 1Q gates. I'll be editing this pass.

# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
Copy link
Collaborator

@jordandsullivan jordandsullivan Sep 10, 2024

Choose a reason for hiding this comment

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

For the licensing, please add a note to each file where the original Qiskit code has been modified.

Copy link
Collaborator

@jordandsullivan jordandsullivan left a comment

Choose a reason for hiding this comment

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

In the Qiskit files you added, you'll need to note at the top for any that you have modified, per the Apache license.

@sonikaj
Copy link
Collaborator Author

sonikaj commented Sep 13, 2024

In the Qiskit files you added, you'll need to note at the top for any that you have modified, per the Apache license.

Is there standard text that Unitary Fund adds in this context?

@jordandsullivan
Copy link
Collaborator

jordandsullivan commented Sep 13, 2024

standard

Yes, we will need to add it before launch. I would need to double check how the two licenses play together:
https://github.com/unitaryfund/mitiq/blob/1a3705c43b47ec44eae90849d2de5106ee3a26d9/mitiq/ddd/ddd.py#L1-L4

Don't worry about all the licensing text for this PR, just note which files have been modified.

…ited docstrings to reflect current functionality
@jordandsullivan
Copy link
Collaborator

Lgtm

@jordandsullivan jordandsullivan merged commit b926941 into main Sep 18, 2024
jordandsullivan added a commit that referenced this pull request Nov 13, 2024
First version of default UCC
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.

Add custom UCC transpiler code to ucc/ucc module
2 participants