Skip to content

Commit 4986a3a

Browse files
KetpuntoGobliviateandsurrenderwilljmaxisaacdevlugtsoranjh
authored
[WIP] Adding `qml.OutPoly' (#6320)
To do: - [x] Final review - [x] Add thumbnail - [x] Add changeling In this PR we add `qml.OutPoly`. An operator that allows to apply arbitrary polynomials on quantum registers. Example where we want to create the operator: $$U|x\rangle |y\rangle |0\rangle = |x\rangle |y\rangle |x^2 + y\rangle$$ ```python import pennylane as qml x_wires = [0, 1, 2] y_wires = [3, 4, 5] output_wires = [6, 7, 8] def f(x, y): return x ** 2 + y @qml.qnode(qml.device("default.qubit", shots = 1)) def circuit(): # loading values for x and y qml.BasisEmbedding(2, wires=x_wires) qml.BasisEmbedding(2 , wires=y_wires) # applying the polynomial qml.OutPoly(f, input_registers = [x_wires, y_wires], output_wires=output_wires) return qml.sample(wires=output_wires) print(circuit()) ``` **Context:** This operator is born of the quantum arithmetic project **Benefits:** complete flexibility for the user to create new arithmetic operators [[sc-72629](https://app.shortcut.com/xanaduai/story/72629/support-polynomial-arithmetic)] --------- Co-authored-by: Utkarsh <utkarshazad98@gmail.com> Co-authored-by: Will <wmaxwell90@gmail.com> Co-authored-by: Isaac De Vlugt <34751083+isaacdevlugt@users.noreply.github.com> Co-authored-by: soranjh <40344468+soranjh@users.noreply.github.com>
1 parent 630cf78 commit 4986a3a

File tree

8 files changed

+716
-1
lines changed

8 files changed

+716
-1
lines changed
50.4 KB
Loading

‎doc/introduction/templates.rst‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ as addition, multiplication and exponentiation.
158158
:description: :doc:`IntegerComparator <../code/api/pennylane.IntegerComparator>`
159159
:figure: _static/templates/arithmetic/integercomparator.png
160160

161+
.. gallery-item::
162+
:description: :doc:`OutPoly <../code/api/pennylane.OutPoly>`
163+
:figure: _static/templates/arithmetic/outpoly.png
164+
161165

162166
.. raw:: html
163167

‎doc/releases/changelog-dev.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@
7979

8080
<h4>Calculating Polynomials 🔢</h4>
8181

82+
* `qml.OutPoly` template is added to implement polynomial arithmetic.
83+
[(#6320)](https://github.com/PennyLaneAI/pennylane/pull/6320)
84+
8285
<h4>Readout Noise 📠</h4>
8386

8487
* Support for applying readout errors to a quantum circuit has been added via the ``NoiseModel`` class

‎pennylane/templates/subroutines/__init__.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,4 @@
5151
from .out_multiplier import OutMultiplier
5252
from .out_adder import OutAdder
5353
from .mod_exp import ModExp
54+
from .out_poly import OutPoly

0 commit comments

Comments
 (0)