Skip to content

Document store directive#5129

Open
beckykd wants to merge 29 commits into
mainfrom
bd-store-directive
Open

Document store directive#5129
beckykd wants to merge 29 commits into
mainfrom
bd-store-directive

Conversation

@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

@beckykd beckykd marked this pull request as ready for review May 22, 2026 17:56
@beckykd beckykd requested a review from a team May 22, 2026 17:56
@qiskit-bot
Copy link
Copy Markdown
Contributor

One or more of the following people are relevant to this code:

abbycross
abbycross previously approved these changes May 22, 2026
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.

I did a copyedit scan. Does anyone need to look with a technical eye? I know Becky's already been working closely with the SMEs on this

@beckykd
Copy link
Copy Markdown
Collaborator Author

beckykd commented May 22, 2026

Does anyone need to look with a technical eye

I'll share it with some experts!

Comment thread docs/guides/classical-feedforward-and-control-flow.ipynb Outdated
Comment on lines +307 to +315
"```python\n",
"# Store the negation in temporary variable\n",
"qc.store(temp, expr.bit_not(creg))\n",
"\n",
"# Now compute parity using the stored result\n",
"parity = expr.bit_xor(\n",
" expr.bit_xor(temp[0], temp[1]), temp[2]\n",
")\n",
"```"
Copy link
Copy Markdown
Member

@francabrera francabrera May 25, 2026

Choose a reason for hiding this comment

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

I would rather add this to a code cell type instead of within the markdown?

and I would put a more complete example like:

from qiskit.circuit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit.circuit.classical import expr, types

qregs = QuantumRegister(4, "q")
creg  = ClassicalRegister(3, "c")
qc    = QuantumCircuit(qregs, creg)

# Declare temp as a Uint(3) variable to hold the negation of creg
temp = qc.add_var("temp", expr.lift(0, types.Uint(3)))

qc.h([0, 1, 2])
qc.measure([0, 1, 2], creg)

# Store bit-NOT of the full 3-bit register in a single parallel step
qc.store(temp, expr.bit_not(creg))

# Compute parity of the stored result using bit-indexed XOR
parity = expr.bit_xor(
    expr.bit_xor(expr.index(temp, 0), expr.index(temp, 1)),
    expr.index(temp, 2),
)

# Flip q3 if parity of ~creg is 1
with qc.if_test(parity):
    qc.x(3)

qc.measure([0, 1, 2], creg)

qc.draw("mpl")

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Adding code from our external discussion.

Comment on lines +196 to +218
"id": "56f98db3-99b3-49d4-b7a9-3d9fd8278890",
"metadata": {},
"source": [
"## `Store`\n",
"\n",
"With `qiskit-ibm-runtime` v0.47.0 or later, you can use the [`store`](/docs/api/qiskit/circuit#store) instruction to save the result of a classical expression, if that expression will be used repeatedly. Operations are automatically parallelized, making your code significantly more efficient at runtime.\n",
"\n",
"For example, it is more natural and performant to write $B[0]^B[1]^B[2]...,$ where $B = ~A$, than $(~A[0])^(~A[1])^(~A[2])....$  The former can be written in Qiskit as the following:\n",
"\n",
"```python\n",
"# Store the negation in temporary variable\n",
"qc.store(temp, expr.bit_not(creg))\n",
"\n",
"# Now compute parity using the stored result\n",
"parity = expr.bit_xor(\n",
" expr.bit_xor(temp[0], temp[1]), temp[2]\n",
")\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "0de5ec21-2b09-4692-82d3-58a469b249e4",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This was not mentioned in the pages to review in the description of the PR, so maybe was introduced by mistake, but this is not the right place to add this content as Store is circuit-building related and not execution.

(in addition to maintenance debt introducing by duplicating the content)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@francabrera - Jessie had me move some of the information here because the first section is Qiskit only and this page is for Qiskit Runtime. I can cut down the information here, but I think it would be good to mention it here.

@github-project-automation github-project-automation Bot moved this to In Review in Docs Planning May 25, 2026
"\n",
" Other notes:\n",
" - Gate twirling can be applied to dynamic circuits, but only to gates not inside conditional blocks. Measurement twirling can only be applied to terminal measurements.\n",
" - Gate twirling can be applied to dynamic circuits, but only to gates not inside conditional blocks.\n",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this file is not rendering in the preview

Co-authored-by: Fran Cabrera <francabrera@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

5 participants