PennyLaneAI / qml

Introductions to key concepts in quantum programming, as well as tutorials and implementations from cutting-edge quantum computing research.
https://pennylane.ai/qml
Apache License 2.0
517 stars 183 forks source link

Update block encoding demo #1080

Closed soranjh closed 3 months ago

soranjh commented 3 months ago

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.
github-actions[bot] commented 3 months ago

👋 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[bot] commented 3 months ago

Thank you for opening this pull request.

You can find the built site at this link.

Deployment Info:

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

soranjh commented 3 months ago

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.

soranjh commented 3 months ago
  • 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.