CQCL / pytket-qiskit

pytket-qiskit, extensions for pytket quantum SDK
Apache License 2.0
16 stars 13 forks source link

A noisy instance of `AerBackend` doesn't distinguish between different two qubit gates #384

Open CalMacCQ opened 2 months ago

CalMacCQ commented 2 months ago

Found a potential problem with how AerBackend backend deals with different two qubit gates.

It seems if you pass a NoiseModel to AerBackend you can use any two qubit gate including {ZZPhase, CY, TK2, etc} that acts between the edges defined in the NoiseModel and get a BackendResult from the simulation. I suppose all two qubit gates will have the same "edge error" regardless of the OpType? Would it make more sense to alter the GateSetPredicate to gates which actually work on IBM? Alternatively we could consider getting the user to define a native gateset if they pass a NoiseModel.

I find "compilation" to a backend which supports such a wide range of "native" gates to be a bit strange. It seems we have the realism of the noise model and architecture but can choose any one and two qubit gates we like for the circuit that runs.

Here's an example where I run a circuit on AerBackend with the Kyiv noise model and connectivity using a CY gate and a ZZPhase

from qiskit_aer.noise import NoiseModel
from pytket.extensions.qiskit import AerBackend, IBMQBackend
from pytket import Circuit, Qubit

# set up a noisy AerBackend
kyiv_backend = IBMQBackend("ibm_kyiv")
kyiv_noise_model = NoiseModel.from_backend(kyiv_backend._backend)
noisy_aer_backend = AerBackend(kyiv_noise_model)

# Build circuit
circ = Circuit(3).H(0).H(1).CY(0, 1).ZZPhase(0.25, 0, 1).measure_all()

# Relabel qubits to device nodes
qubit_rename_map = {Qubit("q", 0) : Qubit("node", 0),
                    Qubit("q", 1) : Qubit("node", 1),
                    Qubit("q", 2) : Qubit("node", 2)}

circ.rename_units(qubit_rename_map)

result = noisy_aer_backend.run_circuit(circ, n_shots=500)
print(result.get_counts())