circuit_knitting.cutting.partition_circuit_qubits

partition_circuit_qubits(circuit, partition_labels, inplace=False)[source]

Replace all nonlocal gates belonging to more than one partition with instances of TwoQubitQPDGate.

TwoQubitQPDGates belonging to a single partition will not be affected.

Parameters:
  • circuit (QuantumCircuit) – The circuit to partition

  • partition_labels (Sequence[Hashable]) – A sequence containing a partition label for each qubit in the input circuit. Nonlocal gates belonging to more than one partition will be replaced with TwoQubitQPDGates.

  • inplace (bool) – Flag denoting whether to copy the input circuit before acting on it

Return type:

QuantumCircuit

Returns:

The output circuit with each nonlocal gate spanning two partitions replaced by a TwoQubitQPDGate

Raises:
  • ValueError – The length of partition_labels does not equal the number of qubits in the circuit.

  • ValueError – Input circuit contains unsupported gate.