diff --git a/qiskit_ibm_runtime/api/clients/runtime.py b/qiskit_ibm_runtime/api/clients/runtime.py index c45e38c771..b895b86447 100644 --- a/qiskit_ibm_runtime/api/clients/runtime.py +++ b/qiskit_ibm_runtime/api/clients/runtime.py @@ -268,13 +268,13 @@ def list_backends( """ return self._api.backends(hgp=hgp, channel_strategy=channel_strategy)["devices"] - def cloud_instance(self) -> bool: + def is_qctrl_enabled(self) -> bool: """Returns a boolean of whether or not the instance has q-ctrl enabled. Returns: Boolean value. """ - return self._api.cloud_instance() + return self._api.is_qctrl_enabled() def backend_configuration(self, backend_name: str) -> Dict[str, Any]: """Return the configuration of the IBM backend. diff --git a/qiskit_ibm_runtime/api/rest/runtime.py b/qiskit_ibm_runtime/api/rest/runtime.py index e34708f3a0..b5a58648b0 100644 --- a/qiskit_ibm_runtime/api/rest/runtime.py +++ b/qiskit_ibm_runtime/api/rest/runtime.py @@ -230,7 +230,7 @@ def backends( params["channel_strategy"] = channel_strategy return self.session.get(url, params=params, timeout=timeout).json() - def cloud_instance(self) -> bool: + def is_qctrl_enabled(self) -> bool: """Return boolean of whether or not the instance has q-ctrl enabled. Returns: diff --git a/qiskit_ibm_runtime/qiskit_runtime_service.py b/qiskit_ibm_runtime/qiskit_runtime_service.py index 8129821302..96806df62a 100644 --- a/qiskit_ibm_runtime/qiskit_runtime_service.py +++ b/qiskit_ibm_runtime/qiskit_runtime_service.py @@ -317,11 +317,21 @@ def _validate_channel_strategy(self) -> None: instance do not match. """ + qctrl_enabled = self._api_client.is_qctrl_enabled() if self._channel_strategy == "q-ctrl": - qctrl_enabled = self._api_client.cloud_instance() if not qctrl_enabled: raise IBMNotAuthorizedError( - "This account is not authorized to use ``q-ctrl`` as a channel strategy." + "The instance passed in is not compatible with Q-CTRL channel strategy. " + "Please switch to or create an instance with the Q-CTRL strategy enabled. " + "See https://cloud.ibm.com/docs/quantum-computing?" + "topic=quantum-computing-get-started for more information" + ) + else: + if qctrl_enabled: + raise IBMNotAuthorizedError( + "The instance passed in is only compatible with Q-CTRL performance " + "management strategy. " + "To use this instance, set channel_strategy='q-ctrl'." ) def _discover_cloud_backends(self) -> Dict[str, "ibm_backend.IBMBackend"]: diff --git a/releasenotes/notes/q-ctrl-instance-check-46181d51f16d18bc.yaml b/releasenotes/notes/q-ctrl-instance-check-46181d51f16d18bc.yaml new file mode 100644 index 0000000000..1a556a4fb5 --- /dev/null +++ b/releasenotes/notes/q-ctrl-instance-check-46181d51f16d18bc.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + If a cloud instance that is `q-ctrl` enabled is used while `q-ctrl` is not + passed in as the `channel_strategy`, an error will be raised. diff --git a/test/unit/mock/fake_runtime_client.py b/test/unit/mock/fake_runtime_client.py index 55f5d29e3f..fb27ffefc8 100644 --- a/test/unit/mock/fake_runtime_client.py +++ b/test/unit/mock/fake_runtime_client.py @@ -285,6 +285,10 @@ def set_job_classes(self, classes): classes = [classes] self._job_classes = classes + def is_qctrl_enabled(self): + """Return whether or not channel_strategy q-ctrl is enabled.""" + return False + def set_final_status(self, final_status): """Set job status to passed in final status instantly.""" self._final_status = final_status