Skip to content

IQP demo update#1672

Open
gabrielasd wants to merge 6 commits intomasterfrom
iqp-demo-update
Open

IQP demo update#1672
gabrielasd wants to merge 6 commits intomasterfrom
iqp-demo-update

Conversation

@gabrielasd
Copy link

Before submitting

Please complete the following checklist when submitting a PR:

  • Ensure that your tutorial executes correctly, and conforms to the
    guidelines specified in the README.

  • Remember to do a grammar check of the content you include.

  • All tutorials conform to
    PEP8 standards.
    To auto format files, simply pip install black, and then
    run black -l 100 path/to/file.py.

When all the above are checked, delete everything above the dashed
line and fill in the pull request template.


Title: Updating the IQPopt demo after the template and estimator function were added to PennyLane in the v0.44.0 release.

Summary:

Related GitHub Issues:

@github-actions
Copy link

👋 Hey, looks like you've updated some demos!

🐘 Don't forget to update the dateOfLastModification in the associated metadata files so your changes are reflected in Glass Onion (search and recommendations).

Please hide this comment once the field(s) are updated. Thanks!

@github-actions
Copy link

github-actions bot commented Jan 22, 2026

Your preview is ready 🎉!

You can view your changes here

Deployed at: 2026-01-26 16:24:08 UTC

Comment on lines 113 to 131
@@ -134,15 +128,7 @@ def penn_iqp_gates(params: np.ndarray, gates: list, n_qubits: int):
n_qubits (int): The total number of qubits in the circuit.
"""

for i in range(n_qubits):
qml.Hadamard(i)

for par, gate in zip(params, gates):
for gen in gate:
qml.MultiRZ(2*par, wires=gen)

for i in range(n_qubits):
qml.Hadamard(i)
qml.IQP(weights=params, num_wires=n_qubits, pattern=gates)
Copy link
Author

Choose a reason for hiding this comment

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

@josh I'd appreciate your opinion on the comments I'll be leaving through this file :)

I think this block of code where penn_iqp_gates is defined could be removed now that the qml.IQP template is available. And then in the function penn_iqp_circuit that is defined bellow qml.IQP could be used directly.

Copy link
Member

Choose a reason for hiding this comment

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

💯 agree!

# where :math:`s` is the number of samples.
#
# Let's see now how to use the IQPopt package to calculate expectation values, based on the same
# Let's see now how to use the :func:`~pennylane.qnn.iqp_expval` function in PennyLane to calculate expectation values, based on the same
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be useful to mention that this is implemented in IQPopt as .op_expval as well

Copy link
Author

Choose a reason for hiding this comment

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

I've added a comment about this as part of this same sentence here 2b7e104, but I'm happy to edit further (e.g. make it a separate note with sphinx's note directive)

@gabrielasd gabrielasd marked this pull request as ready for review January 26, 2026 16:18
@gabrielasd gabrielasd requested review from a team as code owners January 26, 2026 16:18
@Alex-Preciado Alex-Preciado removed the request for review from a team January 29, 2026 05:09
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.

3 participants