Skip to content

Commit

Permalink
map qubits
Browse files Browse the repository at this point in the history
  • Loading branch information
NoureldinYosri committed Jan 10, 2025
1 parent f8dc0c6 commit c307e4a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def generate_library_of_2q_circuits_for_circuit_op(
else:
op = circuits.CircuitOperation(circuit_or_op.freeze()).with_tags(*tags)

two_qubit_op_factory = lambda a, b, _: op.with_qubits(a, b)
two_qubit_op_factory = lambda a, b, _: op.with_qubits(a, b).mapped_op()
return _generate_library_of_2q_circuits(
n_library_circuits=n_library_circuits,
two_qubit_op_factory=two_qubit_op_factory,
Expand Down
12 changes: 9 additions & 3 deletions cirq-core/cirq/experiments/xeb_sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import tqdm

from cirq import ops, devices, value, protocols
from cirq.circuits import Circuit, Moment
from cirq.circuits import Circuit, Moment, CircuitOperation
from cirq.experiments.random_quantum_circuit_generation import CircuitLibraryCombination

if TYPE_CHECKING:
Expand Down Expand Up @@ -184,7 +184,9 @@ def _get_combinations_by_layer_for_isolated_xeb(
"""
q0, q1 = _verify_and_get_two_qubits_from_circuits(circuits)
circuits = [
circuit.transform_qubits(lambda q: {q0: devices.LineQubit(0), q1: devices.LineQubit(1)}[q])
circuit.transform_qubits(
lambda q: {q0: devices.LineQubit(0), q1: devices.LineQubit(1)}[q]
).map_operations(lambda op: op.mapped_op() if isinstance(op, CircuitOperation) else op)
for circuit in circuits
]
return [
Expand Down Expand Up @@ -215,7 +217,11 @@ def _zip_circuits(
for combination_i, combination in enumerate(layer_combinations.combinations):
wide_circuit = Circuit.zip(
*(
circuits[i].transform_qubits(lambda q: pair[q.x])
circuits[i]
.transform_qubits(lambda q: pair[q.x])
.map_operations(
lambda op: op.mapped_op() if isinstance(op, CircuitOperation) else op
)
for i, pair in zip(combination, layer_combinations.pairs)
)
)
Expand Down

0 comments on commit c307e4a

Please sign in to comment.