From c886320f61af7e459ab4d955679d6ce1d29f1ea8 Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Tue, 15 Oct 2024 11:12:36 -0700 Subject: [PATCH 01/24] feat: Upgrade pyQuil to 4.17.4 --- CHANGELOG.md | 34 ++++++++++++++++++++-------------- requirements.txt | 2 +- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 660cae1e..2303d306 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ Changelog ========= +v0.10.0 (October 15, 2024) + +### Announcements + +- Upgrade pyQuil to a minimum of v4.14.3 (gh-240). + v0.9.0 (September 20, 2023) ------------------------------------------------------------------------------------ @@ -34,7 +40,7 @@ Improvements and Changes: - Add PyPI version and Slack badges (gh-196). - Add Zenodo badge and BibTeX file for citation (gh-197). -- Accommodate XY gate in `basic_compile` (gh-202). +- Accommodate XY gate in `basic_compile` (gh-202). - Increase PyQuil version requirement to accommodate XY gate (gh-203). @@ -43,7 +49,7 @@ v0.7 (September 20, 2019) Breaking Changes: - Major module re-org of superoperator tools into `operator_tools` also moved `random_operators` to the operator tools module. Added type checking in random operators, added new module to check plain old operators are unitary etc (gh-150, 140, 164). -- Remove symmetrization functionality from `observable_estimation` in favor of pyquil functionality (gh-194). +- Remove symmetrization functionality from `observable_estimation` in favor of pyquil functionality (gh-194). - Methods in `fitting` renamed to be less ambiguous `decay_constant_param_decay` -> `decay_time_param_decay` and `fit_decay_constant_param_decay` -> `fit_decay_time_param_decay`. Correspondingly, the fit parameter was renamed `decay_constant` -> `decay_time`(gh-175) @@ -51,19 +57,19 @@ Breaking Changes: - `acquire_cz_phase_ramsey_data` removed in favor of `estimate_observables` and all other specific `acquire_*` methods in `qubit_spectroscopy.py` were removed in favor of `acquire_qubit_spectroscopy_data` (gh-175) - argument order standardized, which changed the api of `generate_exhaustive_process_dfe_experiment`, -`generate_exhaustive_state_dfe_experiment`, `generate_monte_carlo_state_dfe_experiment`, -`generate_monte_carlo_process_dfe_experiment`, `robust_phase_estimate`, -and positional arg name of `acquire_dfe_data` (gh-182) +`generate_exhaustive_state_dfe_experiment`, `generate_monte_carlo_state_dfe_experiment`, +`generate_monte_carlo_process_dfe_experiment`, `robust_phase_estimate`, +and positional arg name of `acquire_dfe_data` (gh-182) Improvements and Changes: - Fixed the years in this Change log file 2018 -> 2019 - Added linear inversion process tomography (gh-142) -- Changed qubit tensor factor ordering of state tomography estimates to match that of process tomography, e.g. -tomographizing the plus eigenstate of `X0 * Z1` and passing in `qubits = [0,1]` will yield the state +- Changed qubit tensor factor ordering of state tomography estimates to match that of process tomography, e.g. +tomographizing the plus eigenstate of `X0 * Z1` and passing in `qubits = [0,1]` will yield the state estimate corresponding to `|+0> = (1, 0, 1, 0)/sqrt(2)` rather than `|0+>` (gh-142) - Improved the `superoperator_tools` notebook and the `random_operators` notebook (gh-98) -- Improvements to Ripple carry adder notebook, added tests for non parametric bit string +- Improvements to Ripple carry adder notebook, added tests for non parametric bit string prep program in utils (gh-98) - Added the ability to project a Choi matrix to the closest unitary (gh-159, 157) - Reduced local test run time from 11min to 5min (gh-160) @@ -100,7 +106,7 @@ Breaking Changes: - `operator_estimation.group_experiments` -> `observable_estimation.group_settings` -- `utils.all_pauli_terms` -> `utils.all_traceless_pauli_terms` +- `utils.all_pauli_terms` -> `utils.all_traceless_pauli_terms` - `DFEData` and `DFEEstimate` dataclasses removed in favor of `ExperimentResult` and tuple of results respectively (gh-134). @@ -108,13 +114,13 @@ Breaking Changes: - `pandas.DataFrame` is no longer used in `randomized_benchmarking` (gh-133), `qubit_spectroscopy` (gh-129), and `robust_phase_estimation` (gh-135). These now make use of `observable_estimation.ObservablesExperiment`, and as such the API has changed substantially. Please refer to example notebooks for new usage. -- `pandas.DataFrame` methods removed from `quantum_volume`. See examples notebook for alternative usage (gh-136). +- `pandas.DataFrame` methods removed from `quantum_volume`. See examples notebook for alternative usage (gh-136). - `utils.determine_simultaneous_grouping()` removed in favor of similar functionality in `observable_estimation.group_settings` - SIC state helpers removed from `utils` -- default `utils.str_to_pauli_term` now associates left-most character of input `pauli_str` with qubit 0. If `qubit_labels` are provided then the qubits label the characters in order. +- default `utils.str_to_pauli_term` now associates left-most character of input `pauli_str` with qubit 0. If `qubit_labels` are provided then the qubits label the characters in order. - `utils.all_pauli_*_terms` -> `utils.all_traceless_pauli_*_terms` to reflect fact that identity term is not included. @@ -131,8 +137,8 @@ Improvements and Changes: - optional symmetrization, which expands each program into a group of programs that accomplish symmetrization - data collection and optional `consolidate_symmetrization_outputs()` which collects data used for estimates - `calibrate_observable_estimates()` which can be used to update estimates after collecting calibration data - -- `plotting.state_process.plot_pauli_transfer_matrix()` now automatically casts input to `np.real_if_close` + +- `plotting.state_process.plot_pauli_transfer_matrix()` now automatically casts input to `np.real_if_close` - `_state_tomo_settings()` no longer includes all-Identity term. @@ -149,7 +155,7 @@ Improvements and Changes: - Added functoinality to `plotting` module: two ways to visualize a quantum state in the Pauli basis, plotting of a Pauli Transfer Matrix, plotting a real matrix using a Hinton diagram, the addition of the computational basis as a predefined basis object (gh-119) - Refactor iterative MLE to use ExperimentResults directly (gh-120) - Combined `graph_state` and `bell_state` modules into `entangled_state` module, added deprecation warnings for the old modules (gh-122) -- Made Ipython Notebooks a part of testing (gh-123) +- Made Ipython Notebooks a part of testing (gh-123) - Resolve test warnings and doc string formatting issues (gh-124) - **Breaking change.** Bump version and delete `graph_state` and `bell_state` modules (gh-125) - Added the ability to check if the Kraus operators are valid (PR 128) diff --git a/requirements.txt b/requirements.txt index f7b83301..24f9acca 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -pyquil>=4.5.0,<5.0.0 +pyquil>=4.14.3,<5.0.0 numpy networkx pandas From f7f4ca3232872b6edb5dcc2ab614d9234cc10233 Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Thu, 17 Oct 2024 09:27:07 -0700 Subject: [PATCH 02/24] update requirements --- requirements-ci.txt | 4 ++-- requirements.txt | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/requirements-ci.txt b/requirements-ci.txt index 1614112e..63b50e9f 100644 --- a/requirements-ci.txt +++ b/requirements-ci.txt @@ -88,14 +88,14 @@ pydantic==1.10.14 pyflakes==3.2.0 Pygments==2.17.2 pyparsing==3.1.1 -pyquil==4.5.0 +pyquil==4.14.3 pytest==7.4.4 pytest-cov==4.1.0 python-dateutil==2.8.2 python-rapidjson==1.14 pytz==2023.3.post1 pyzmq==25.1.2 -qcs-sdk-python==0.16.3 +qcs-sdk-python==0.20.1 qdldl==0.1.7.post0 quil==0.6.5 referenceqvm==0.3 diff --git a/requirements.txt b/requirements.txt index 24f9acca..fd7a472f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,6 +11,7 @@ cvxpy>=1.0.0 tqdm gitpython matplotlib>=3.1.0 +qcs-sdk-python>=0.20.1 # test dependencies flake8 From 3684e1278bfb7e682459781719c2bce6a298db1b Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Thu, 17 Oct 2024 09:34:35 -0700 Subject: [PATCH 03/24] update Python version in CI --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6c6d9c21..eaaf7f31 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8, 3.9, "3.10", "3.11"] + python-version: ["3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} From b572eb9f8e7d7281667d5471e63b1263012607de Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Thu, 17 Oct 2024 09:46:48 -0700 Subject: [PATCH 04/24] re-establish CI requirements --- requirements-ci.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/requirements-ci.txt b/requirements-ci.txt index 63b50e9f..8198fa72 100644 --- a/requirements-ci.txt +++ b/requirements-ci.txt @@ -33,14 +33,14 @@ gitdb==4.0.11 GitPython==3.1.41 h11==0.14.0 httpcore==1.0.2 -httpx==0.26.0 +httpx==0.27.0 idna==3.6 imagesize==1.4.1 importlib-metadata==7.0.1 importlib-resources==6.1.1 iniconfig==2.0.0 ipykernel==6.29.0 -ipython==8.12.3 +ipython==8.28.0 jedi==0.19.1 Jinja2==3.1.3 joblib==1.3.2 @@ -54,7 +54,7 @@ lark==0.11.3 lmfit==1.2.2 MarkupSafe==2.1.4 matplotlib==3.7.4 -matplotlib-inline==0.1.6 +matplotlib-inline==0.1.7 mccabe==0.7.0 mistune==3.0.2 mpmath==1.3.0 @@ -66,7 +66,7 @@ nbsphinx==0.9.3 nbval==0.10.0 nest-asyncio==1.6.0 networkx==3.1 -numpy==1.24.4 +numpy==1.25.0 osqp==0.6.3 packaging==23.2 pandas==2.0.3 @@ -97,7 +97,7 @@ pytz==2023.3.post1 pyzmq==25.1.2 qcs-sdk-python==0.20.1 qdldl==0.1.7.post0 -quil==0.6.5 +quil==0.11.2 referenceqvm==0.3 referencing==0.32.1 requests==2.31.0 @@ -106,7 +106,7 @@ rpds-py==0.17.1 ruamel.yaml==0.18.5 ruamel.yaml.clib==0.2.8 scikit-learn==1.3.2 -scipy==1.10.1 +scipy==1.11.4 scs==3.2.4.post1 seaborn==0.13.2 six==1.16.0 From b243e55fc13217341181a3e10f271c002fbf2488 Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Thu, 17 Oct 2024 09:52:02 -0700 Subject: [PATCH 05/24] try looser ipython requirement --- requirements-ci.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-ci.txt b/requirements-ci.txt index 8198fa72..b84d3494 100644 --- a/requirements-ci.txt +++ b/requirements-ci.txt @@ -40,7 +40,7 @@ importlib-metadata==7.0.1 importlib-resources==6.1.1 iniconfig==2.0.0 ipykernel==6.29.0 -ipython==8.28.0 +ipython>=8.0.0 jedi==0.19.1 Jinja2==3.1.3 joblib==1.3.2 From 4e7e8932266523036a1fef33b84223f8d6780cd4 Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Thu, 17 Oct 2024 11:56:37 -0700 Subject: [PATCH 06/24] specify/upgrade packaging --- requirements-ci.txt | 2 +- requirements.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements-ci.txt b/requirements-ci.txt index b84d3494..6e44f668 100644 --- a/requirements-ci.txt +++ b/requirements-ci.txt @@ -68,7 +68,7 @@ nest-asyncio==1.6.0 networkx==3.1 numpy==1.25.0 osqp==0.6.3 -packaging==23.2 +packaging==24.1 pandas==2.0.3 pandocfilters==1.5.1 parso==0.8.3 diff --git a/requirements.txt b/requirements.txt index fd7a472f..3934cdf5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ pyquil>=4.14.3,<5.0.0 numpy networkx +packaging pandas lmfit scipy From 46c8af5c56a45ae2df4587e2ceef94aa28b5de84 Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Thu, 17 Oct 2024 12:03:31 -0700 Subject: [PATCH 07/24] specify setuptools --- requirements-ci.txt | 3 ++- requirements.txt | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/requirements-ci.txt b/requirements-ci.txt index 6e44f668..ad061562 100644 --- a/requirements-ci.txt +++ b/requirements-ci.txt @@ -68,7 +68,7 @@ nest-asyncio==1.6.0 networkx==3.1 numpy==1.25.0 osqp==0.6.3 -packaging==24.1 +packaging==23.2 pandas==2.0.3 pandocfilters==1.5.1 parso==0.8.3 @@ -109,6 +109,7 @@ scikit-learn==1.3.2 scipy==1.11.4 scs==3.2.4.post1 seaborn==0.13.2 +setuptools=75.2.0 six==1.16.0 smmap==5.0.1 sniffio==1.3.0 diff --git a/requirements.txt b/requirements.txt index 3934cdf5..d6fea252 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,6 +5,7 @@ packaging pandas lmfit scipy +setuptools sympy python-rapidjson seaborn From d036ea1259c71f2b43bbbe85930f1957901ad423 Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Thu, 17 Oct 2024 12:05:11 -0700 Subject: [PATCH 08/24] fix specification --- requirements-ci.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-ci.txt b/requirements-ci.txt index ad061562..4039c96a 100644 --- a/requirements-ci.txt +++ b/requirements-ci.txt @@ -109,7 +109,7 @@ scikit-learn==1.3.2 scipy==1.11.4 scs==3.2.4.post1 seaborn==0.13.2 -setuptools=75.2.0 +setuptools==75.2.0 six==1.16.0 smmap==5.0.1 sniffio==1.3.0 From baeb89dfe55b9be25ff80b7cb31f794dc6f2b023 Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Thu, 17 Oct 2024 12:12:12 -0700 Subject: [PATCH 09/24] install distutils in runner --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eaaf7f31..2eeb231d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,13 +17,13 @@ jobs: steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Test (Python ${{ matrix.python-version }}) run: | docker run --rm -itd -p 5555:5555 rigetti/quilc -S docker run --rm -itd -p 5000:5000 rigetti/qvm -S - apt update -y && apt install -y libblas-dev liblapack-dev + apt update -y && apt install -y libblas-dev liblapack-dev python3-distutils pip install -r requirements-ci.txt && pip install -e . MPLBACKEND=Agg pytest From 02311287e520d03b645702e6ba77368c5921a6c4 Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Thu, 17 Oct 2024 12:14:17 -0700 Subject: [PATCH 10/24] try 3.10 distutils --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2eeb231d..263e22ce 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,6 +24,6 @@ jobs: run: | docker run --rm -itd -p 5555:5555 rigetti/quilc -S docker run --rm -itd -p 5000:5000 rigetti/qvm -S - apt update -y && apt install -y libblas-dev liblapack-dev python3-distutils + apt update -y && apt install -y libblas-dev liblapack-dev python3.10-distutils pip install -r requirements-ci.txt && pip install -e . MPLBACKEND=Agg pytest From 62f62a43325b606eafc213787b51175856d0da4d Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Thu, 17 Oct 2024 12:17:45 -0700 Subject: [PATCH 11/24] install setuptools first --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 263e22ce..096fc96c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,5 +25,6 @@ jobs: docker run --rm -itd -p 5555:5555 rigetti/quilc -S docker run --rm -itd -p 5000:5000 rigetti/qvm -S apt update -y && apt install -y libblas-dev liblapack-dev python3.10-distutils + pip install setuptools pip install -r requirements-ci.txt && pip install -e . MPLBACKEND=Agg pytest From 53f87de25aa1b5ce46608b3767fcac8e5c285312 Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Thu, 17 Oct 2024 12:21:16 -0700 Subject: [PATCH 12/24] upgrade numpy CI version --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index d6fea252..3e8d8434 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -pyquil>=4.14.3,<5.0.0 +eyquil>=4.14.3,<5.0.0 numpy networkx packaging From ae48b3d7f69a51cb079a5544fed12fb5dad84598 Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Thu, 17 Oct 2024 12:27:36 -0700 Subject: [PATCH 13/24] upgrade virtualenv as well --- .github/workflows/test.yml | 2 +- requirements-ci.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 096fc96c..f84f1b34 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,6 +25,6 @@ jobs: docker run --rm -itd -p 5555:5555 rigetti/quilc -S docker run --rm -itd -p 5000:5000 rigetti/qvm -S apt update -y && apt install -y libblas-dev liblapack-dev python3.10-distutils - pip install setuptools + pip install --upgrade setuptools virtualenv pip install -r requirements-ci.txt && pip install -e . MPLBACKEND=Agg pytest diff --git a/requirements-ci.txt b/requirements-ci.txt index 4039c96a..f821028e 100644 --- a/requirements-ci.txt +++ b/requirements-ci.txt @@ -66,7 +66,7 @@ nbsphinx==0.9.3 nbval==0.10.0 nest-asyncio==1.6.0 networkx==3.1 -numpy==1.25.0 +numpy==1.26.4 osqp==0.6.3 packaging==23.2 pandas==2.0.3 From 1e84d7936b0a314b38581d58eb9ad35513fc6f5a Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Thu, 17 Oct 2024 12:48:53 -0700 Subject: [PATCH 14/24] update test QVM creation --- forest/benchmarking/tests/conftest.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/forest/benchmarking/tests/conftest.py b/forest/benchmarking/tests/conftest.py index 1f02cf89..8005fea2 100644 --- a/forest/benchmarking/tests/conftest.py +++ b/forest/benchmarking/tests/conftest.py @@ -11,7 +11,7 @@ PATH = os.path.dirname(os.path.realpath(__file__)) -@pytest.fixture(scope='module') +@pytest.fixture(scope="module") def test_qc(): import networkx as nx from forest.benchmarking.compilation import basic_compile @@ -20,16 +20,18 @@ def test_qc(): from pyquil.gates import I class BasicQVMCompiler(AbstractCompiler): - def quil_to_native_quil(self, program: Program, protoquil=None): return basic_compile(program) def native_quil_to_executable(self, nq_program: Program): return nq_program + def reset(self): + pass + try: qc = QuantumComputer( - name='testing-qc', + name="testing-qc", qam=QVM(random_seed=52), compiler=BasicQVMCompiler( quantum_processor=NxQuantumProcessor(nx.complete_graph(2)), @@ -43,30 +45,35 @@ def native_quil_to_executable(self, nq_program: Program): return pytest.skip("This test requires a running local QVM: {}".format(e)) -@pytest.fixture(scope='module') +@pytest.fixture(scope="module") def qvm(): try: - qc = get_qc('9q-square-qvm', compiler_timeout=10.0) + qc = get_qc("9q-square-qvm", compiler_timeout=10.0) qc.run(Program(I(0))) return qc except (RequestError, TimeoutError) as e: - return pytest.skip("This test requires a running local QVM and quilc: {}".format(e)) + return pytest.skip( + "This test requires a running local QVM and quilc: {}".format(e) + ) -@pytest.fixture(scope='session') +@pytest.fixture(scope="session") def wfn(): return WavefunctionSimulator() -@pytest.fixture(scope='session') +@pytest.fixture(scope="session") def benchmarker(): try: benchmarker = BenchmarkConnection(timeout=10) benchmarker.apply_clifford_to_pauli(Program(I(0)), sX(0)) return benchmarker except (RequestError, TimeoutError) as e: - return pytest.skip("This test requires a running local benchmarker endpoint (ie quilc): {}" - .format(e)) + return pytest.skip( + "This test requires a running local benchmarker endpoint (ie quilc): {}".format( + e + ) + ) def pytest_addoption(parser): From b1eef4eb31b5635c0f93f6d2c6d3b2e027355c73 Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Thu, 17 Oct 2024 13:08:18 -0700 Subject: [PATCH 15/24] use assert_almost_equal --- forest/benchmarking/tests/test_direct_fidelity_estimation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/forest/benchmarking/tests/test_direct_fidelity_estimation.py b/forest/benchmarking/tests/test_direct_fidelity_estimation.py index 3e216c13..90b0deec 100755 --- a/forest/benchmarking/tests/test_direct_fidelity_estimation.py +++ b/forest/benchmarking/tests/test_direct_fidelity_estimation.py @@ -46,7 +46,7 @@ def test_exhaustive_process_dfe_run(benchmarker: BenchmarkConnection): prog += process expectation = wfnsim.reset().do_program(prog).expectation(setting.observable) - assert expectation == 1. + assert_almost_equal(expectation, 1.0) def test_exhaustive_state_dfe_run(benchmarker: BenchmarkConnection): @@ -62,7 +62,7 @@ def test_exhaustive_state_dfe_run(benchmarker: BenchmarkConnection): prog += process expectation = wfnsim.reset().do_program(prog).expectation(setting.observable) - assert expectation == 1. + assert_almost_equal(expectation, 1.0) def test_exhaustive_process_dfe_analytical(benchmarker: BenchmarkConnection, qvm): From 389aa973d52644fb9e23b95165e01f7a56f34fa1 Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Thu, 17 Oct 2024 13:46:55 -0700 Subject: [PATCH 16/24] fix quantum_volume parsing --- forest/benchmarking/quantum_volume.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/forest/benchmarking/quantum_volume.py b/forest/benchmarking/quantum_volume.py index 4c876484..d1ef6215 100644 --- a/forest/benchmarking/quantum_volume.py +++ b/forest/benchmarking/quantum_volume.py @@ -66,14 +66,14 @@ def _naive_program_generator(qc: QuantumComputer, qubits: Sequence[int], new_1q = {} for key, val in single_qs.items(): if int(key) in qubits: - new_1q[key] = val + new_1q[key] = dict(val.dict()) new_2q = {} for key, val in two_qs.items(): - q1, q2 = key.split('-') + q1, q2 = key.split("-") if int(q1) in qubits and int(q2) in qubits: - new_2q[key] = val + new_2q[key] = val.dict() - new_isa = CompilerISA.parse_obj({'1Q': new_1q, '2Q': new_2q}) + new_isa = CompilerISA.parse_obj({"1Q": new_1q, "2Q": new_2q}) new_compiler = copy(qc.compiler) new_compiler.target_device = TargetDevice(isa=new_isa.dict(by_alias=True), specs={}) From e29927bd3ecca2d66131e50cc89223a7e667ad67 Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Thu, 17 Oct 2024 13:47:27 -0700 Subject: [PATCH 17/24] remove pydantic --- requirements-ci.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements-ci.txt b/requirements-ci.txt index f821028e..5b4650da 100644 --- a/requirements-ci.txt +++ b/requirements-ci.txt @@ -84,7 +84,6 @@ ptyprocess==0.7.0 pure-eval==0.2.2 pybind11==2.11.1 pycodestyle==2.11.1 -pydantic==1.10.14 pyflakes==3.2.0 Pygments==2.17.2 pyparsing==3.1.1 From 3594d2717c2825b560a1a36754b7e5547b07657c Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Thu, 17 Oct 2024 14:12:30 -0700 Subject: [PATCH 18/24] increase timeouts --- forest/benchmarking/tests/conftest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/forest/benchmarking/tests/conftest.py b/forest/benchmarking/tests/conftest.py index 8005fea2..18c0c3b4 100644 --- a/forest/benchmarking/tests/conftest.py +++ b/forest/benchmarking/tests/conftest.py @@ -35,7 +35,7 @@ def reset(self): qam=QVM(random_seed=52), compiler=BasicQVMCompiler( quantum_processor=NxQuantumProcessor(nx.complete_graph(2)), - timeout=10.0, + timeout=20.0, client_configuration=None, ), ) @@ -65,7 +65,7 @@ def wfn(): @pytest.fixture(scope="session") def benchmarker(): try: - benchmarker = BenchmarkConnection(timeout=10) + benchmarker = BenchmarkConnection(timeout=30) benchmarker.apply_clifford_to_pauli(Program(I(0)), sX(0)) return benchmarker except (RequestError, TimeoutError) as e: From a87aa6ac2d296acf5a5abcb4240850b028330728 Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Thu, 17 Oct 2024 14:25:09 -0700 Subject: [PATCH 19/24] revert autoformatting changes --- forest/benchmarking/tests/conftest.py | 14 ++++++-------- requirements.txt | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/forest/benchmarking/tests/conftest.py b/forest/benchmarking/tests/conftest.py index 18c0c3b4..64e2d20b 100644 --- a/forest/benchmarking/tests/conftest.py +++ b/forest/benchmarking/tests/conftest.py @@ -45,26 +45,24 @@ def reset(self): return pytest.skip("This test requires a running local QVM: {}".format(e)) -@pytest.fixture(scope="module") +@pytest.fixture(scope='module') def qvm(): try: - qc = get_qc("9q-square-qvm", compiler_timeout=10.0) + qc = get_qc('9q-square-qvm', compiler_timeout=10.0) qc.run(Program(I(0))) return qc except (RequestError, TimeoutError) as e: - return pytest.skip( - "This test requires a running local QVM and quilc: {}".format(e) - ) + return pytest.skip("This test requires a running local QVM and quilc: {}".format(e)) -@pytest.fixture(scope="session") +@pytest.fixture(scope='session') def wfn(): return WavefunctionSimulator() -@pytest.fixture(scope="session") +@pytest.fixture(scope='session') def benchmarker(): - try: + try(: benchmarker = BenchmarkConnection(timeout=30) benchmarker.apply_clifford_to_pauli(Program(I(0)), sX(0)) return benchmarker diff --git a/requirements.txt b/requirements.txt index 3e8d8434..d6fea252 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -eyquil>=4.14.3,<5.0.0 +pyquil>=4.14.3,<5.0.0 numpy networkx packaging From ed17b7e0df15b09c4f10d7137562fd385e0855d7 Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Thu, 17 Oct 2024 14:26:19 -0700 Subject: [PATCH 20/24] remove setuptools from ci requirements --- requirements-ci.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements-ci.txt b/requirements-ci.txt index 5b4650da..65db8842 100644 --- a/requirements-ci.txt +++ b/requirements-ci.txt @@ -108,7 +108,6 @@ scikit-learn==1.3.2 scipy==1.11.4 scs==3.2.4.post1 seaborn==0.13.2 -setuptools==75.2.0 six==1.16.0 smmap==5.0.1 sniffio==1.3.0 From a647ff112a991526d4b67876a46022faf0bf5327 Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Thu, 17 Oct 2024 14:30:37 -0700 Subject: [PATCH 21/24] replace more " with ' --- forest/benchmarking/quantum_volume.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/forest/benchmarking/quantum_volume.py b/forest/benchmarking/quantum_volume.py index d1ef6215..34deefd9 100644 --- a/forest/benchmarking/quantum_volume.py +++ b/forest/benchmarking/quantum_volume.py @@ -69,11 +69,11 @@ def _naive_program_generator(qc: QuantumComputer, qubits: Sequence[int], new_1q[key] = dict(val.dict()) new_2q = {} for key, val in two_qs.items(): - q1, q2 = key.split("-") + q1, q2 = key.split('-') if int(q1) in qubits and int(q2) in qubits: new_2q[key] = val.dict() - new_isa = CompilerISA.parse_obj({"1Q": new_1q, "2Q": new_2q}) + new_isa = CompilerISA.parse_obj({'1Q': new_1q, '2Q': new_2q}) new_compiler = copy(qc.compiler) new_compiler.target_device = TargetDevice(isa=new_isa.dict(by_alias=True), specs={}) From 49c9bef62889f3f0892aa8b783625211fa8b3a79 Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Thu, 17 Oct 2024 14:32:33 -0700 Subject: [PATCH 22/24] lower, more consistent, timeout --- forest/benchmarking/tests/conftest.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/forest/benchmarking/tests/conftest.py b/forest/benchmarking/tests/conftest.py index 64e2d20b..7e8fd09c 100644 --- a/forest/benchmarking/tests/conftest.py +++ b/forest/benchmarking/tests/conftest.py @@ -35,7 +35,7 @@ def reset(self): qam=QVM(random_seed=52), compiler=BasicQVMCompiler( quantum_processor=NxQuantumProcessor(nx.complete_graph(2)), - timeout=20.0, + timeout=15.0, client_configuration=None, ), ) @@ -45,24 +45,26 @@ def reset(self): return pytest.skip("This test requires a running local QVM: {}".format(e)) -@pytest.fixture(scope='module') +@pytest.fixture(scope="module") def qvm(): try: - qc = get_qc('9q-square-qvm', compiler_timeout=10.0) + qc = get_qc("9q-square-qvm", compiler_timeout=15.0) qc.run(Program(I(0))) return qc except (RequestError, TimeoutError) as e: - return pytest.skip("This test requires a running local QVM and quilc: {}".format(e)) + return pytest.skip( + "This test requires a running local QVM and quilc: {}".format(e) + ) -@pytest.fixture(scope='session') +@pytest.fixture(scope="session") def wfn(): return WavefunctionSimulator() -@pytest.fixture(scope='session') +@pytest.fixture(scope="session") def benchmarker(): - try(: + try: benchmarker = BenchmarkConnection(timeout=30) benchmarker.apply_clifford_to_pauli(Program(I(0)), sX(0)) return benchmarker From 4f9a600ccaadd4da2e4b23b85284fa76768d9ba2 Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Fri, 18 Oct 2024 09:37:06 -0700 Subject: [PATCH 23/24] remove extraneous cast --- forest/benchmarking/quantum_volume.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forest/benchmarking/quantum_volume.py b/forest/benchmarking/quantum_volume.py index 34deefd9..5b26a953 100644 --- a/forest/benchmarking/quantum_volume.py +++ b/forest/benchmarking/quantum_volume.py @@ -66,7 +66,7 @@ def _naive_program_generator(qc: QuantumComputer, qubits: Sequence[int], new_1q = {} for key, val in single_qs.items(): if int(key) in qubits: - new_1q[key] = dict(val.dict()) + new_1q[key] = val.dict() new_2q = {} for key, val in two_qs.items(): q1, q2 = key.split('-') From 71dffbf77ed3feb477839cf90010c2eb822d6659 Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Fri, 18 Oct 2024 09:38:48 -0700 Subject: [PATCH 24/24] formatting fixes --- forest/benchmarking/tests/conftest.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/forest/benchmarking/tests/conftest.py b/forest/benchmarking/tests/conftest.py index 7e8fd09c..897af0d9 100644 --- a/forest/benchmarking/tests/conftest.py +++ b/forest/benchmarking/tests/conftest.py @@ -45,24 +45,22 @@ def reset(self): return pytest.skip("This test requires a running local QVM: {}".format(e)) -@pytest.fixture(scope="module") +@pytest.fixture(scope='module') def qvm(): try: - qc = get_qc("9q-square-qvm", compiler_timeout=15.0) + qc = get_qc('9q-square-qvm', compiler_timeout=15.0) qc.run(Program(I(0))) return qc except (RequestError, TimeoutError) as e: - return pytest.skip( - "This test requires a running local QVM and quilc: {}".format(e) - ) + return pytest.skip("This test requires a running local QVM and quilc: {}".format(e)) -@pytest.fixture(scope="session") +@pytest.fixture(scope='session') def wfn(): return WavefunctionSimulator() -@pytest.fixture(scope="session") +@pytest.fixture(scope='session') def benchmarker(): try: benchmarker = BenchmarkConnection(timeout=30)