Skip to content

Commit 99ff911

Browse files
authored
Enable reference docs for rotation synthesis (#1794)
- enable reference doc generation for the `rotation_synthesis` module. - Fix some latex issues, including some places where sphinx/mathjax is more sensitive Fixes #1767
1 parent acea250 commit 99ff911

8 files changed

Lines changed: 19 additions & 10 deletions

File tree

dev_tools/qualtran_dev_tools/make_reference_docs/_make.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373
'qualtran.linalg',
7474
'qualtran._infra.gate_with_registers.GateWithRegisters',
7575
'qualtran.resource_counting.t_counts_from_sigma',
76-
'qualtran.rotation_synthesis', # TODO: https://github.com/quantumlib/Qualtran/issues/1767
7776
]
7877
MINIMAL = True
7978

qualtran/rotation_synthesis/channels/_channel.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@ class UnitaryChannel(Channel):
4444
r"""A Unitary operation.
4545
4646
The unitary matrix of an $SU(2)$ matrix is defined with two complex numbers $u, v$ as
47+
4748
$$
4849
\begin{bmatrix}
4950
u & -v^*\\
5051
v & u^*
5152
\end{bmatrix}
5253
$$
5354
for clifford+T unitarys the matrix can be written as
55+
5456
$$
5557
\frac{1}{\sqrt{2(2+\sqrt{2})^n}}
5658
\begin{bmatrix}
@@ -203,11 +205,13 @@ class ProjectiveChannel(Channel):
203205
This channel applies the following circuit where $V$ is the `rotation` channel and $C$ is the
204206
correction channel.
205207
208+
```
206209
q: ─────────@───V───@───────Y───C───
207210
│ │ ║ ║
208211
ancilla: ───X───────X───M───╫───╫───
209212
║ ║ ║
210213
m: ═════════════════════@═══^═══^═══
214+
```
211215
212216
Attributes:
213217
rotation: This first half of the channel (i.e. $V$).

qualtran/rotation_synthesis/lattice/_ipe.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def enumerate_1d(
3535
) -> Iterator[rings.ZSqrt2]:
3636
r"""Yield points $p \in \mathbb{Z}[\sqrt{2}]$ contained in the region.
3737
38-
Point $p$ belongs to the region iff $p \in inter$ and $p^sbullet \in \texit{comp_inter}$
38+
Point $p$ belongs to the region iff $p \in \textit{inter}$ and $p^\bullet \in \textit{comp_inter}$
3939
4040
Follows section 4 of https://arxiv.org/abs/1403.2975
4141
@@ -84,7 +84,7 @@ def enumerate_1d(
8484
def enumerate_upright(
8585
r: _geometry.Rectangle, comp_r: _geometry.Rectangle, config: mc.MathConfig
8686
) -> Iterator[rings.ZW]:
87-
r"""Yield $p \in \mathbb{Z}[e^{i \pi/4}]$ such that $p \in r$ and $p^\sbullet \in \textit{comp_r}$
87+
r"""Yield $p \in \mathbb{Z}[e^{i \pi/4}]$ such that $p \in r$ and $p^\bullet \in \textit{comp_r}$
8888
8989
Follows section 5 of https://arxiv.org/abs/1403.2975
9090
@@ -94,7 +94,7 @@ def enumerate_upright(
9494
config: The MathConfig to use.
9595
9696
Yields:
97-
Points $p$ such that $p \in r$ and $p^\sbullet \in \textit{comp_r}$
97+
Points $p$ such that $p \in r$ and $p^\bullet \in \textit{comp_r}$
9898
"""
9999
second_part = tuple(enumerate_1d(r.y_bounds, comp_r.y_bounds, config))
100100
for a in enumerate_1d(r.x_bounds, comp_r.x_bounds, config):

qualtran/rotation_synthesis/lattice/_state.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def followed_by(self, other: "GridOperatorAction") -> "GridOperatorAction":
5656
class SelingerState:
5757
r"""A state is a region in space defined by two ellipses (A, B).
5858
59-
A point $p$ belongs to the region iff $p \in A$ and $p^\bullet in B$. Where
59+
A point $p$ belongs to the region iff $p \in A$ and $p^\bullet \in B$. Where
6060
$p^\bullet$ is the sqrt2-conjugate of $p$.
6161
6262
Attributes:

qualtran/rotation_synthesis/matrix/_clifford_t_repr.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,17 @@ def _xz_sequence(
8282
def to_sequence(matrix: _su2_ct.SU2CliffordT, fmt: str = 'xyz') -> tuple[str, ...]:
8383
r"""Returns a sequence of Clifford+T that produces the given matrix.
8484
85+
Allowable format strings are
86+
- 'xyz' uses Tx, Ty, Tz gates.
87+
- 'xz' uses $Tx, Tz, Tx^\dagger, Tz^\dagger$
88+
8589
Args:
8690
matrix: The matrix to represent.
87-
fmt: A string from the set {'xz', 'xyz'} representing the allowed T gates where
88-
- 'xyz' uses Tx, Ty, Tz gates.
89-
- 'xz' uses $Tx, Tz, Tx^\dagger, Tz^\dagger$
91+
fmt: A string from the set {'xz', 'xyz'} representing the allowed T gates described above.
92+
9093
Returns:
9194
A tuple of strings representing the gates.
95+
9296
Raises:
9397
ValueError: If `fmt` is not supported.
9498
"""

qualtran/rotation_synthesis/matrix/_su2_ct.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class SU2CliffordT:
3737
Where $u, v \in \mathbb{Z}[e^{i \pi/4}]$ and $n$ is the needed number of $T$ gates with a
3838
determinant $\frac{1}{2(2+\sqrt{2})^n} (|u|^2 + |v|^2) = 1$.
3939
40-
Instances of this class represent the matrix [[u, -v^*], [v, u^*]] with the scaling factor
40+
Instances of this class represent the matrix `[[u, -v^*], [v, u^*]]` with the scaling factor
4141
being implicit.
4242
4343
Attributes:

qualtran/rotation_synthesis/protocols/_fallback.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,13 @@ class Fallback(_protocol.ApproxProblem):
113113
r"""Approximate a Z-rotation with a fallback channel.
114114
115115
Approximate the $Rz(2\theta)$ with the channel
116+
```
116117
q: ─────────@───V───@───────Y───C───
117118
│ │ ║ ║
118119
ancilla: ───X───────X───M───╫───╫───
119120
║ ║ ║
120121
m: ═════════════════════@═══^═══^═══
122+
```
121123
122124
where a cheap (in terms of T gates) rotation `V` is applied and then depending on
123125
the result of the measurement we may need to apply an expensive correction. The problem

qualtran/rotation_synthesis/relative_norm/_clifford_t.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class CliffordTRelativeNormSolver:
5656
r"""A relative norm solver for the Clifford+T Gateset.
5757
5858
The class implements the relative norm solver described in section Algorithm 2 in
59-
https://arxiv.org/abs/2203.10064. For Clifford+T, $O_K = \mathbb{Z}[\zsqrt{2}]$ and
59+
https://arxiv.org/abs/2203.10064. For Clifford+T, $O_K = \mathbb{Z}[\sqrt{2}]$ and
6060
$O_L = \mathbb{Z}[e^{i pi/4}]$.
6161
"""
6262

0 commit comments

Comments
 (0)