Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Support noise on custom gates #515

Closed
daniel-mills-cqc opened this issue Jun 20, 2023 · 1 comment
Closed

Support noise on custom gates #515

daniel-mills-cqc opened this issue Jun 20, 2023 · 1 comment

Comments

@daniel-mills-cqc
Copy link

Qiskit permits noise to be added to particular gates, for example as follow:

from qiskit import QuantumCircuit
from qiskit_aer import AerSimulator
from qiskit_aer.noise import NoiseModel, depolarizing_error
from qiskit.extensions import UnitaryGate

error = depolarizing_error(0.1, 1)

noise_model = NoiseModel()
noise_model.add_quantum_error(error, 'my_gate', [0])
noise_model.add_basis_gates(['unitary'])

matrix = [[0,1], [1,0]]
gate = UnitaryGate(matrix, label='my_gate')

circ = QuantumCircuit(1)
circ.append(gate, [0])
circ.measure_all()

backend = AerSimulator(noise_model=noise_model)

noise_result = backend.run(circ).result()
noise_result.get_counts()

giving in one instance:

{'0': 46, '1': 978}

as expected. It seems that it's not straightforward to do the same with pytket with something very simple like:

from pytket.extensions.qiskit import AerBackend

tket_backend = AerBackend(noise_model=noise_model)

giving an error ending in:

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pytket/extensions/qiskit/backends/aer.py:591, in _process_noise_model(noise_model, gate_set)
    589 if len(qubits) == 1:
    590     [q] = qubits
--> 591     optype = _gate_str_2_optype[name]
    592     qubits_set.add(q)
    593     if error["type"] == "qerror":

KeyError: 'my_gate'

Being able to add noise to particular gates would be a great feature to have!

@daniel-mills-cqc
Copy link
Author

Closed as reopened here -> CQCL/pytket-qiskit#124

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant