Skip to content

Add a post-selection guide#4990

Open
kaelynj wants to merge 9 commits intomainfrom
kjf/post-selection
Open

Add a post-selection guide#4990
kaelynj wants to merge 9 commits intomainfrom
kjf/post-selection

Conversation

@kaelynj
Copy link
Copy Markdown
Collaborator

@kaelynj kaelynj commented Apr 14, 2026

Closes #4397

@kaelynj kaelynj requested review from a team and jyu00 April 14, 2026 21:20
@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link
Copy Markdown
Collaborator

@abbycross abbycross left a comment

Choose a reason for hiding this comment

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

Reads well! I did a copyedit passthrough.

Comment thread docs/guides/_toc.json Outdated
Comment thread docs/guides/post-selection.ipynb Outdated
Comment thread docs/guides/post-selection.ipynb Outdated
Comment thread docs/guides/post-selection.ipynb Outdated
Comment thread docs/guides/post-selection.ipynb Outdated
Comment thread docs/guides/post-selection.ipynb Outdated
Comment thread docs/guides/post-selection.ipynb Outdated
Comment thread docs/guides/post-selection.ipynb Outdated
Comment thread docs/guides/post-selection.ipynb Outdated
Comment thread docs/guides/post-selection.ipynb Outdated
@abbycross
Copy link
Copy Markdown
Collaborator

Let's also take this opportunity to standardize to postselection (one word, no hyphen) both in this PR and in other instances in the guides where we hyphenate.

Co-authored-by: abbycross <across@us.ibm.com>
Co-authored-by: abbycross <across@us.ibm.com>
@abbycross
Copy link
Copy Markdown
Collaborator

abbycross commented Apr 20, 2026

I do not understand why the spellcheck is flagging mdash (as part of the &mdash; unicode)! It doesn't do that with things like &nbsp; and &reg; 🤷
Feel free to add it to the cspell ignore file. I'm doing it in another PR but it depends which gets merged first! I've added it to cspell

"source": [
"## Add postselection transpiler passes\n",
"\n",
"Next, create a preset pass manager that includes the [`AddPostSelectionMeasures`](https://qiskit.github.io/qiskit-addon-utils/stubs/qiskit_addon_utils.noise_management.post_selection.transpiler.passes.AddSpectatorMeasures.html) and [`AddSpectatorMeasures`](https://qiskit.github.io/qiskit-addon-utils/stubs/qiskit_addon_utils.noise_management.post_selection.transpiler.passes.AddPostSelectionMeasures.html) passes from the [`qiskit-addon-utils`](https://qiskit.github.io/qiskit-addon-utils/index.html) package."
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's explained a bit in the intro, but I think it's worth repeating that this step adds a long X pulse (using a series of rx gates) then another set of measurements.

")\n",
"\n",
"\n",
"# template_circuit, samplex = build(transpiled_circuit)\n",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I assume you meant to delete this line? Since this example doesn't use samplex.

Comment on lines +164 to +168
"# program.append_samplex_item(\n",
"# template_circuit_ps,\n",
"# samplex=samplex,\n",
"# shape=(shape,)\n",
"# )\n",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same as above, this example doesn't use samplex.

"id": "6b460888",
"metadata": {},
"source": [
"These keys correspond to the active and spectator qubits before the `rx` instructions (`meas` and `spec`) and after the `rx` instructions (`meas_ps` and `spec_ps`). Each of these is an array of arrays based on the number of shots, randomizations, and qubits. In this case, the shape is (1000, 4).\n",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There are no randomizations in this example. There was also an unused shots_per_randomization variable in the code block.

"\n",
"## Create postselection mask\n",
"\n",
"From these measurements, you can create a mask using the `PostSelector` class from `qiskit-addon-utils`. This mask is a boolean array where each shot is marked as either `True` or `False` based on one of two postselection strategies. The first strategy, `node`, uses qubit information to decide whether a measurement shot should be discarded &mdash; and the second, `edge`, uses nearest-neighbor connectivity information to make this decision."
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"From these measurements, you can create a mask using the `PostSelector` class from `qiskit-addon-utils`. This mask is a boolean array where each shot is marked as either `True` or `False` based on one of two postselection strategies. The first strategy, `node`, uses qubit information to decide whether a measurement shot should be discarded &mdash; and the second, `edge`, uses nearest-neighbor connectivity information to make this decision."
"From these measurements, you can create a mask using the [`PostSelector`](https://qiskit.github.io/qiskit-addon-utils/apidocs/qiskit_addon_utils.noise_management.html#qiskit_addon_utils.noise_management.PostSelector) class from `qiskit-addon-utils`. This mask is a boolean array where each shot is marked as either `True` or `False` based on one of two postselection strategies. The first strategy, `node`, uses qubit information to decide whether a measurement shot should be discarded &mdash; and the second, `edge`, uses nearest-neighbor connectivity information to make this decision."

],
"source": [
"mask = mask_node & mask_edge\n",
"print(f\"The combined mask for first twirl instance: {mask[0]}\")\n",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You're not doing any twirling here, right?

Comment on lines +337 to +338
"Distance before postselection: 0.94225\n",
"Distance before after-selection: 0.935374149659864\n"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit - I think it'd be more impactful to show a graph rather than text. But not required if too much work.

Comment on lines +382 to +386
"## Next steps\n",
"\n",
"<Admonition type=\"tip\" title=\"Recommendations\">\n",
" - Understand how to incorporate [noise learning](/docs/guides/noise-learning) into a quantum workload.\n",
" - Read through other available [error mitigation and suppression](/docs/guides/error-mitigation-and-suppression-techniques) techniques.\n",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think it's also worth pointing people to this error detection tutorial: https://quantum.cloud.ibm.com/docs/en/tutorials/ghz-spacetime-codes
which does error detection and (implied) post selection, as a different type of post selection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Add a new page on post selection

3 participants