diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..558b033 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,15 @@ +# Description + +Please summarise the changes. + +# Related issues + +Please mention any github issues addressed by this PR. + +# Checklist + +- [ ] I have performed a self-review of my code. +- [ ] I have commented hard-to-understand parts of my code. +- [ ] I have made corresponding changes to the public API documentation. +- [ ] I have added tests that prove my fix is effective or that my feature works. +- [ ] I have updated the changelog with any user-facing changes. diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 004c9c1..6deb3e0 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -37,7 +37,7 @@ jobs: docker pull rigetti/qvm - name: Set up Python 3.9 if: github.event_name == 'push' || github.event_name == 'schedule' - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.9' - name: Build and test (3.9) @@ -46,7 +46,7 @@ jobs: run: | ./.github/workflows/build-test nomypy - name: Set up Python 3.10 - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.10' - name: Build and test including remote checks (3.10) mypy @@ -61,7 +61,7 @@ jobs: ./.github/workflows/build-test nomypy - name: Set up Python 3.11 if: github.event_name == 'push' || github.event_name == 'pull_request' || github.event_name == 'schedule' - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.11' - name: Build and test (3.11) @@ -69,10 +69,10 @@ jobs: shell: bash run: | ./.github/workflows/build-test nomypy - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: github.event_name == 'release' || contains(github.ref, 'refs/heads/wheel') with: - name: artefacts + name: artefact-${{ matrix.os }} path: wheelhouse/ - name: Install docs dependencies if: (matrix.os == 'ubuntu-22.04') && (github.event_name == 'pull_request' || github.event_name == 'schedule' ) @@ -92,9 +92,13 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Download all wheels - uses: actions/download-artifact@v3 + # downloading all three files into the wheelhouse + # all files are identical, so there will only be one file + uses: actions/download-artifact@v4 with: path: wheelhouse + pattern: artefact-* + merge-multiple: true - name: Put them all in the dist folder run: | mkdir dist @@ -116,11 +120,11 @@ jobs: with: fetch-depth: '0' - name: Set up Python 3.10 - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.10' - name: Download all wheels - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: path: wheelhouse - name: Install pip, wheel @@ -137,7 +141,7 @@ jobs: mkdir extensions ./build-docs -d ${GITHUB_WORKSPACE}/.github/workflows/docs/extensions/api - name: Upload docs as artefact - uses: actions/upload-pages-artifact@v2 + uses: actions/upload-pages-artifact@v3 with: path: .github/workflows/docs/extensions @@ -155,4 +159,4 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v2 + uses: actions/deploy-pages@v4.0.1 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index ec7a88d..e10ca09 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python 3.9 - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.9' - name: Upgrade pip and install wheel @@ -31,7 +31,7 @@ jobs: cd .github/workflows/docs mkdir extensions ./build-docs -d ${GITHUB_WORKSPACE}/.github/workflows/docs/extensions - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: pytket-extension-docs path: .github/workflows/docs/extensions/ diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index bed8273..8af01e0 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python 3.x - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.x' - name: Update pip diff --git a/README.md b/README.md index 192a28c..fff0122 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ tests and is accepted after review, it will be merged in. All code should be formatted using [black](https://black.readthedocs.io/en/stable/), with default options. This is -checked on the CI. The CI is currently using version 20.8b1. +checked on the CI. The CI is currently using version 22.3. #### Type annotation diff --git a/_metadata.py b/_metadata.py index 18add0d..9cc5c03 100644 --- a/_metadata.py +++ b/_metadata.py @@ -1,2 +1,2 @@ -__extension_version__ = "0.31.0" +__extension_version__ = "0.32.0" __extension_name__ = "pytket-pyquil" diff --git a/docs/changelog.rst b/docs/changelog.rst index 043990a..91a5e8c 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,6 +1,12 @@ Changelog ~~~~~~~~~ +0.32.0 (January 2024) +--------------------- + +* Updated pytket version requirement to 1.23. +* Don’t include :py:class:`SimplifyInitial` in default passes; instead make it an option to ``process_circuits()``. + 0.31.0 (November 2023) ---------------------- diff --git a/pytket/extensions/pyquil/backends/forest.py b/pytket/extensions/pyquil/backends/forest.py index 76b5eb5..4444cb0 100644 --- a/pytket/extensions/pyquil/backends/forest.py +++ b/pytket/extensions/pyquil/backends/forest.py @@ -46,6 +46,7 @@ EulerAngleReduction, CXMappingPass, auto_rebase_pass, + KAKDecomposition, SequencePass, SynthesiseTket, DecomposeBoxes, @@ -165,18 +166,16 @@ def default_compilation_pass(self, optimisation_level: int = 2) -> BasePass: ) passlist.append(NaivePlacementPass(self.backend_info.architecture)) # type: ignore if optimisation_level == 2: - passlist.append(CliffordSimp(False)) + # Add some connectivity preserving optimisations after routing. + passlist.extend( + [KAKDecomposition(allow_swaps=False), CliffordSimp(allow_swaps=False)] + ) if optimisation_level > 0: passlist.append(SynthesiseTket()) passlist.append(self.rebase_pass()) if optimisation_level > 0: - passlist.extend( - [ - EulerAngleReduction(OpType.Rx, OpType.Rz), - SimplifyInitial( - allow_classical=False, create_all_qubits=True, xcirc=_xcirc - ), - ] + passlist.append( + EulerAngleReduction(OpType.Rx, OpType.Rz), ) return SequencePass(passlist) @@ -193,7 +192,15 @@ def process_circuits( ) -> List[ResultHandle]: """ See :py:meth:`pytket.backends.Backend.process_circuits`. - Supported kwargs: `seed`. + + Supported kwargs: + + * `seed` + * `postprocess`: apply end-of-circuit simplifications and classical + postprocessing to improve fidelity of results (bool, default False) + * `simplify_initial`: apply the pytket ``SimplifyInitial`` pass to improve + fidelity of results assuming all qubits initialized to zero (bool, default + False) """ circuits = list(circuits) n_shots_list = Backend._get_n_shots_as_list( @@ -204,6 +211,7 @@ def process_circuits( self._check_all_circuits(circuits) postprocess = kwargs.get("postprocess", False) + simplify_initial = kwargs.get("simplify_initial", False) handle_list = [] for circuit, n_shots in zip(circuits, n_shots_list): @@ -212,6 +220,13 @@ def process_circuits( ppcirc_rep = ppcirc.to_dict() else: c0, ppcirc_rep = circuit, None + + if simplify_initial: + _x_circ = Circuit(1).Rx(1, 0) + SimplifyInitial( + allow_classical=False, create_all_qubits=True, xcirc=_x_circ + ).apply(circuit) + p, bits = tk_to_pyquil(c0, return_used_bits=True) p.wrap_in_numshots_loop(n_shots) ex = self._qc.compiler.native_quil_to_executable(p) @@ -285,7 +300,7 @@ def backend_info(self) -> BackendInfo: @classmethod def _get_backend_info(cls, qc: QuantumComputer) -> BackendInfo: char_dict: dict = process_characterisation(qc) - arch = char_dict.get("Architecture", Architecture([])) + arch = char_dict.get("Architecture") node_errors = char_dict.get("NodeErrors") link_errors: dict[tuple[Node, Node], float] = char_dict.get("EdgeErrors") # type: ignore averaged_errors = get_avg_characterisation(char_dict) diff --git a/setup.py b/setup.py index 0386ed1..0ecede0 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ author_email="tket-support@cambridgequantum.com", python_requires=">=3.8", project_urls={ - "Documentation": "https://tket.quantinuum.com/extensions/pytket-pyquil/api/index.html", + "Documentation": "https://tket.quantinuum.com/extensions/pytket-pyquil/index.html", "Source": "https://github.com/CQCL/pytket-pyquil", "Tracker": "https://github.com/CQCL/pytket-pyquil/issues", }, @@ -44,7 +44,7 @@ packages=find_namespace_packages(include=["pytket.*"]), include_package_data=True, install_requires=[ - "pytket ~= 1.22", + "pytket ~= 1.23", "pyquil ~= 3.5", "typing-extensions ~= 4.2", ],