Skip to content

Commit f50f021

Browse files
committed
update example
1 parent 2d57352 commit f50f021

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

pennylane/transforms/decompositions/gridsynth.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,42 @@ def gridsynth(tape, *, epsilon, ppr_basis):
2929
3030
Args:
3131
tape (QNode): A quantum circuit.
32-
epsilon (float): The maximum permissible operator norm error per rotation gate.
33-
ppr_basis (bool): If True, decompose into the PPR basis. If False, decompose into the Clifford+T basis. Note: Simulating with ``ppr_basis=True`` is currently not supported.
32+
epsilon (float): The maximum permissible operator norm error per rotation gate. Defaults to ``1e-4``.
33+
ppr_basis (bool): If True, decompose into the PPR basis. If False, decompose into the Clifford+T basis. Defaults to ``False``.
3434
3535
**Example**
3636
37-
.. code-block:: python
37+
.. code-block:: python # doctest: +SKIP
3838
3939
qml.capture.enable()
40-
@qml.qjit
41-
@partial(qml.transforms.gridsynth, epsilon=1e-5)
40+
4241
@qml.qnode(qml.device("lightning.qubit", wires=1))
4342
def circuit(x):
4443
qml.Hadamard(0)
4544
qml.RZ(x, 0)
4645
qml.PhaseShift(x * 0.2, 0)
4746
return qml.state()
4847
49-
>>> circuit(1.1) # doctest: +SKIP
48+
result = circuit(1.1)
49+
gridsynth_circuit = qml.transforms.gridsynth(circuit, epsilon=1e-4)
50+
qjitted_circuit = qml.qjit(decomposed_circuit)
51+
approx = qjitted_circuit(1.1)
52+
53+
>>> result # doctest: +SKIP
54+
[0.60282587-0.36959568j 0.5076395 +0.49224195j]
55+
>>> approx # doctest: +SKIP
5056
[0.6028324 -0.3695921j 0.50763281+0.49224355j]
5157
58+
5259
.. warning::
5360
5461
Using an ``epsilon`` value smaller than ``1e-7`` may lead to inaccurate results,
5562
due to potential integer overflow in the solver.
5663
64+
.. warning::
65+
66+
Note: Simulating with ``ppr_basis=True`` is currently not supported.
67+
5768
"""
5869

5970
raise NotImplementedError( # pragma: no cover

0 commit comments

Comments
 (0)