Skip to content

Commit

Permalink
Merge branch 'main' into plot-execution-spans
Browse files Browse the repository at this point in the history
  • Loading branch information
ihincks authored Oct 28, 2024
2 parents 81549bc + 9d01de5 commit 00d4fc8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
12 changes: 8 additions & 4 deletions qiskit_ibm_runtime/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
IAMAuthenticator,
)
from ibm_platform_services import ResourceControllerV2 # pylint: disable=import-error
from qiskit.circuit import QuantumCircuit, ControlFlowOp
from qiskit.circuit import QuantumCircuit, ControlFlowOp, Parameter
from qiskit.transpiler import Target
from qiskit.providers.backend import BackendV1, BackendV2
from .deprecation import deprecate_function
Expand Down Expand Up @@ -72,9 +72,13 @@ def _is_isa_circuit_helper(circuit: QuantumCircuit, target: Target, qubit_map: D
# We allow an angle value of a bit more than pi/2, to compensate floating point rounding
# errors (beyond pi/2 does not trigger an error down the stack, only may become less
# accurate).
if name == "rzz" and (
instruction.operation.params[0] < 0.0
or instruction.operation.params[0] > 1.001 * np.pi / 2
if (
name == "rzz"
and not isinstance(instruction.operation.params[0], Parameter)
and (
instruction.operation.params[0] < 0.0
or instruction.operation.params[0] > 1.001 * np.pi / 2
)
):
return f"The instruction {name} on qubits {qargs} is supported only for angles in the \
range [0, pi/2], but an angle of {instruction.operation.params[0]} has been provided."
Expand Down
13 changes: 13 additions & 0 deletions test/unit/test_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit.primitives.containers.sampler_pub import SamplerPub
from qiskit.circuit import Parameter
from qiskit.circuit.library import RealAmplitudes
from qiskit_ibm_runtime import Session, SamplerV2, SamplerOptions, IBMInputValueError
from qiskit_ibm_runtime.fake_provider import FakeFractionalBackend, FakeSherbrooke, FakeCusco
Expand Down Expand Up @@ -296,3 +297,15 @@ def test_rzz_angle_validation(self, angle):
else:
with self.assertRaises(IBMInputValueError):
SamplerV2(backend).run(pubs=[(circ)])

def test_rzz_validates_only_for_fixed_angles(self):
"""Verify that the rzz validation occurs only when the angle is a number, and not a
parameter"""
backend = FakeFractionalBackend()
param = Parameter("p")

circ = QuantumCircuit(2)
circ.rzz(param, 0, 1)

# Should run without an error
SamplerV2(backend).run(pubs=[(circ, [1])])

0 comments on commit 00d4fc8

Please sign in to comment.