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

Copying circuit wire_names #1525

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/qibo/models/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ def wire_names(self, wire_names: Union[list, dict]):
]
else:
self._wire_names = [f"q{i}" for i in range(self.nqubits)]
self.init_kwargs["wire_names"] = self._wire_names

@property
def repeated_execution(self):
Expand Down
7 changes: 5 additions & 2 deletions src/qibo/transpiler/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ def __call__(self, circuit: Circuit) -> Circuit:
)
if logical_qubits == physical_qubits:
return circuit
new_circuit = Circuit(physical_qubits)
new_wire_names = circuit.wire_names + list(
self.connectivity.nodes - circuit.wire_names
)
new_circuit = Circuit(nqubits=physical_qubits, wire_names=new_wire_names)
for gate in circuit.queue:
new_circuit.add(gate)
return new_circuit
Expand All @@ -48,7 +51,7 @@ def __init__(self, max_qubits: int = 1):

def __call__(self, circuit: Circuit):
fused_circuit = circuit.fuse(max_qubits=self.max_qubits)
new = circuit.__class__(circuit.nqubits)
new = Circuit(**circuit.init_kwargs)
for fgate in fused_circuit.queue:
if isinstance(fgate, gates.FusedGate):
new.add(gates.Unitary(fgate.matrix(), *fgate.qubits))
Expand Down
2 changes: 1 addition & 1 deletion src/qibo/transpiler/placer.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ def _assemble_circuit(self, circuit: Circuit):
gates_qubits_pairs.reverse()
assembled_gates_qubits_pairs += gates_qubits_pairs[0:remainder]

new_circuit = Circuit(circuit.nqubits)
new_circuit = Circuit(**circuit.init_kwargs)
for qubits in assembled_gates_qubits_pairs:
# As only the connectivity is important here we can replace everything with CZ gates
new_circuit.add(gates.CZ(qubits[0], qubits[1]))
Expand Down
Loading