From 1bafb03527ea77c1e99ae23c45532a9b02a92600 Mon Sep 17 00:00:00 2001 From: Ed Younis Date: Thu, 12 Sep 2024 11:49:32 -0400 Subject: [PATCH] Update --- docs/guides/customgate.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/guides/customgate.md b/docs/guides/customgate.md index dff66287..eca66e8c 100644 --- a/docs/guides/customgate.md +++ b/docs/guides/customgate.md @@ -128,17 +128,17 @@ class MyGateTensor(Gate): ## Utilizing Helper Classes -BQSKit provides some helper classes to simplify the process of defining gates. In the first example of this guide, we used the [`ConstantGate`](https://bqskit.readthedocs.io/en/latest/source/autogen/bqskit.ir.ConstantGate.html#bqskit.ir.ConstantGate) and [`QubitGate`](https://bqskit.readthedocs.io/en/latest/source/autogen/bqskit.ir.QubitGate.html#bqskit.ir.QubitGate) helper classes. To use these helper subclasses, we will subclass them instead of [`Gate`](https://bqskit.readthedocs.io/en/latest/source/autogen/bqskit.ir.Gate.html#bqskit.ir.Gate). The following are the available helper classes: +BQSKit provides some helper classes to simplify the process of defining gates. In the first example of this guide, we used the [`ConstantGate`](https://bqskit.readthedocs.io/en/latest/source/autogen/bqskit.ir.gates.ConstantGate.html#bqskit.ir.gates.ConstantGate) and [`QubitGate`](https://bqskit.readthedocs.io/en/latest/source/autogen/bqskit.ir.gates.QubitGate.html#bqskit.ir.gates.QubitGate) helper classes. To use these helper subclasses, we will subclass them instead of [`Gate`](https://bqskit.readthedocs.io/en/latest/source/autogen/bqskit.ir.Gate.html#bqskit.ir.Gate). The following are the available helper classes: - [`ConstantGate`](https://bqskit.readthedocs.io/en/latest/source/autogen/bqskit.ir.gates.ConstantGate.html#bqskit.ir.gates.ConstantGate): A gate that has a fixed unitary matrix with no parameters. This will automatically set `_num_params` to 0, and swap the `get_unitary` method for a `_utry` attribute. Additionally, these gates have the trivial differentiable implementations provided. - [`QubitGate`](https://bqskit.readthedocs.io/en/latest/source/autogen/bqskit.ir.gates.QubitGate.html#bqskit.ir.gates.QubitGate): A gate that acts only on qubits. This defines `_radixes` to be all `2`s. -- [`QutritGate`](https://bqskit.readthedocs.io/en/latest/source/autogen/bqskit.ir.gates.QutritGate.html#bqskit.ir.gates.QutritGate): A gate that acts on qutrits. This defines `_radixes` to be all `3`s. +- [`QutritGate`](https://bqskit.readthedocs.io/en/latest/source/autogen/bqskit.ir.gates.QutritGate.html#bqskit.ir.gates.QutritGate): A gate that acts only on qutrits. This defines `_radixes` to be all `3`s. - [`QuditGate`](https://bqskit.readthedocs.io/en/latest/source/autogen/bqskit.ir.gates.QuditGate.html#bqskit.ir.gates.QuditGate): A gate that acts on qudits of the same radix. This swaps the `_radixes` requirement for a required `_radix` attribute. This is useful for gates that act on qudits of the same radix, but not necessarily only qubits or qutrits. - [`ComposedGate`](https://bqskit.readthedocs.io/en/latest/source/autogen/bqskit.ir.gates.ComposedGate.html#bqskit.ir.gates.ComposedGate): A gate that is composed of other gates. This provides methods to dynamically determine if the gate is differentiable or optimizable via other means. ## Differentiable Gates -If you are implementing a parameterized gate, you may want to make it differentiable. By making a gate differentiable, you allow it to be used by out instantiation engine. In turn, this allows synthesis and other algorithms to work more easily with these gates. To do this, you will need to additionally subclass [`DifferentiableUnitary`](https://bqskit.readthedocs.io/en/latest/source/autogen/bqskit.qis.DifferentiableUnitary.html) and implement the [`get_grad`](https://bqskit.readthedocs.io/en/latest/source/autogen/bqskit.qis.DifferentiableUnitary.get_grad.html#bqskit.qis.DifferentiableUnitary.get_grad) method. `ConstantGate`s are trivially differentiable, as they have no parameters. +If you are implementing a parameterized gate, you may want to make it differentiable. By making a gate differentiable, you allow it to be used by BQSKit's instantiation engine. In turn, this allows synthesis and other algorithms to work more easily with these gates. To do this, you will need to additionally subclass [`DifferentiableUnitary`](https://bqskit.readthedocs.io/en/latest/source/autogen/bqskit.qis.DifferentiableUnitary.html) and implement the [`get_grad`](https://bqskit.readthedocs.io/en/latest/source/autogen/bqskit.qis.DifferentiableUnitary.get_grad.html#bqskit.qis.DifferentiableUnitary.get_grad) method. `ConstantGate`s are trivially differentiable, as they have no parameters. Most of the time, the [`get_unitary_and_grad`](https://bqskit.readthedocs.io/en/latest/source/autogen/bqskit.qis.DifferentiableUnitary.get_unitary_and_grad.html#bqskit.qis.DifferentiableUnitary.get_unitary_and_grad) method is called by other parts of BQSKit, since both the unitary and gradient are typically needed at the same time. For most gates, computing them at the same time can allow for greater efficiency, since the unitary and gradient can share some computations.