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

add optional labels to standard gates #175

Merged
merged 11 commits into from
Apr 29, 2019

Conversation

chriseclectic
Copy link
Member

@chriseclectic chriseclectic commented Apr 24, 2019

Summary

  • Fix rounder error for using atol parameter in truncating probabilities in QuantumError (closes Composing a depolarizing error with a thermal error fails for certain values #176).
  • Composing errors with unitary or Kraus instructions now fuses additional instructions.
  • Adds optional labels to all standard gate operations. This allows adding a noise model to specially labeled gates as with the unitary instruction in the noise model.
  • If a label isn't specified the gate name is used as the label so there is no backwards compatibility.

NOTE: this isn't supported through Terra circuits yet, this is to preemptively to add support to Aer from the qobj level.

Details and comments

If a qobj circuit had instructions: [{"name": "id", "qubits": [0]}, {"name": "id", "qubits": [0], "label": "alt_id"}] then adding a noise model with quantum error error_a to "id" and error_b to "alt_id" would sample from the two different errors for each of the identity instructions.

Example

from qiskit import *
from qiskit.providers.aer import QasmSimulator, noise

qr = QuantumRegister(2)
cr = ClassicalRegister(2)
circ = QuantumCircuit(qr, cr)
circ.iden(qr[0])
circ.iden(qr[1])
circ.barrier(qr)
circ.measure(qr, cr)

qobj = assemble_circuits(circ)
# edit qobj
qobj.experiments[0].instructions[1].label = 'id1'
qobj.config.shots = 10000

# Ideal
result = QasmSimulator().run(qobj).result()
print(result.get_counts(0))  # {'00': 10000}

# noise model
error0 = noise.errors.depolarizing_error(0.25, 1)
error1 = noise.errors.depolarizing_error(0.5, 1)
noise_model = noise.NoiseModel()
noise_model.add_all_qubit_quantum_error(error0, 'id')
noise_model.add_all_qubit_quantum_error(error1, 'id1')

result = QasmSimulator().run(qobj, noise_model=noise_model).result()
print(result.get_counts(0))  # {'11': 323, '00': 6532, '01': 943, '10': 2202}

@chriseclectic chriseclectic requested a review from atilag as a code owner April 24, 2019 20:24
@chriseclectic chriseclectic added this to the 0.2 milestone Apr 27, 2019
@chriseclectic chriseclectic merged commit 3f1437d into Qiskit:master Apr 29, 2019
@chriseclectic chriseclectic deleted the feature-gate-labels branch April 30, 2019 20:12
dcmckayibm pushed a commit to dcmckayibm/qiskit-aer that referenced this pull request Nov 3, 2019
* add optional labels to standard gates in cpp noise model

* allow labels for gates in python noise model

* rename operations to instructions in NoiseModel

* move test_noise_transformation

* add add_basis_gates function to NoiseModel

* add basis_gates to NoiseModel init

* add id to NoiseModel default basis_gates

* add to_instruction method to QuantumError

* fix rounding errors in QuantumError composition

* update changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Composing a depolarizing error with a thermal error fails for certain values
1 participant