-
Notifications
You must be signed in to change notification settings - Fork 9
Add UCC+DDD compiler #200
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
Open
natestemen
wants to merge
9
commits into
main
Choose a base branch
from
nts-ucc-ddd
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add UCC+DDD compiler #200
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
11155c4
add basic ucc+ddd compiler
natestemen 94fbacb
add note about why 1 circuit
natestemen 01e7c98
oops; no auto-format on this repo
natestemen f7fe36d
add identity as default gate
natestemen 0c9eab6
add ucc-ddd compiler to unit tests
natestemen 46b9879
use DDD rule that follows correct gate set
natestemen c19f77c
add more complex noise model
natestemen 51d8ccc
general_rule performing better
natestemen adcd905
add coherent error noise model
natestemen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| from .base_compiler import BaseCompiler | ||
| from qiskit import QuantumCircuit | ||
| from qiskit.providers import Backend | ||
| from typing import Optional | ||
| from qbraid import transpile as qb_transpile | ||
|
|
||
| from ucc import __version__ as ucc_version | ||
| from ucc import compile as ucc_compile | ||
|
|
||
| from ..registry import register | ||
|
|
||
| from mitiq import __version__ as mitiq_version | ||
| from mitiq.ddd import construct_circuits as ddd_construct_circuits | ||
| from mitiq.ddd import rules as ddd_rules | ||
|
|
||
|
|
||
| @register.compiler("ucc-ddd") | ||
| class UCCDDDCompiler(BaseCompiler[QuantumCircuit]): | ||
| """ | ||
| UCC compiler followed by Digital Dynamical Decoupling using Mitiq. | ||
| """ | ||
|
|
||
| @classmethod | ||
| def version(cls) -> str: | ||
| return f"UCC:{ucc_version}+mitiq:{mitiq_version}" | ||
|
|
||
| def qasm_to_native(self, qasm: str) -> QuantumCircuit: | ||
| return qb_transpile(qasm, "qiskit") | ||
|
|
||
| def compile( | ||
| self, circuit: QuantumCircuit, target_device: Optional[Backend] = None | ||
| ) -> QuantumCircuit: | ||
natestemen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if target_device is not None: | ||
| compiled = ucc_compile(circuit, target_backend=target_device) | ||
| else: | ||
| compiled = ucc_compile( | ||
| circuit, | ||
| target_gateset={"rx", "ry", "rz", "h", "cx"}, | ||
| ) | ||
|
|
||
| ddd_circuits = ddd_construct_circuits( | ||
| compiled, | ||
| rule=ddd_rules.xx, | ||
| num_trials=1, # one circuit = no post-processing | ||
| ) | ||
| return ddd_circuits[0] | ||
|
|
||
| def count_multi_qubit_gates(self, circuit: QuantumCircuit) -> int: | ||
| return circuit.num_nonlocal_gates() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Interesting question this raises, as all other compilers return the single version string of that compiler. This change is reasonable, but would complicate the labels in the performance by time plots.
I believe seeing how performance changes with new software versions is the main use of this
versionstring. For composite compilers like this, that becomes tricky to define a version order.That being said, I'm ok to leave that an open question, but I wanted to flag.