Skip to content

Commit

Permalink
fix: remove platform.wire_names
Browse files Browse the repository at this point in the history
  • Loading branch information
changsookim authored and alecandido committed Oct 28, 2024
1 parent 5945732 commit 801dced
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
12 changes: 12 additions & 0 deletions src/qibolab/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,18 @@ def execute_circuit(self, circuit, initial_state=None, nshots=1000):
"Hardware backend only supports circuits as initial states.",
)

if not all(q in circuit.wire_names for q in self.platform.qubits):
# This should be done in qibo side
# raise_error(
# ValueError,
# "Circuit qubits do not match the platform qubits.",
# )

# Temporary fix: overwrite the wire names
circuit._wire_names = self.qubits

self.platform.wire_names = circuit.wire_names

sequence, measurement_map = self.compiler.compile(circuit, self.platform)

if not self.platform.is_connected:
Expand Down
11 changes: 4 additions & 7 deletions tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ def test_natives():

def test_natives_no_cz_cnot():
platform = create_platform("dummy")
for p in platform.pairs:
platform.pairs[p].native_gates.CZ = None
platform.pairs[p].native_gates.CNOT = None

backend = QibolabBackend(platform)
assert set(backend.natives) == {
"I",
Expand All @@ -72,15 +76,8 @@ def test_natives_no_cz_cnot():
"GPI2",
"GPI",
"M",
"CZ",
"CNOT",
}

for gate in ["CZ", "CNOT"]:
for p in platform.pairs:
setattr(platform.pairs[p].native_gates, gate, None)
assert gate not in set(backend.natives)


def test_execute_circuit_initial_state():
backend = QibolabBackend("dummy")
Expand Down

0 comments on commit 801dced

Please sign in to comment.