qat.plugins.Localizer
The Localizer
is designed to be used in front of the DLinAlg
simulator.
Since N-qbits remote gates are not implemented in the current version of DLinAlg
simulator, it is necessary to “localize” the remote qubits involved before simulating them. The Localizer
plugin adds SWAP gates in front of these remote operations to swap the remote qubits involved with an unused local qubit.
- class qat.plugins.Localizer(method='windowed_layer', update_initial_remote_qubits=None, nbqbits_remote=None, qbits_compilation_threshold=None, **kwargs)
Swap insertion plugin that adds in SWAP gates before remote operations to localize the remote qubits. After the application of this plugin, the compiled circuit will only consist of local gates, remote SWAP gates, remote diagonal gates, and remote gates where the remote qubits are control qubits. The only gates that require communication are then the remote SWAP gates.
Currently, there are 3 different insertion strategies that can be applied by this plugin, which are described below:
naive
: This strategy naively localize remote gates in the order they come in the input circuit. When a remote operation is encountered, it always swap the remote qubits involved with the last available local qubits.naive_layer
: This strategy extends the naive strategy with an additional step to reorder the gates so that all the local gates that can be performed without inserting any SWAP gate are applied. The compiled circuit will end up with some remote SWAP gates in between layers of local gates. This leads to less SWAP gate added compared to the naive method. However, the SWAP gates are still added between the remote qubits involved in the remote operations and the last available local qubits.windowed_layer
: This strategy further extends the naive_layer method, and considers the local qubits used in the next few windows of local operations, when trying to insert the SWAP gates. Local qubits that are not used in the next windows are chosen in priority, since we won’t need to add more SWAP gates to swap them in again. This method will add in the least amount of SWAP gates compared to the other two strategies.
- Parameters
method (optional, str) – the localizer method to apply (possible strategies are “naive”, “naive_layer”, “windowed_layer”). Default is “windowed_layer”.
qbits_compilation_threshold (optional, int) – the minimum number of qubits in a circuit for it to be compiled Default is 2.
- compile(batch, specs)
Compiles the batch to add in SWAP gates, ensuring that multiple qubit gates (except the SWAP gates) only operates on local qubits.
- Parameters
batch (Batch) – batch to optimize
specs (HardwareSpecs) – hardware specifications