diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 86eab8c2..e177985f 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -211,8 +211,8 @@ jobs: - name: Run tests with mpl test env: PYTKET_RUN_MPL_TESTS: 1 - PYTKET_REMOTE_QUANTINUUM_USERNAME_QA: ${{ secrets.PYTKET_REMOTE_QUANTINUUM_USERNAME }} - PYTKET_REMOTE_QUANTINUUM_PASSWORD_QA: ${{ secrets.PYTKET_REMOTE_QUANTINUUM_USERNAME }} + PYTKET_REMOTE_QUANTINUUM_USERNAME_QA: ${{ secrets.PYTKET_REMOTE_QUANTINUUM_USERNAME_QA }} + PYTKET_REMOTE_QUANTINUUM_PASSWORD_QA: ${{ secrets.PYTKET_REMOTE_QUANTINUUM_PASSWORD_QA }} working-directory: ./tests run: | pytest --mpl-generate-path=integration/baseline diff --git a/pytket/extensions/quantinuum/backends/quantinuum.py b/pytket/extensions/quantinuum/backends/quantinuum.py index 4d09858a..33a0f309 100644 --- a/pytket/extensions/quantinuum/backends/quantinuum.py +++ b/pytket/extensions/quantinuum/backends/quantinuum.py @@ -326,6 +326,14 @@ def __init__( ] = dict() self._default_2q_gate = _default_2q_gate(device_name) + + if self._default_2q_gate in self.two_qubit_gate_set: + pass + elif len(self.two_qubit_gate_set) > 0: + self._default_2q_gate = list(self.two_qubit_gate_set)[0] + else: + raise ValueError("The device is not supporting any two qubit gates") + if compilation_config is None: self.compilation_config = QuantinuumBackendCompilationConfig( allow_implicit_swaps=True, target_2qb_gate=self._default_2q_gate diff --git a/tests/unit/api1_test.py b/tests/unit/api1_test.py index aa71cdff..16feb96c 100644 --- a/tests/unit/api1_test.py +++ b/tests/unit/api1_test.py @@ -189,9 +189,13 @@ def test_custom_login_flow( ), ) + qcc = QuantinuumConfigCredentialStorage() + qcc.save_user_name("user3") + qcc.save_refresh_token("token") + backend_3 = QuantinuumBackend( device_name=fake_device, - api_handler=QuantinuumAPI(QuantinuumConfigCredentialStorage()), + api_handler=QuantinuumAPI(qcc), ) circ = Circuit(2, name="default_login_flow_test").H(0).CX(0, 1).measure_all() @@ -391,9 +395,8 @@ def test_device_family( ) backend = QuantinuumBackend( - device_name=chosen_device, + device_name=chosen_device, api_handler=mock_quum_api_handler ) - backend.api_handler = mock_quum_api_handler circ = Circuit(2, name="batching_test").H(0).CX(0, 1).measure_all() circ = backend.get_compiled_circuit(circ) @@ -443,8 +446,8 @@ def test_resumed_batching( backend = QuantinuumBackend( device_name="H1-1E", + api_handler=mock_quum_api_handler, ) - backend.api_handler = mock_quum_api_handler circ = Circuit(2, name="batching_test").H(0).CX(0, 1).measure_all() circ = backend.get_compiled_circuit(circ) @@ -553,8 +556,8 @@ def test_submit_qasm_api( backend = QuantinuumBackend( device_name="H1-1SC", + api_handler=mock_quum_api_handler, ) - backend.api_handler = mock_quum_api_handler qasm = """ OPENQASM 2.0; diff --git a/tests/unit/offline_backend_test.py b/tests/unit/offline_backend_test.py index 7811616a..992cce07 100644 --- a/tests/unit/offline_backend_test.py +++ b/tests/unit/offline_backend_test.py @@ -151,8 +151,8 @@ def test_shots_bits_edgecases(n_shots, n_bits, language: Language) -> None: @pytest.mark.parametrize("device_name", pytest.ALL_DEVICE_NAMES) # type: ignore def test_defaultapi_handler(device_name: str) -> None: """Test that the default API handler is used on backend construction.""" - backend_1 = QuantinuumBackend(device_name) - backend_2 = QuantinuumBackend(device_name) + backend_1 = QuantinuumBackend(device_name, machine_debug=True) + backend_2 = QuantinuumBackend(device_name, machine_debug=True) assert backend_1.api_handler is backend_2.api_handler @@ -163,8 +163,12 @@ def test_custom_api_handler(device_name: str) -> None: handler_1 = QuantinuumAPI() handler_2 = QuantinuumAPI() - backend_1 = QuantinuumBackend(device_name, api_handler=handler_1) - backend_2 = QuantinuumBackend(device_name, api_handler=handler_2) + backend_1 = QuantinuumBackend( + device_name, api_handler=handler_1, machine_debug=True + ) + backend_2 = QuantinuumBackend( + device_name, api_handler=handler_2, machine_debug=True + ) assert backend_1.api_handler is not backend_2.api_handler assert backend_1.api_handler._cred_store is not backend_2.api_handler._cred_store