  Probabilistic storage and retrieval (PSR) of unitary quantum dynamics is
possible with exponentially small failure probability with respect to the
number of systems used as a quantum memory [PRL 122, 170502 (2019)]. Here we
study improvements due to a priori knowledge about the unitary transformation
to be stored. In particular, we study $N \rightarrow 1$ PSR of qubit phase
gates, i.e. qubit rotations a round $Z$ axis with an unknown angle, and show
that if we access the gate only $N$-times, the optimal probability of perfect
retrieving of its single use is $N/(N+1)$. We propose a quantum circuit
realization for the optimal protocol and show that programmable phase gate [PRL
88, 047905 (2002)] can be turned into $(2^k-1)\rightarrow 1$ optimal PSR of
phase gates and requires only $k$ CNOT gates, while having exponentially small
failure probability in $k$.
