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

Update block encoding demo #1080

Merged
merged 6 commits into from
Apr 26, 2024
Merged

Update block encoding demo #1080

merged 6 commits into from
Apr 26, 2024

Conversation

soranjh
Copy link
Contributor

@soranjh soranjh commented Apr 24, 2024

Update the demo on block encoding with matrix access oracles to:

  1. Add the newly implemented qml.FABLE to the demo.
  2. Correct an equation to allow block encoding 2 x 2 matrices.

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!

Copy link

github-actions bot commented Apr 24, 2024

Thank you for opening this pull request.

You can find the built site at this link.

Deployment Info:

  • Pull Request ID: 1080
  • Deployment SHA: 83a93c54770f0d798356c964062c55f84529fa75
    (The Deployment SHA refers to the latest commit hash the docs were built from)

Note: It may take several minutes for updates to this pull request to be reflected on the deployed site.

Copy link
Contributor

@austingmhuang austingmhuang left a comment

Choose a reason for hiding this comment

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

Looks good @soranjh! Do you want to refactor this demo cause there are some lines

e.g. wire_order = ancilla_wires + wires_i[::-1] + wires_j[::-1]
M = len(A) * qml.matrix(circuit,wire_order=wire_order)().real[0:len(A),0:len(A)]

in the code that don't work quite the same when using the template instead. With the template, we don't need to set the wire_order this way, just need
M = len(A) * qml.matrix(circuit)().real[0 : len(A), 0 : len(A)]

There's also code like
wire_map = {control_index : wire for control_index, wire in enumerate(wires_j + wires_i)} that can be replaced with what's in the template
wire_map = dict(enumerate(wires_j + wires_i))

Not a super big deal and the demo works as is though.

@soranjh
Copy link
Contributor Author

soranjh commented Apr 25, 2024

Looks good @soranjh! Do you want to refactor this demo cause there are some lines

e.g. wire_order = ancilla_wires + wires_i[::-1] + wires_j[::-1] M = len(A) * qml.matrix(circuit,wire_order=wire_order)().real[0:len(A),0:len(A)]

in the code that don't work quite the same when using the template instead. With the template, we don't need to set the wire_order this way, just need M = len(A) * qml.matrix(circuit)().real[0 : len(A), 0 : len(A)]

There's also code like wire_map = {control_index : wire for control_index, wire in enumerate(wires_j + wires_i)} that can be replaced with what's in the template wire_map = dict(enumerate(wires_j + wires_i))

Not a super big deal and the demo works as is though.

Thanks @austingmhuang, the demo codes are a bit verbose for educational purposes, so no need to change them if they run correctly.

Copy link
Contributor

@Jaybsoni Jaybsoni left a comment

Choose a reason for hiding this comment

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

Nice! Happy to approve 👍🏼

Just two comments:

  • We could optionally show a circuit using qml.Fable and then draw the circuit using my_circuit.tape.expand().draw() to show the decomposed operation
  • Just make sure that the link to the Fable template works well once the CI builds

@soranjh
Copy link
Contributor Author

soranjh commented Apr 26, 2024

  • We could optionally show a circuit using qml.Fable and then draw the circuit using my_circuit.tape.expand().draw() to show the decomposed operation

Checked and confirmed locally but adding it here breaks the current nice workflow.

  • Just make sure that the link to the Fable template works well once the CI builds

Confirmed with @KetpuntoG that it will work when merged.

@KetpuntoG KetpuntoG merged commit 65aeaf3 into dev Apr 26, 2024
10 checks passed
@KetpuntoG KetpuntoG deleted the add_fable_template branch April 26, 2024 18:17
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.

4 participants