Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support noise on custom gates #124

Open
daniel-mills-cqc opened this issue Jun 20, 2023 · 0 comments
Open

Support noise on custom gates #124

daniel-mills-cqc opened this issue Jun 20, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@daniel-mills-cqc
Copy link

daniel-mills-cqc commented Jun 20, 2023

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

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants