diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index ad0ed00..e88691b 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -4,17 +4,11 @@ on: pull_request: branches: - main + schedule: + # 04:00 every Tuesday morning + - cron: '0 4 * * 2' workflow_dispatch: {} -env: - PYTKET_RUN_REMOTE_TESTS: 1 - PYTKET_REMOTE_AZURE_RESOURCE_ID: ${{ secrets.PYTKET_REMOTE_AZURE_RESOURCE_ID }} - PYTKET_REMOTE_AZURE_LOCATION: ${{ secrets.PYTKET_REMOTE_AZURE_LOCATION }} - PYTKET_REMOTE_AZURE_STORAGE: ${{ secrets.PYTKET_REMOTE_AZURE_STORAGE }} - AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} - AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} - AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }} - jobs: checks: name: Build and test module @@ -30,4 +24,17 @@ jobs: python-version: '3.10' - name: Build and test shell: bash - run: ./.github/workflows/build-test nomypy + env: + PYTKET_RUN_REMOTE_TESTS: 1 + PYTKET_REMOTE_AZURE_RESOURCE_ID: ${{ secrets.PYTKET_REMOTE_AZURE_RESOURCE_ID }} + PYTKET_REMOTE_AZURE_LOCATION: ${{ secrets.PYTKET_REMOTE_AZURE_LOCATION }} + PYTKET_REMOTE_AZURE_STORAGE: ${{ secrets.PYTKET_REMOTE_AZURE_STORAGE }} + AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} + AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} + AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }} + run: ./.github/workflows/build-test mypy + - name: Install docs dependencies + run: pip install -r .github/workflows/docs/requirements.txt + - name: Build docs + timeout-minutes: 20 + run: ./.github/workflows/docs/check-build-docs diff --git a/.github/workflows/full_checks.yml b/.github/workflows/full_checks.yml deleted file mode 100644 index f93cb68..0000000 --- a/.github/workflows/full_checks.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Build and test - -on: - pull_request: - branches: - - main - schedule: - # 04:00 every Tuesday morning - - cron: '0 4 * * 2' - -jobs: - checks: - name: Build and test module - runs-on: 'ubuntu-latest' - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: '0' - - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* +refs/heads/*:refs/remotes/origin/* - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.10' - - name: Build and test - shell: bash - env: - PYTKET_RUN_REMOTE_TESTS: 1 - run: | - ./.github/workflows/build-test mypy - - name: Install docs dependencies - run: | - pip install -r .github/workflows/docs/requirements.txt - - name: Build docs - timeout-minutes: 20 - run: | - ./.github/workflows/docs/check-build-docs diff --git a/pytket/extensions/azure/backends/azure.py b/pytket/extensions/azure/backends/azure.py index ba0e584..51a5742 100644 --- a/pytket/extensions/azure/backends/azure.py +++ b/pytket/extensions/azure/backends/azure.py @@ -122,7 +122,14 @@ def process_circuits( ) -> List[ResultHandle]: """ See :py:meth:`pytket.backends.Backend.process_circuits`. + + Supported kwargs: + + - option_params: a dictionary with string keys and arbitrary values; + key-value pairs in the dictionary are passed as input parameters to + the backend. Their semantics are backend-dependent. """ + option_params = kwargs.get("option_params") circuits = list(circuits) n_shots_list = Backend._get_n_shots_as_list( n_shots, @@ -138,16 +145,19 @@ def process_circuits( qkc = tk_to_qiskit(c) module, entry_points = to_qir_module(qkc) assert len(entry_points) == 1 + input_params = { + "entryPoint": entry_points[0], + "arguments": [], + "count": n_shots, + } + if option_params is not None: + input_params.update(option_params) job = self._target.submit( input_data=module.bitcode, input_data_format="qir.v1", output_data_format="microsoft.quantum-results.v1", name=f"job_{i}", - input_params={ - "entryPoint": entry_points[0], - "arguments": [], - "count": n_shots, - }, + input_params=input_params, ) jobid: str = job.id handle = ResultHandle(jobid) diff --git a/tests/backend_test.py b/tests/backend_test.py index a764fe8..02e05b3 100644 --- a/tests/backend_test.py +++ b/tests/backend_test.py @@ -14,6 +14,7 @@ from collections import Counter import os +from warnings import warn import pytest from pytket.circuit import Circuit from pytket.extensions.azure import AzureBackend @@ -33,16 +34,35 @@ def test_ionq_simulator(azure_backend: AzureBackend) -> None: r = b.get_result(h) counts = r.get_counts() assert counts == Counter({(0, 0): 5, (1, 1): 5}) + else: + warn("ionq.simulator unavailable or queue time >= 60s: not submitting") @pytest.mark.skipif(skip_remote_tests, reason=REASON) -@pytest.mark.parametrize("azure_backend", ["quantinuum.sim.h1-1e"], indirect=True) +@pytest.mark.parametrize("azure_backend", ["quantinuum.sim.h1-1sc"], indirect=True) def test_quantinuum_sim_h11e(azure_backend: AzureBackend) -> None: c = Circuit(2).H(0).CX(0, 1).measure_all() b = azure_backend c1 = b.get_compiled_circuit(c) - if b.is_available() and b.average_queue_time_s() < 600: + if b.is_available() and b.average_queue_time_s() < 60: h = b.process_circuit(c1, n_shots=1000) r = b.get_result(h) counts = r.get_counts() assert sum(counts.values()) == 1000 + else: + warn("quantinuum.sim.h1-1sc unavailable or queue time >= 60s: not submitting") + + +@pytest.mark.skipif(skip_remote_tests, reason=REASON) +@pytest.mark.parametrize("azure_backend", ["quantinuum.sim.h1-1e"], indirect=True) +def test_quantinuum_option_params(azure_backend: AzureBackend) -> None: + c = Circuit(2).H(0).CX(0, 1).measure_all() + b = azure_backend + c1 = b.get_compiled_circuit(c) + if b.is_available() and b.average_queue_time_s() < 600: + h = b.process_circuit(c1, n_shots=1000, option_params={"error_model": False}) + r = b.get_result(h) + counts = r.get_counts() + assert all(x0 == x1 for x0, x1 in counts.keys()) + else: + warn("quantinuum.sim.h1-1e unavailable or queue time >= 600s: not submitting")