-
Notifications
You must be signed in to change notification settings - Fork 12
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
Update TketBackend
to derive from BackendV2
#389
Conversation
dfcbcb8
to
1dff824
Compare
gate_name = _gate_str_2_optype_rev[optype] | ||
if gate_name in standard_gate_mapping: | ||
gate_obj = standard_gate_mapping[gate_name] | ||
if gate_obj.num_qubits in [1, 2] or inspect.isclass(gate_obj): |
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.
See https://github.com/Qiskit/qiskit/blob/2ef371ae0d159a6dfd643805f3e5e5fdec37ab88/qiskit/transpiler/target.py#L1066 -- have to restrict the gateset to match what is accepted by the Target
method.
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.
Do I understand correctly that the gate_obj
variable is not always a class? Presumably thats why the inspect check is needed.
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.
Yes, some gates such as CCX were rejected when I omitted this check. I am not sure when gate_obj
is a class, but simply copied that from the code linked above.
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.
Looks good :) just a few very minor comments
] | ||
basis_gates = [] | ||
for optype in pred.gate_set: | ||
if optype in _gate_str_2_optype_rev.keys(): |
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.
Perhaps worth adding a comment explaining what these "if" statements are for?
from pytket.architecture import FullyConnected | ||
|
||
|
||
def _extract_basis_gates(backend: Backend) -> list[str]: | ||
standard_gate_mapping = get_standard_gate_name_mapping() | ||
for pred in backend.required_predicates: | ||
if type(pred) == GateSetPredicate: |
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.
Rather pedantic but is there a reason not to use "is" or "isinstance" here vs "=="?
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.
Thanks :)
Closes #350 .
This change would break one of the examples in the manual, and perhaps also one or two places in the example notebooks (I haven't checked). This shouldn't affect the docs build since it's pinned to a specific version of pytket-qiskit, but we should probably revise those sections. It seems that the relevant parts of
qiskit_algorithms
(a community-maintained project) haven't yet been updated to use the new backend class.This PR removes the last of the deprecation warnings from the qiskit tests that were coming from our code.