Required prerequisites
Describe the feature
GridSynth can find multiple valid approximations with the same T-count and
approximation error but different Clifford costs. It currently has no secondary
quality objective for choosing between them.
For example, synthesize Rz(pi/8) at error tolerance 1e-3. Save this as
repro.qke:
func.func @kernel() {
%theta = arith.constant 0.39269908169872414 : f64 // pi/8
%q = quake.null_wire
%0 = quake.rz (%theta) %q : (f64, !quake.wire) -> !quake.wire
quake.sink %0 : !quake.wire
return
}
Run the synthesis several times and count the resulting operations:
for run in $(seq 1 20); do
cudaq-opt --mlir-disable-threading \
--pass-pipeline='builtin.module(clifford-t-synthesis{epsilon=0.001 skip-below=0 fail-on-controlled-rotation=true},inline)' \
repro.qke -o "output.${run}.qke"
awk '
/quake.h / { h++ }
/quake.s / { s++ }
/quake.t / { t++ }
/quake.x / { x++ }
END {
printf "h=%d s=%d t=%d x=%d total=%d\n", h, s, t, x, h+s+t+x
}
' "output.${run}.qke"
done
CUDA-Q c6e220e5f76fa1a92319011e4e8e367215db4cd8 produces both of these
results:
h=33 s=12 t=32 x=1 total=78
h=33 s=22 t=32 x=1 total=88
Both results have approximation error 0.00057387052611130424. Neither
exhausts an iteration or restart limit, and both gate sequences are already in
Matsumoto-Amano normal form. They are different exactly representable unitaries
that approximate the same target rotation, rather than different
representations of one exact unitary. Matsumoto-Amano normalization therefore
does not remove the ten-gate difference.
This is an optimization opportunity rather than a correctness defect. CUDA-Q
could reduce the Clifford overhead of rotation synthesis when several results
already satisfy the primary T-count and approximation objectives. For this
reproducer, an improvement should retain at most 32 T gates, meet the 1e-3
tolerance, and avoid the additional ten S gates. Any general change should also
be evaluated over a representative set of rotations for synthesis time and
output quality.
The separate seed issue above covers whether repeated synthesis is
reproducible. This issue covers the quality of the selected result and does not
require a particular selection algorithm.
Required prerequisites
Describe the feature
GridSynth can find multiple valid approximations with the same T-count and
approximation error but different Clifford costs. It currently has no secondary
quality objective for choosing between them.
For example, synthesize
Rz(pi/8)at error tolerance1e-3. Save this asrepro.qke:Run the synthesis several times and count the resulting operations:
CUDA-Q
c6e220e5f76fa1a92319011e4e8e367215db4cd8produces both of theseresults:
Both results have approximation error
0.00057387052611130424. Neitherexhausts an iteration or restart limit, and both gate sequences are already in
Matsumoto-Amano normal form. They are different exactly representable unitaries
that approximate the same target rotation, rather than different
representations of one exact unitary. Matsumoto-Amano normalization therefore
does not remove the ten-gate difference.
This is an optimization opportunity rather than a correctness defect. CUDA-Q
could reduce the Clifford overhead of rotation synthesis when several results
already satisfy the primary T-count and approximation objectives. For this
reproducer, an improvement should retain at most 32 T gates, meet the
1e-3tolerance, and avoid the additional ten S gates. Any general change should also
be evaluated over a representative set of rotations for synthesis time and
output quality.
The separate seed issue above covers whether repeated synthesis is
reproducible. This issue covers the quality of the selected result and does not
require a particular selection algorithm.