Skip to content

Upload nonlinear amplitude transformation demo - #1738

Open
drdren wants to merge 89 commits into
masterfrom
dren-nonlinear-QSVT
Open

drdren wants to merge 89 commits into
masterfrom
dren-nonlinear-QSVT

Conversation

@drdren

@drdren drdren commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

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:

Summary:

Relevant references:

Possible Drawbacks:

Related GitHub Issues:


If you are writing a demonstration, please answer these questions to facilitate the marketing process.

  • GOALS — Why are we working on this now?

    Eg. Promote a new PL feature or show a PL implementation of a recent paper.

  • AUDIENCE — Who is this for?

    Eg. Chemistry researchers, PL educators, beginners in quantum computing.

  • KEYWORDS — What words should be included in the marketing post?

  • Which of the following types of documentation is most similar to your file?
    (more details here)

  • Tutorial
  • [ X] Demo
  • How-to

@drdren
drdren requested review from a team as code owners April 8, 2026 16:52
@github-actions

github-actions Bot commented Apr 8, 2026

Copy link
Copy Markdown

👋 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!

@drdren drdren left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Try to fix pip install

@drdren drdren left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Remove pip install

@drdren drdren left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Add pip install pyqsp

Comment on lines +197 to +210
def MultiControlledZ(wires, control_values=None):
if control_values is None:
control_values = [0] * (len(wires) - 1)
qml.ctrl(qml.Z(wires=wires[-1]),
control=wires[:-1],
control_values=control_values)

# R_gate implements the reflection R used in the block construction.
def R(wires):
assert len(wires) % 2 == 1
n = len(wires)//2
qml.PauliX(wires=wires[0])
MultiControlledZ(wires=wires[1:n+1]+[wires[0]])
qml.PauliX(wires=wires[0])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Take a look to qml.Reflection(wires)
That should replace all this code 😄

Comment on lines +440 to +445
def ProjCtrlPhaseShift(control_wires, target_wire, phi):
qml.MultiControlledX(wires=control_wires + target_wire,
control_values=[0] * len(control_wires))
qml.RZ(phi = 2 * phi, wires=target_wire)
qml.MultiControlledX(wires=control_wires + target_wire,
control_values=[0] * len(control_wires))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this qml.PCPhase?

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 don't think they are equivalent. I tested it numerically and they both apply different phase patterns.

@drdren drdren left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Remove pip install pyqsp

@github-actions

github-actions Bot commented Apr 17, 2026 •

Copy link
Copy Markdown

Your preview is ready 🎉!

You can view your changes here

Deployed at: 2026-11-13 19:36:35 UTC

@drdren drdren left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Update figures

@drdren drdren left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fix figure formatting

Co-authored-by: drdren <104710745+drdren@users.noreply.github.com>
Co-authored-by: drdren <104710745+drdren@users.noreply.github.com>
control_values=[0])(wires=wires[:n], *args, **kwargs)

# Adjoint of U on the data register controlled on ancilla B=0.
def Uc_adj(base, wires, *args, **kwargs):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just leaving an on-the-fly comment: Is it necessary to manually define the adjoint of all the operators? We have qp.adjoint for this

#

qp.draw_mpl(be_circuit)(feature_vector, main_wires, ancilla_wires)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if you add

plt.show()

then in the deployment we clean the output

Image

This branch has not been deployed

No deployments
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.

5 participants