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

Transpiler add passes that might be out of the default basis #2357

Merged
merged 18 commits into from
May 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions qiskit/compiler/transpile.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,14 @@ def _parse_basis_gates(basis_gates, backend, circuits):
if basis_gates is None or (isinstance(basis_gates, list) and
all(isinstance(i, str) for i in basis_gates)):
basis_gates = [basis_gates] * len(circuits)
# no basis means don't unroll (all circuit gates are valid basis)
basis_gates = [[inst.name for inst, _, _ in circuit.data] if basis is None
else basis for basis, circuit in zip(basis_gates, circuits)]

# no basis means don't unroll (all circuit gates are valid basis)
for index, circuit in enumerate(circuits):
basis = basis_gates[index]
ajavadia marked this conversation as resolved.
Show resolved Hide resolved
if basis is None:
gates_in_circuit = set(inst.name for inst, _, _ in circuit.data)
# Other passes might add new gates that need to be supported
basis_gates[index] = list(gates_in_circuit.union(['u3', 'cx']))
return basis_gates


Expand Down