SlowGuess/NeurIPS_2023_OCR huggingface dataset:
For the variable  $\pmb{L} \sim \mathcal{N}(\bar{\pmb{L}}, \sigma^2\pmb{I})$ , we have  $\pmb{Q}\pmb{L} \sim \mathcal{N}(\pmb{Q}\bar{\pmb{L}}, \pmb{Q}(\sigma^2\pmb{I})\pmb{Q}^\top) = \mathcal{N}(\pmb{Q}\bar{\pmb{L}}, \sigma^2\pmb{I})$ . That is,
$$
\mathcal {N} (\boldsymbol {L} | \bar {\boldsymbol {L}}, \sigma^ {2} \boldsymbol {I}) = \mathcal {N} (\boldsymbol {Q L} | \boldsymbol {Q} \bar {\boldsymbol {L}}, \sigma^ {2} \boldsymbol {I}). \tag {11}
$$
For the transition probability  $p(L_{t - 1}|L_t,F_t,A)$  , we have
$$
\begin{array}{l} p \left(\boldsymbol {Q} \boldsymbol {L} _ {t - 1} \mid \boldsymbol {Q} \boldsymbol {L} _ {t}, \boldsymbol {F} _ {t}, \boldsymbol {A}\right) = \mathcal {N} \left(\boldsymbol {Q} \boldsymbol {L} _ {t - 1} \mid a _ {t} \left(\boldsymbol {Q} \boldsymbol {L} _ {t} - b _ {t} \hat {\epsilon} _ {\boldsymbol {L}} \left(\boldsymbol {Q} \boldsymbol {L} _ {t}, \boldsymbol {F} _ {t}, \boldsymbol {A}, t\right)\right), \sigma_ {t} ^ {2} \boldsymbol {I}\right) \\ = \mathcal {N} (\boldsymbol {Q} \boldsymbol {L} _ {t - 1} | a _ {t} (\boldsymbol {Q} \boldsymbol {L} _ {t} - b _ {t} \boldsymbol {Q} \hat {\epsilon} _ {\boldsymbol {L}} (\boldsymbol {L} _ {t}, \boldsymbol {F} _ {t}, \boldsymbol {A}, t)), \sigma_ {t} ^ {2} \boldsymbol {I}) \quad (\text {O (3) - e q u i v a r i a n t} \hat {\epsilon} _ {\boldsymbol {L}}) \\ = \mathcal {N} (\boldsymbol {Q} \boldsymbol {L} _ {t - 1} | \boldsymbol {Q} \left(a _ {t} \left(\boldsymbol {L} _ {t} - b _ {t} \hat {\epsilon} _ {\boldsymbol {L}} \left(\boldsymbol {L} _ {t}, \boldsymbol {F} _ {t}, \boldsymbol {A}, t\right)\right), \sigma_ {t} ^ {2} \boldsymbol {I}\right) \\ = \mathcal {N} \left(\boldsymbol {L} _ {t - 1} \mid a _ {t} \left(\boldsymbol {L} _ {t} - b _ {t} \hat {\epsilon} _ {\boldsymbol {L}} \left(\boldsymbol {L} _ {t}, \boldsymbol {F} _ {t}, \boldsymbol {A}, t\right), \sigma_ {t} ^ {2} \boldsymbol {I}\right) \right. \tag {Eq. (11)} \\ = p \left(\boldsymbol {L} _ {t - 1} \mid \boldsymbol {L} _ {t}, \boldsymbol {F} _ {t}, \boldsymbol {A}\right). \\ \end{array}
$$
As the transition is  $O(3)$ -equivariant and the prior distribution  $\mathcal{N}(0, I)$  is  $O(3)$ -invariant, we prove that the marginal distribution  $p(\pmb{L}_0)$  is  $O(3)$ -invariant based on lemma 1.
A.2 Proof of Proposition 2
Let  $\mathcal{N}_w(\mu, \sigma^2 I)$  denote the wrapped normal distribution with mean  $\mu$ , variance  $\sigma^2$  and period 1. We first provide the following lemma.
Lemma 3. If the denoising term  $\hat{\epsilon}_{\pmb{F}}(\pmb{L}_t, \pmb{F}_t, \pmb{A}, t)$  is periodic translation invariant, and the transition probability can be formulated as  $p(\pmb{F}_{t-1}|\pmb{L}_t, \pmb{F}_t, \pmb{A}) = \mathcal{N}_w(\pmb{F}_{t-1}|\pmb{F}_t + u_t\hat{\epsilon}_{\pmb{F}}(\pmb{L}_t, \pmb{F}_t, \pmb{A}, t), v_t^2\pmb{I})$  where  $u_t, v_t$  are functions of  $t$ , the transition is periodic translation equivariant.
Proof. As the denoising term  $\hat{\epsilon}_{\pmb{F}}(\pmb{L}_t, \pmb{F}_t, \pmb{A}, t)$  is periodic translation invariant (for short PTI), we have  $\hat{\epsilon}_{\pmb{F}}(\pmb{L}_t, w(\pmb{F}_t + \pmb{t1}^\top), \pmb{A}, t) = \hat{\epsilon}_{\pmb{F}}(\pmb{L}_t, \pmb{F}_t, \pmb{A}, t)$ , for any translation  $t \in \mathbb{R}^3$ .
For the wrapping function  $w(\cdot)$ , we have
$$
w (a + b) = w (w (a) + b), \forall a, b \in \mathbb {R}. \tag {12}
$$
For wrapped normal distribution  $\mathcal{N}_w(\mu, \sigma^2)$  with mean  $\mu$ , variance  $\sigma^2$  and period 1, and for any  $k', k'' \in \mathbb{Z}$ , we have
$$
\begin{array}{l} \mathcal {N} _ {w} (x + k ^ {\prime} | \mu + k ^ {\prime \prime}, \sigma^ {2}) = \frac {1}{\sqrt {2 \pi} \sigma} \sum_ {k = - \infty} ^ {\infty} \exp \left(- \frac {(x + k ^ {\prime} - (\mu + k ^ {\prime \prime}) - k) ^ {2}}{2 \sigma^ {2}}\right) \\ = \frac {1}{\sqrt {2 \pi} \sigma} \sum_ {m = - \infty} ^ {\infty} \exp \left(- \frac {(x - \mu - m) ^ {2}}{2 \sigma^ {2}}\right) (m = k - k ^ {\prime} + k ^ {\prime \prime}) \\ = \mathcal {N} _ {w} (x | \mu , \sigma^ {2}) \\ \end{array}
$$
Let  $k^{\prime} = 0,k^{\prime \prime} = w(\mu) - \mu$  , we directly have
$$
\mathcal {N} _ {w} (x \mid w (\mu), \sigma^ {2}) = \mathcal {N} _ {w} (x \mid \mu , \sigma^ {2}). \tag {13}
$$
For any  $t\in \mathbb{R}$  , we have
$$
\begin{array}{l} \mathcal {N} _ {w} (x + t | \mu + t, \sigma^ {2}) = \frac {1}{\sqrt {2 \pi} \sigma} \sum_ {k = - \infty} ^ {\infty} \exp \left(- \frac {(x + t - (\mu + t) - k) ^ {2}}{2 \sigma^ {2}}\right) \\ = \frac {1}{\sqrt {2 \pi} \sigma} \sum_ {k = - \infty} ^ {\infty} \exp \left(- \frac {(x - \mu - k) ^ {2}}{2 \sigma^ {2}}\right) \\ = \mathcal {N} _ {w} (x | \mu , \sigma^ {2}). \\ \end{array}
$$
Let  $k' = w(x + t) - (x + t), k'' = w(\mu + t) - (\mu + t)$ , we have
$$
\mathcal {N} _ {w} (w (x + t) | w (\mu + t), \sigma^ {2}) = \mathcal {N} _ {w} (x + t | \mu + t, \sigma^ {2}) = \mathcal {N} _ {w} (x | \mu , \sigma^ {2}). \tag {14}
$$
For the transition probability  $p(\mathbf{F}_{t - 1}|\mathbf{L}_t,\mathbf{F}_t,\mathbf{A})$  , we have
$$
\begin{array}{l} p \left(w \left(\boldsymbol {F} _ {t - 1} + \boldsymbol {t}\right) \mid \boldsymbol {L} _ {t}, w \left(\boldsymbol {F} _ {t} + \boldsymbol {t} \mathbf {1} ^ {\top}\right), \boldsymbol {A}\right) \\ = \mathcal {N} _ {w} \left(w \left(\boldsymbol {F} _ {t - 1} + \boldsymbol {t} \boldsymbol {1} ^ {\top}\right) \mid w \left(\boldsymbol {F} _ {t} + \boldsymbol {t} \boldsymbol {1} ^ {\top}\right) + u _ {t} \hat {\epsilon} _ {\boldsymbol {F}} \left(\boldsymbol {L} _ {t}, w \left(\boldsymbol {F} _ {t} + \boldsymbol {t} \boldsymbol {1} ^ {\top}\right), \boldsymbol {A}, t\right), v _ {t} ^ {2} \boldsymbol {I}\right) \\ = \mathcal {N} _ {w} \left(w \left(\boldsymbol {F} _ {t - 1} + \boldsymbol {t} \boldsymbol {1} ^ {\top}\right) \mid w \left(\boldsymbol {F} _ {t} + \boldsymbol {t} \boldsymbol {1} ^ {\top}\right) + u _ {t} \hat {\epsilon} _ {\boldsymbol {F}} \left(\boldsymbol {L} _ {t}, \boldsymbol {F} _ {t}, \boldsymbol {A}, t\right), v _ {t} ^ {2} \boldsymbol {I}\right) \quad (\text {P T I}) \\ = \mathcal {N} _ {w} \left(w \left(\boldsymbol {F} _ {t - 1} + \boldsymbol {t} \mathbf {1} ^ {\top}\right) \mid w \left(w \left(\boldsymbol {F} _ {t} + \boldsymbol {t} \mathbf {1} ^ {\top}\right) + u _ {t} \hat {\epsilon} _ {\boldsymbol {F}} \left(\boldsymbol {L} _ {t}, \boldsymbol {F} _ {t}, \boldsymbol {A}, t\right)\right), v _ {t} ^ {2} \boldsymbol {I}\right) (Eq. (13)) \\ = \mathcal {N} _ {w} \left(w \left(\boldsymbol {F} _ {t - 1} + \boldsymbol {t} \mathbf {1} ^ {\top}\right) \mid w \left(\boldsymbol {F} _ {t} + u _ {t} \hat {\epsilon} _ {\boldsymbol {F}} \left(\boldsymbol {L} _ {t}, \boldsymbol {F} _ {t}, \boldsymbol {A}, t\right) + \boldsymbol {t}\right), v _ {t} ^ {2} \boldsymbol {I}\right) (Eq. (12)) \\ = \mathcal {N} _ {w} \left(\boldsymbol {F} _ {t - 1} \mid \boldsymbol {F} _ {t} + u _ {t} \hat {\epsilon} _ {\boldsymbol {F}} \left(\boldsymbol {L} _ {t}, \boldsymbol {F} _ {t}, \boldsymbol {A}, t\right), v _ {t} ^ {2} \boldsymbol {I}\right) (Eq. (14)) \\ = p \left(\boldsymbol {F} _ {t - 1} \mid \boldsymbol {L} _ {t}, \boldsymbol {F} _ {t}, \boldsymbol {A}\right). \\ \end{array}
$$
The transition probability of the fractional coordinates during the Predictor-Corrector sampling can be formulated as
$$
p (\boldsymbol {F} _ {t - 1} | \boldsymbol {L} _ {t}, \boldsymbol {F} _ {t}, \boldsymbol {A}) = p _ {P} (\boldsymbol {F} _ {t - \frac {1}{2}} | \boldsymbol {L} _ {t}, \boldsymbol {F} _ {t}, \boldsymbol {A}) p _ {C} (\boldsymbol {F} _ {t - 1} | \boldsymbol {L} _ {t - 1}, \boldsymbol {F} _ {t - \frac {1}{2}}, \boldsymbol {A}),
$$
$$
p _ {P} (\pmb {F} _ {t - \frac {1}{2}} | \pmb {L} _ {t}, \pmb {F} _ {t}, \pmb {A}) = \mathcal {N} _ {w} (\pmb {F} _ {t - \frac {1}{2}} | \pmb {F} _ {t} + (\sigma_ {t} ^ {2} - \sigma_ {t - 1} ^ {2}) \hat {\epsilon} _ {\pmb {F}} (\pmb {L} _ {t}, \pmb {F} _ {t}, \pmb {A}, t), \frac {\sigma_ {t - 1} ^ {2} (\sigma_ {t} ^ {2} - \sigma_ {t - 1} ^ {2})}{\sigma_ {t} ^ {2}} \pmb {I}),
$$
$$
p _ {C} (\pmb {F} _ {t - 1} | \pmb {L} _ {t - 1}, \pmb {F} _ {t - \frac {1}{2}}, \pmb {A}) = \mathcal {N} _ {w} (\pmb {F} _ {t - \frac {1}{2}} | \pmb {F} _ {t} + \gamma \frac {\sigma_ {t - 1}}{\sigma_ {1}} \hat {\epsilon} _ {\pmb {F}} (\pmb {L} _ {t - 1}, \pmb {F} _ {t - \frac {1}{2}}, \pmb {A}, t - 1), 2 \gamma \frac {\sigma_ {t - 1}}{\sigma_ {1}} \pmb {I}),
$$
where  $p_P, p_C$  are the transitions of the predictor and corrector. According to lemma 3, both of the transitions are periodic translation equivariant. Therefore, the transition  $p(\pmb{F}_{t-1} | \pmb{L}_t, \pmb{F}_t, \pmb{A})$  is periodic translation equivariant. As the prior distribution  $\mathcal{U}(0,1)$  is periodic translation invariant, we finally prove that the marginal distribution  $p(\pmb{F}_0)$  is periodic translation invariant based on lemma 1.
A.3 Proof of Proposition 3
We rewrite proposition 3 as follows.
Proposition 3. The score  $\hat{\epsilon}_{L}$  by Eq. (9) is  $O(3)$ -equivariant, and the score  $\hat{\epsilon}_{F}$  from Eq. (10) is periodic translation invariant. Hence, the generated distribution by DiffCSP is periodic  $E(3)$  invariant.
Proof. We first prove the orthogonal invariance of the inner product term  $L^{\top}L$ . For any orthogonal transformation  $\bar{Q}\in \mathbb{R}^{3\times 3}$ ,  $Q^{\top}Q = I$ , we have
$$
\left(\boldsymbol {Q} \boldsymbol {L}\right) ^ {\top} \left(\boldsymbol {Q} \boldsymbol {L}\right) = \boldsymbol {L} ^ {\top} \boldsymbol {Q} ^ {\top} \boldsymbol {Q} \boldsymbol {L} = \boldsymbol {L} ^ {\top} \boldsymbol {I} \boldsymbol {L} = \boldsymbol {L} ^ {\top} \boldsymbol {L}.
$$
For the Fourier Transformation, consider  $k$  is even, we have
$$
\begin{array}{l} \psi_ {\mathrm {F T}} \left(w \left(\boldsymbol {f} _ {j} + \boldsymbol {t}\right) - w \left(\boldsymbol {f} _ {i} + \boldsymbol {t}\right)\right) [ c, k ] \\ = \sin \left(2 \pi m \left(w \left(f _ {j, c} + t _ {c}\right) - w \left(f _ {i, c} + t _ {c}\right)\right)\right) \\ = \sin \left(2 \pi m \left(f _ {j, c} - f _ {i, c}\right) - 2 \pi m \left(\left(f _ {j, c} - f _ {i, c}\right) - \left(w \left(f _ {j, c} + t _ {c}\right) - w \left(f _ {i, c} + t _ {c}\right)\right)\right)\right) \\ = \sin (2 \pi m \left(f _ {j, c} - f _ {i, c}\right)) \\ = \psi_ {\mathrm {F T}} (\boldsymbol {f} _ {j} - \boldsymbol {f} _ {i}) [ c, k ]. \\ \end{array}
$$
Similar results can be acquired as  $k$  is odd. Therefore, we have  $\psi_{\mathrm{FT}}(w(\pmb{f}_j + \pmb{t}) - w(\pmb{f}_i + \pmb{t})) = \psi_{\mathrm{FT}}(\pmb{f}_j - \pmb{f}_i), \forall \pmb{t} \in \mathbb{R}^3$ , i.e., the Fourier Transformation  $\psi_{\mathrm{FT}}$  is periodic translation invariant. According to the above, the message passing layers defined in Eq. (6)-(8) is periodic E(3) invariant. Hence, we can directly prove that the coordinate denoising term  $\hat{\epsilon}_{\pmb{F}}$  is periodic translation invariant. Let  $\hat{\epsilon}_l(\pmb{L}, \pmb{F}, \pmb{A}, t) = \varphi_L\left(\frac{1}{N}\sum_{i=1}^{N}\pmb{h}_i^{(S)}\right)$ . For the lattice denoising term  $\hat{\epsilon}_L = L\hat{\epsilon}_l$ , we have
$$
\begin{array}{l} \hat {\epsilon} _ {L} (Q L, F, A, t) = Q L \hat {\epsilon} _ {l} (Q L, F, A, t) \\ = Q L \hat {\epsilon} _ {l} (\boldsymbol {L}, \boldsymbol {F}, \boldsymbol {A}, t) \\ = Q \hat {\epsilon} _ {L} (\boldsymbol {L}, \boldsymbol {F}, \boldsymbol {A}, t), \forall \boldsymbol {Q} \in \mathbb {R} ^ {3 \times 3}, \boldsymbol {Q} ^ {\top} \boldsymbol {Q} = \boldsymbol {I}. \\ \end{array}
$$
(a) Translation on infinite 3D space.
(b) Periodic translation on a unit cell.
Figure 4: An example of periodic translation invariance. From the view of a unit cell, the atoms translated across the right boundary will be brought back to the left side.
Above all,  $\hat{\epsilon}_L$  is O(3)-equivariant, and  $\hat{\epsilon}_F$  is periodic translation invariant. According to proposition 1 and 2, the generated distribution by DiffCSP in Algorithm 2 is periodic E(3) invariant.
A.4 Discussion on Periodic Translation Invariance
In Definition 3, we define the periodic translation invariance as a combination of translation invariance and periodicity. To see this, we illustrate an additional example in Figure 4. From a global view, when we translate all atom coordinates from left to right, the crystal structure remains unchanged, which indicates translation invariance. At the same time, from the view of a unit cell, the atom translated across the right boundary will be brought back to the left side owing to periodicity. Therefore, for convenience, we define the joint effect of translation invariance and periodicity as periodic translation invariance.
Previous works [36] have shown that shifting the periodic boundaries will not change the crystal structure. In this section, we further show that such periodic boundary shifting is equivalent to the periodic translation defined in Definition 3.
Consider two origin points  $\pmb{p}_1, \pmb{p}_2 \in \mathbb{R}^{3 \times 1}$  and the lattice matrix  $L$ , the constructed unit cells by  $\pmb{p}_1, \pmb{p}_2$  can be represented as  $\mathcal{M}_1 = (A_1, F_1, L)$  and  $\mathcal{M}_2 = (A_2, F_2, L)$ , where  $F_1, F_2 \in \mathbb{R}^{3 \times N}$  are fractional coordinates and
$$
\begin{array}{l} \left\{\left(\boldsymbol {a} _ {1, i} ^ {\prime}, \boldsymbol {x} _ {1, i} ^ {\prime}\right) \mid \boldsymbol {a} _ {1, i} ^ {\prime} = \boldsymbol {a} _ {1, i}, \boldsymbol {x} _ {1, i} ^ {\prime} = \boldsymbol {p} _ {1} + \boldsymbol {L} \boldsymbol {f} _ {1, i} + \boldsymbol {L} \boldsymbol {k}, \forall \boldsymbol {k} \in \mathbb {Z} ^ {3 \times 1} \right\} (15) \\ = \left\{\left(\boldsymbol {a} _ {1, j} ^ {\prime}, \boldsymbol {x} _ {1, j} ^ {\prime}\right) \mid \boldsymbol {a} _ {1, j} ^ {\prime} = \boldsymbol {a} _ {1, j}, \boldsymbol {x} _ {2, j} ^ {\prime} = \boldsymbol {p} _ {2} + \boldsymbol {L} \boldsymbol {f} _ {2, j} + \boldsymbol {L} \boldsymbol {k}, \forall \boldsymbol {k} \in \mathbb {Z} ^ {3 \times 1} \right\}, (16) \\ \end{array}
$$
which means that the unit cells formed by different origin points actually represent the same infinite crystal structures [36]. We further construct a bijection  $\mathcal{T}:\mathcal{M}_1\to \mathcal{M}_2$  mapping each atom in  $\mathcal{M}_1$  to the corresponding atom in unit cell  $\mathcal{M}_2$ . For the pair  $(a_{1,i},f_{1,i})\in \mathcal{M}_1,(a_{2,j},f_{2,j})\in \mathcal{M}_2$ , we have  $\mathcal{T}(a_{1,i},f_{1,i}) = (a_{2,j},f_{2,j})$  iff  $\exists \pmb {k}_i\in \mathbb{Z}^{3\times 1}$ , s.t.
$$
\left\{ \begin{array}{l} \boldsymbol {a} _ {1, i} = \boldsymbol {a} _ {2, j}, \\ \boldsymbol {p} _ {1} + \boldsymbol {L} \boldsymbol {f} _ {1, i} + \boldsymbol {L} \boldsymbol {k} _ {i} = \boldsymbol {p} _ {2} + \boldsymbol {L} \boldsymbol {f} _ {2, j}. \end{array} \right.
$$
After proper transformation, we have
$$
\boldsymbol {f} _ {2, j} = \boldsymbol {f} _ {1, i} + \boldsymbol {L} ^ {- 1} \left(\boldsymbol {p} _ {1} - \boldsymbol {p} _ {2}\right) + \boldsymbol {k} _ {i}. \tag {17}
$$
As  $\pmb{f}_{1,i}, \pmb{f}_{2,i} \in [0,1)^{3 \times 1}$ , we have
$$
\left\{ \begin{array}{l} \boldsymbol {k} _ {i} = - \lfloor \boldsymbol {f} _ {1, i} + \boldsymbol {L} ^ {- 1} (\boldsymbol {p} _ {1} - \boldsymbol {p} _ {2}) \rfloor , \\ \boldsymbol {f} _ {2, j} = w \Big (\boldsymbol {f} _ {1, i} + \boldsymbol {L} ^ {- 1} (\boldsymbol {p} _ {1} - \boldsymbol {p} _ {2}) \Big), \end{array} \right.
$$
which means shifting the periodic boundaries by changing the origin point  $\pmb{p}_1$  into  $\pmb{p}_2$  is equivalent to a periodic translation  $\pmb{F}_2 = w\Big(\pmb{F}_1 + \pmb{L}^{-1}(\pmb{p}_1 - \pmb{p}_2)\pmb{1}^\top \Big)$ .
B.1 Approximation of the Wrapped Normal Distribution
The Probability Density Function (PDF) of the wrapped normal distribution  $\mathcal{N}_w(0,\sigma_t^2)$  is
$$
\mathcal {N} _ {w} (x | 0, \sigma_ {t} ^ {2}) = \frac {1}{\sqrt {2 \pi} \sigma_ {t}} \sum_ {k = - \infty} ^ {\infty} \exp \Big (- \frac {(x - k) ^ {2}}{2 \sigma_ {t} ^ {2}} \Big),
$$
where  $x \in [0,1)$ . Because the above series is convergent, it is reasonable to approximate the infinite summation to a finite truncated summation [61] as
$$
f _ {w, n} (x; 0, \sigma_ {t} ^ {2}) = \frac {1}{\sqrt {2 \pi} \sigma_ {t}} \sum_ {k = - n} ^ {n} \exp \Big (- \frac {(x - k) ^ {2}}{2 \sigma_ {t} ^ {2}} \Big).
$$
And the logarithmic gradient of  $f$  can be formulated as
$$
\begin{array}{l} \nabla_ {x} \log f _ {w, n} (x; 0, \sigma_ {t} ^ {2}) = \nabla_ {x} \log \left(\frac {1}{\sqrt {2 \pi} \sigma_ {t}} \sum_ {k = - n} ^ {n} \exp \left(- \frac {(x - k) ^ {2}}{2 \sigma_ {t} ^ {2}}\right)\right) \\ = \nabla_ {x} \log \left(\sum_ {k = - n} ^ {n} \exp \left(- \frac {(x - k) ^ {2}}{2 \sigma_ {t} ^ {2}}\right)\right) \\ = \frac {\sum_ {k = - n} ^ {n} (k - x) \exp \left(- \frac {(x - k) ^ {2}}{2 \sigma_ {t} ^ {2}}\right)}{\sigma_ {t} ^ {2} \sum_ {k = - n} ^ {n} \exp \left(- \frac {(x - k) ^ {2}}{2 \sigma_ {t} ^ {2}}\right)} \\ \end{array}
$$
To estimate  $\lambda_{t} = \mathbb{E}_{x\sim \mathcal{N}_{w}(0,\sigma_{t}^{2})}\big[\| \nabla_{x}\log \mathcal{N}_{w}(x|0,\sigma_{t}^{2})\|_{2}^{2}\big]$ , we first sample  $m$  points from  $\mathcal{N}_w(0,\sigma_t^2)$  and the expectation is approximated as
$$
\begin{array}{l} \tilde {\lambda} _ {t} = \left[ \frac {1}{m} \sum_ {i = 1} ^ {m} \| \nabla_ {x} \log f _ {w, n} (x _ {i}; 0, \sigma_ {t} ^ {2}) \| _ {2} ^ {2} \right] ^ {- 1} \\ = \left[ \frac {1}{m} \sum_ {i = 1} ^ {m} \left\| \frac {\sum_ {k = - n} ^ {n} (k - x _ {i}) \exp \left(- \frac {(x _ {i} - k) ^ {2}}{2 \sigma_ {t} ^ {2}}\right)}{\sigma_ {t} ^ {2} \sum_ {k = - n} ^ {n} \exp \left(- \frac {(x _ {i} - k) ^ {2}}{2 \sigma_ {t} ^ {2}}\right)} \right\| _ {2} ^ {2} \right] ^ {- 1}. \\ \end{array}
$$
For implementation, we select  $n = 10$  and  $m = 10000$ .
B.2 Adaptation of CDVAE
As illustrated in Figure 5, the original CDVAE [9] mainly consists of three parts: (1) a 3D encoder to encode the structure into the latent variable  $z_{3D}$ , (2) a property predictor to predict the lattice  $L$ , the number of nodes in the unit cell  $N$ , and the proportion of each element in the composition  $c$ , (3) a 3D decoder to generate the structure from  $z_{3D}$ ,  $L$ ,  $N$ ,  $c$  via the Score Matching with Langevin Dynamics (SMLD, Song and Ermon [49]) method. The training objective is composed of the loss functions on the three parts, i.e. the KL divergence between the encoded distribution and the standard normal distribution  $\mathcal{L}_{KL}$ , the aggregated prediction loss  $\mathcal{L}_{AGG}$  and the denoising loss on the decoder  $\mathcal{L}_{DEC}$ . Formally, we have
$$
\mathcal {L} _ {O R I} = \mathcal {L} _ {A G G} + \mathcal {L} _ {D E C} + \beta D _ {K L} \left(\mathcal {N} \left(\mu_ {3 D}, \sigma_ {3 D} ^ {2} \boldsymbol {I}\right) \| \mathcal {N} (0, \boldsymbol {I})\right).
$$
We formulate  $\mathcal{L}_{KL} = \beta D_{KL}(\mathcal{N}(\mu_{3D},\sigma_{3D}^2 I)\| \mathcal{N}(0,I))$  for better comparison with the adapted method.  $\beta$  is the hyper-parameter to balance the scale of the KL divergence and other loss functions.
To adapt the CDVAE framework to the CSP task, we apply two main changes. Firstly, for the encoder side, to take the composition as the condition, we apply an additional 1D prior encoder to encode the composition set into a latent distribution  $\mathcal{N}(\mu_{1D},\sigma_{1D}^2 I)$  and minimize the KL divergence between the 3D and 1D distribution. The training objective is modified into
$$
\mathcal {L} _ {A D A} = \mathcal {L} _ {A G G} + \mathcal {L} _ {D E C} + \beta D _ {K L} \Big (\mathcal {N} (\mu_ {3 D}, \sigma_ {3 D} ^ {2} \boldsymbol {I}) \| \mathcal {N} (\mu_ {1 D}, \sigma_ {1 D} ^ {2} \boldsymbol {I}) \Big).
$$
Figure 5: Overview of the original (a,b) and adapted (c,d) CDVAE. The key adaptations lie in two points. (1) We introduce an additional 1D prior encoder to fit the latent distribution of the given composition. (2) We initialize the generation procedure of the 3D decoder with the ground truth composition and keep the atom types unchanged to ensure the generated structure conforms to the given composition.
During the inference procedure, as the composition is given, the latent variable  $z_{1D}$  is sampled from  $\mathcal{N}(\mu_{1D}, \sigma_{1D}^2 I)$ . For implementation, we apply a Transformer [51] without positional encoding as the 1D encoder to ensure the permutation invariance. Secondly, for the generation procedure, we apply the ground truth composition for initialization and keep the atom types unchanged during the Langevin dynamics to ensure the generated structure conforms to the given composition.
B.3 Algorithms for Training and Sampling
Algorithm 1 summarizes the forward diffusion process as well as the training of the denoising model  $\phi$ , while Algorithm 2 illustrates the backward sampling process. They can maintain the symmetries if  $\phi$  is delicately constructed. Notably, We apply the predictor-corrector sampler [50] to sample  $F_0$ . In Algorithm 2, Line 7 refers to the predictor while Lines 9-10 correspond to the corrector.
Algorithm 1 Training Procedure of DiffCSP
1: Input: lattice matrix  $L_{0}$ , atom types  $\mathbf{A}$ , fractional coordinates  $\mathbf{F}_0$ , denoising model  $\phi$ , and the number of sampling steps  $T$ .  
2: Sample  $\epsilon_L \sim \mathcal{N}(\mathbf{0}, \mathbf{I}), \epsilon_F \sim \mathcal{N}(\mathbf{0}, \mathbf{I})$  and  $t \sim \mathcal{U}(1, T)$ .  
3:  $\mathbf{L}_t \gets \sqrt{\bar{\alpha}_t} \mathbf{L}_0 + \sqrt{1 - \bar{\alpha}_t} \epsilon_L$   
4:  $\mathbf{F}_t \gets w(\mathbf{F}_0 + \sigma_t \epsilon_F)$   
5:  $\hat{\epsilon}_L, \hat{\epsilon}_F \gets \phi(\mathbf{L}_t, \mathbf{F}_t, \mathbf{A}, t)$   
6:  $\mathcal{L}_L \gets \| \epsilon_L - \hat{\epsilon}_L\|_2^2$   
7:  $\mathcal{L}_F \gets \lambda_t \| \nabla_{\mathbf{F}_t} \log q(\mathbf{F}_t | \mathbf{F}_0) - \hat{\epsilon}_F\|_2^2$   
8: Minimize  $\mathcal{L}_L + \mathcal{L}_F$
Algorithm 2 Sampling Procedure of DiffCSP
1: Input: atom types  $\mathbf{A}$ , denoising model  $\phi$ , number of sampling steps  $T$ , step size of Langevin dynamics  $\gamma$ .  
2: Sample  $\mathbf{L}_T \sim \mathcal{N}(\mathbf{0}, \mathbf{I}), \mathbf{F}_T \sim \mathcal{U}(0, 1)$ .  
3: for  $t \gets T, \dots, 1$  do  
4: Sample  $\epsilon_L, \epsilon_F, \epsilon'_F \sim \mathcal{N}(\mathbf{0}, \mathbf{I})$   
5:  $\hat{\epsilon}_L, \hat{\epsilon}_F \gets \phi(\mathbf{L}_t, \mathbf{F}_t, \mathbf{A}, t)$ .  
6:  $\mathbf{L}_{t-1} \gets \frac{1}{\sqrt{\alpha_t}} (\mathbf{L}_t - \frac{\beta_t}{\sqrt{1 - \bar{\alpha}_t}} \hat{\epsilon}_L) + \sqrt{\beta_t \cdot \frac{1 - \bar{\alpha}_{t-1}}{1 - \bar{\alpha}_t}} \epsilon_L$ .  
7:  $\mathbf{F}_{t-\frac{1}{2}} \gets w(\mathbf{F}_t + (\sigma_t^2 - \sigma_{t-1}^2) \hat{\epsilon}_F + \frac{\sigma_{t-1} \sqrt{\sigma_t^2 - \sigma_{t-1}^2}}{\sigma_t} \epsilon_F)$   
8:  $-, \hat{\epsilon}_F \gets \phi(\mathbf{L}_{t-1}, \mathbf{F}_{t-\frac{1}{2}}, \mathbf{A}, t-1)$ .  
9:  $d_t \gets \gamma \sigma_{t-1} / \sigma_1$   
10:  $\mathbf{F}_{t-1} \gets w(\mathbf{F}_{t-\frac{1}{2}} + d_t \hat{\epsilon}_F + \sqrt{2d_t} \epsilon'_F)$ .  
11: end for  
12: Return  $\mathbf{L}_0, \mathbf{F}_0$ .
B.4 Hyper-parameters and Training Details
We acquire the origin datasets from CDVAE [9] and MPTS-52 [57]. We utilize the codebases from GN-OA [21], cG-SchNet [53] and CDVAE [9] for baseline implementations.
For the optimization methods, we apply the MEGNet [52] with 3 layers, 32 hidden states as property predictor. The model is trained for 1000 epochs with an Adam optimizer with learning rate  $1 \times 10^{-3}$ . As for the optimization algorithms, we apply RS, PSO, and BO according to Cheng et al. [21]. For RS and BO, We employ random search and TPE-based BO as implemented in Hyperopt [62] $^9$ . Specifically, we choose observation quantile  $\gamma$  as 0.25 and the number of initial random points as 200 for BO. For PSO, we used scikit-opt $^{10}$  and choose the momentum parameter  $\omega$  as 0.8, the cognitive as 0.5, the social parameters as 0.5 and the size of population as 20.