Closed cqc-alec closed 1 month ago
Would using
AutoRebase
work for this? Notk1_replacement
function is needed forAutoRebase
.
Yes I think AutoRebase
would work for this (the target gateset is large).
Also is there a reason this needs to be serialized? The
tk_to_qiskit
function is not used in thedefault_compilation_pass
for any Backends as far as I know.
Good question. I can't see why it would be needed. But @johnchildren mentioned that some of the default passes for ibm-qiskit were not serializable. At the moment I'm struggling to see how a RebaseCustom is making its way into any of these.
@johnchildren Could you provide more details of the non-serializable default pass in pytket-qiskit?
@cqc-alec Sure, using this script I get quite a large dict that contains this pass:
{'StandardPass': {'basis_allowed': ['CX', 'GPI2', 'GPI', 'PhasedX', 'TK1', 'Reset', 'U1', 'Collapse', 'U2', 'Measure', 'U3', 'noop', 'Rz', 'Ry', 'Z', 'X', 'Y', 'S', 'Sdg', 'T', 'Tdg', 'V', 'Vdg', 'SX', 'SXdg', 'H', 'Rx'], 'basis_cx_replacement': {'bits': [], 'commands': [{'args': [['q', [0]], ['q', [1]]], 'op': {'type': 'CX'}}], 'created_qubits': [], 'discarded_qubits': [], 'implicit_permutation': [[['q', [0]], ['q', [0]]], [['q', [1]], ['q', [1]]]], 'phase': '0.0', 'qubits': [['q', [0]], ['q', [1]]]}, 'basis_tk1_replacement': 'SERIALIZATION OF FUNCTIONS IS NOT YET SUPPORTED', 'name': 'RebaseCustom'}, 'pass_class': 'StandardPass'}
from pytket.extensions.qiskit.backends.ibm import IBMQBackend
print(IBMQBackend(backend_name="ibm_kyiv").default_compilation_pass().to_dict())
pytket-qiskit version 0.55, pytket version 1.31.1
Thanks John, should be easy to replace this use of RebaseCustom
I am slightly puzzled that this RebaseCustom
pass shows up in the dict
at all. Its not a part of the default_compilation_pass
in and of itself. Rather the circuit is converted from pytket -> qiskit after compilation for submission to the wrapped qiskit backend.
Unfortunately CQCL/pytket-qiskit#387 did not fix this: John's script still prints JSON including 'basis_tk1_replacement': 'SERIALIZATION OF FUNCTIONS IS NOT YET SUPPORTED'
.
Yes I also spotted this... Puzzled as to why its showing up as it was the only place that RebaseCustom appeared in the pytket-qiskit extension.
Yes I also spotted this... Puzzled as to why its showing up as it was the only place that RebaseCustom appeared in the pytket-qiskit extension.
I suppose it must be used in tket inside one of the other passes?
I suppose it must be used in tket inside one of the other passes?
Yes, that must be the reason. I guess we should try and update this internal rebasing if we can?
I noticed that this didn't remove the RebaseCustom
pass from the dict before merging CQCL/pytket-qiskit#387. However I still think it was worth doing for the code simplification.
To clarify something for me as well, does every Custom pass have a 'basis_tk1_replacement'
? It looked like from the serialization code that value would always be returned even if there was no replacement in the pass?
To clarify something for me as well, does every Custom pass have a
'basis_tk1_replacement'
? It looked like from the serialization code that value would always be returned even if there was no replacement in the pass?
Every RebaseCustom
pass (not every CustomPass
) contains a basis_tk1_replacement
. However, a pass generated from AutoRebase
should not:
from pytket.circuit import OpType
from pytket.passes import AutoRebase
p = AutoRebase(set([OpType.Rx, OpType.Rz, OpType.CX]))
print(p.to_dict())
{'StandardPass': {'allow_swaps': False,
'basis_allowed': ['Rx', 'Rz', 'CX'],
'name': 'AutoRebase'},
'pass_class': 'StandardPass'}
Perhaps this issue should be closed now. Maybe we should open a follow-up on the CQCL/tket
repo?
Let's keep it open for now; it needs more investigation before we know where the fix should be.
The non-serializable component of the pass is the CXMappingPass()
. The fix for this should indeed be in TKET, so I will move this issue to the tket repo (and rename it).
Would using
AutoRebase
work for this? Notk1_replacement
function is needed forAutoRebase
.Also is there a reason this needs to be serialized? The
tk_to_qiskit
function is not used in thedefault_compilation_pass
for any Backends as far as I know.