Environment:
- Qiskit version:
2.4.0rc3
- Python version:
Python 3.14.2
- Operating system: Windows 11
Description:
In Qiskit 2.4.0rc3, when using transpile with unitary_synthesis_plugin_config, the epsilon value seems to be ignored when using gridsynth to synthesize single-qubit rz gates. This results in the same transpiled circuits when trying to synthesize with different epsilon tolerances (where we would expect the T-like counts to increase as the synthesis tolerance decreases for a Clifford + T/Tdg basis).
Steps to Reproduce:
Run the following Python script for both Qiskit versions 2.4.0rc3 and 2.3.1:
import importlib.metadata
from qiskit import QuantumCircuit, transpile
from qiskit.quantum_info import Operator, get_clifford_gate_names
import numpy as np
package_name = "qiskit"
try:
version = importlib.metadata.version(package_name)
print(f"{package_name} version: {version}")
except importlib.metadata.PackageNotFoundError:
print(f"{package_name} is not installed.")
theta = 0.1
qc = QuantumCircuit(1)
qc.rz(theta, 0)
for eps in [1e-6, 1e-7, 1e-8, 1e-9, 1e-10, 1e-11, 1e-12, 1e-13, 1e-14, 1e-15]:
transpiled = transpile(
qc,
basis_gates=get_clifford_gate_names() + ["t", "tdg"],
unitary_synthesis_method="gridsynth",
unitary_synthesis_plugin_config={"epsilon": eps},
)
print(f"epsilon: {eps}, T-like count: {transpiled.count_ops().get('t', 0) + transpiled.count_ops().get('tdg', 0)}")
# Compute the actual spectral norm error between the original and transpiled unitaries
original_unitary = Operator(qc).data
transpiled_unitary = Operator(transpiled).data
error = np.linalg.norm(original_unitary - transpiled_unitary, ord=2)
print(f" Spectral norm error: {error:.2e}")
if error > eps:
print(f"***ERROR!")
Outputs:
- With Qiskit version
2.4.0.rc1:
qiskit version: 2.4.0rc3
epsilon: 1e-06, T-like count: 124
Spectral norm error: 2.68e-13
epsilon: 1e-07, T-like count: 124
Spectral norm error: 2.68e-13
epsilon: 1e-08, T-like count: 124
Spectral norm error: 2.68e-13
epsilon: 1e-09, T-like count: 124
Spectral norm error: 2.68e-13
epsilon: 1e-10, T-like count: 124
Spectral norm error: 2.68e-13
epsilon: 1e-11, T-like count: 124
Spectral norm error: 2.68e-13
epsilon: 1e-12, T-like count: 124
Spectral norm error: 2.68e-13
epsilon: 1e-13, T-like count: 124
Spectral norm error: 2.68e-13
***ERROR!
epsilon: 1e-14, T-like count: 124
Spectral norm error: 2.68e-13
***ERROR!
epsilon: 1e-15, T-like count: 124
Spectral norm error: 2.68e-13
***ERROR!
- With Qiskit version
2.3.1:
qiskit version: 2.3.1
epsilon: 1e-06, T-like count: 63
Spectral norm error: 2.66e-07
epsilon: 1e-07, T-like count: 73
Spectral norm error: 4.22e-08
epsilon: 1e-08, T-like count: 81
Spectral norm error: 2.07e-09
epsilon: 1e-09, T-like count: 94
Spectral norm error: 3.48e-10
epsilon: 1e-10, T-like count: 104
Spectral norm error: 4.03e-11
epsilon: 1e-11, T-like count: 112
Spectral norm error: 4.91e-12
epsilon: 1e-12, T-like count: 124
Spectral norm error: 1.52e-13
epsilon: 1e-13, T-like count: 130
Spectral norm error: 5.06e-14
epsilon: 1e-14, T-like count: 144
Spectral norm error: 2.03e-14
***ERROR!
epsilon: 1e-15, T-like count: 151
Spectral norm error: 2.12e-14
***ERROR!
Notes:
- As we can see, the T-like count increase with smaller
gridsynth tolerances in 2.3.1, but remains the same for 2.4.0rc3. It looks like it may be using a tolerance of 1e-12.
- Minor note: The "ERROR" in
2.3.1 for very small tolerance can probably be attributed to floating point imprecision, but the main point is that the tolerance seems to be ignored in 2.4.0rc3.
- I'm unsure if there is a chance that this behavior is intended (given the recent changes to the
Clifford+T and Clifford+Rz pipeline), but it seems that larger tolerances (eg: 1e-3) should have smaller counts if the transpiler can get away with shallower approximations.
Environment:
2.4.0rc3Python 3.14.2Description:
In Qiskit 2.4.0rc3, when using
transpilewithunitary_synthesis_plugin_config, theepsilonvalue seems to be ignored when usinggridsynthto synthesize single-qubitrzgates. This results in the same transpiled circuits when trying to synthesize with differentepsilontolerances (where we would expect the T-like counts to increase as the synthesis tolerance decreases for aClifford + T/Tdgbasis).Steps to Reproduce:
Run the following Python script for both Qiskit versions
2.4.0rc3and2.3.1:Outputs:
2.4.0.rc1:2.3.1:Notes:
gridsynthtolerances in2.3.1, but remains the same for2.4.0rc3. It looks like it may be using a tolerance of1e-12.2.3.1for very small tolerance can probably be attributed to floating point imprecision, but the main point is that the tolerance seems to be ignored in2.4.0rc3.Clifford+TandClifford+Rzpipeline), but it seems that larger tolerances (eg:1e-3) should have smaller counts if the transpiler can get away with shallower approximations.