diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6c6d9c21..f84f1b34 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,17 +13,18 @@ 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 }} - 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.10-distutils + pip install --upgrade setuptools virtualenv pip install -r requirements-ci.txt && pip install -e . MPLBACKEND=Agg pytest 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/forest/benchmarking/quantum_volume.py b/forest/benchmarking/quantum_volume.py index 4c876484..5b26a953 100644 --- a/forest/benchmarking/quantum_volume.py +++ b/forest/benchmarking/quantum_volume.py @@ -66,12 +66,12 @@ 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] = val.dict() new_2q = {} for key, val in two_qs.items(): 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}) diff --git a/forest/benchmarking/tests/conftest.py b/forest/benchmarking/tests/conftest.py index 1f02cf89..897af0d9 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,20 +20,22 @@ 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)), - timeout=10.0, + timeout=15.0, client_configuration=None, ), ) @@ -46,7 +48,7 @@ def native_quil_to_executable(self, nq_program: Program): @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: @@ -61,12 +63,15 @@ 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: - 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): 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): diff --git a/requirements-ci.txt b/requirements-ci.txt index 1614112e..65db8842 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.0.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.26.4 osqp==0.6.3 packaging==23.2 pandas==2.0.3 @@ -84,20 +84,19 @@ 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 -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 +quil==0.11.2 referenceqvm==0.3 referencing==0.32.1 requests==2.31.0 @@ -106,7 +105,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 diff --git a/requirements.txt b/requirements.txt index f7b83301..d6fea252 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,11 @@ -pyquil>=4.5.0,<5.0.0 +pyquil>=4.14.3,<5.0.0 numpy networkx +packaging pandas lmfit scipy +setuptools sympy python-rapidjson seaborn @@ -11,6 +13,7 @@ cvxpy>=1.0.0 tqdm gitpython matplotlib>=3.1.0 +qcs-sdk-python>=0.20.1 # test dependencies flake8