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 to_instruction to ReadoutError #257

Merged
merged 2 commits into from
Jul 2, 2019

Conversation

chriseclectic
Copy link
Member

Summary

Adds missing to_instruction method to ReadoutError object. This allows directly inserting readout errors into a QuantumCircuit for simulation in Aer like with QuantumError objects which can be directly inserted into circuits as "kraus" instructions.

Details and comments

Example: 2-qubit readout error

from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute
from qiskit.providers.aer import QasmSimulator, noise

# make readout error probabilities
roerror1 = noise.errors.ReadoutError([[0.9, 0.1], [0.4, 0.6]])
roerror2 = roerror1.tensor(roerror1)

# Make circuit and add readout error after measurement
q = QuantumRegister(2, 'q')
c = ClassicalRegister(2, 'c')
qc = QuantumCircuit(q, c)
qc.x(q[1])
qc.measure(q, c)
qc.append(roerror2, cargs=[c[0], c[1]])

# Execute
result = execute(qc, QasmSimulator(), shots=10000).result()
result.get_counts(0)

@chriseclectic chriseclectic requested a review from atilag as a code owner July 1, 2019 18:53
atilag
atilag previously approved these changes Jul 1, 2019
Copy link
Member

@atilag atilag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go!

CHANGELOG.md Outdated
@@ -39,6 +39,7 @@ Fixed

Added
-----
- Added `to_instruction` method to `ReadoutError`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Added `to_instruction` method to `ReadoutError`.
- Added `to_instruction` method to `ReadoutError`. (#257)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(postfix the PR number)

@@ -771,7 +771,8 @@ Op json_to_op_roerror(const json_t &js) {
op.name = "roerror";
JSON::get_value(op.memory, "memory", js);
JSON::get_value(op.registers, "register", js);
JSON::get_value(op.probs, "probabilities", js);
JSON::get_value(op.probs, "probabilities", js); // DEPRECIATED: Remove in 0.4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure you'll know better than me, but I'd swear that "depreciated" is used in financial-related context. it's more common to use "deprecate" here :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's value has gone down since we included it

@chriseclectic chriseclectic merged commit f2bd261 into Qiskit:master Jul 2, 2019
@chriseclectic chriseclectic deleted the roerror2instruction branch July 20, 2019 02:16
dcmckayibm pushed a commit to dcmckayibm/qiskit-aer that referenced this pull request Nov 3, 2019
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.

2 participants