Skip to content

Commit

Permalink
Merge branch 'main' into fix/table
Browse files Browse the repository at this point in the history
  • Loading branch information
cqc-melf authored Jan 24, 2025
2 parents 40fc233 + 2b358b5 commit 468cd54
Show file tree
Hide file tree
Showing 23 changed files with 262 additions and 112 deletions.
33 changes: 0 additions & 33 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,36 +113,3 @@ jobs:
user: __token__
password: ${{ secrets.PYPI_PYTKET_QISKIT_API_TOKEN }}
verbose: true

build_docs:
name: Build docs
if: github.event_name == 'release'
needs: publish_to_pypi
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Download all wheels
uses: actions/download-artifact@v4
with:
path: wheelhouse
- name: Install pip, wheel
run: pip install -U pip wheel
- name: Install poetry
run: pip install poetry
- name: Install extension
run: for w in `find wheelhouse/ -type f -name "*.whl"` ; do poetry install $w ; done
- name: Install docs dependencies
run: |
cd docs
poetry install
- name: Build docs
timeout-minutes: 20
run: |
cd docs
poetry run bash ./build-docs.sh
33 changes: 0 additions & 33 deletions .github/workflows/docs.yml

This file was deleted.

2 changes: 1 addition & 1 deletion _metadata.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__extension_version__ = "0.62.0"
__extension_version__ = "0.63.0"
__extension_name__ = "pytket-qiskit"
5 changes: 4 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

# Changelog

## Unreleased
## 0.63.0 (January 2025)

- Support conversion of qiskit circuits containing `IfElseOp` in the {py:func}`qiskit_to_tk` converter. Note: Only conditions on a single bit are supported currently. Handling of more general conditions will be added in future.
- Reject circuits containing nested conditionals when converting to qiskit.
- Update pytket version requirement to 1.39.0.
- Add support for fractional gates on backends that support them.

## 0.62.0 (December 2024)

Expand Down
2 changes: 1 addition & 1 deletion pytket/extensions/qiskit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2024 Quantinuum
# Copyright Quantinuum
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion pytket/extensions/qiskit/backends/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2024 Quantinuum
# Copyright Quantinuum
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion pytket/extensions/qiskit/backends/aer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2024 Quantinuum
# Copyright Quantinuum
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion pytket/extensions/qiskit/backends/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021-2023 Cambridge Quantum Computing
# Copyright Quantinuum
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion pytket/extensions/qiskit/backends/crosstalk_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2024 Quantinuum
# Copyright Quantinuum
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
42 changes: 32 additions & 10 deletions pytket/extensions/qiskit/backends/ibm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2024 Quantinuum
# Copyright Quantinuum
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -49,6 +49,7 @@
from pytket.circuit import Bit, Circuit, OpType
from pytket.passes import (
AutoRebase,
AutoSquash,
BasePass,
CliffordSimp,
CustomPass,
Expand Down Expand Up @@ -128,13 +129,16 @@ def _save_ibmq_auth(qiskit_config: Optional[QiskitConfig]) -> None:
)


ALL_PRIMITIVE_1Q_GATES: set[OpType] = {OpType.Rx, OpType.Rz, OpType.SX, OpType.X}
ALL_PRIMITIVE_2Q_GATES: set[OpType] = {OpType.CX, OpType.CZ, OpType.ECR, OpType.ZZPhase}


def _get_primitive_gates(gateset: set[OpType]) -> set[OpType]:
if gateset >= {OpType.X, OpType.SX, OpType.Rz, OpType.CX}:
return {OpType.X, OpType.SX, OpType.Rz, OpType.CX}
elif gateset >= {OpType.X, OpType.SX, OpType.Rz, OpType.ECR}:
return {OpType.X, OpType.SX, OpType.Rz, OpType.ECR}
else:
return gateset
return gateset & (ALL_PRIMITIVE_1Q_GATES | ALL_PRIMITIVE_2Q_GATES)


def _get_primitive_1q_gates(gateset: set[OpType]) -> set[OpType]:
return gateset & ALL_PRIMITIVE_1Q_GATES


def _int_from_readout(readout: np.ndarray) -> int:
Expand All @@ -161,6 +165,9 @@ class IBMQBackend(Backend):
See the Qiskit documentation at
https://docs.quantum.ibm.com/api/qiskit-ibm-runtime/qiskit_ibm_runtime.options.SamplerOptions
for details and default values.
:param use_fractional_gates: Whether to use native "fractional gates" on the device
if available. See https://docs.quantum.ibm.com/guides/fractional-gates (default
False).
"""

_supports_shots = False
Expand All @@ -176,6 +183,7 @@ def __init__(
service: Optional[QiskitRuntimeService] = None,
token: Optional[str] = None,
sampler_options: SamplerOptions = None,
use_fractional_gates: bool = False,
):
super().__init__()
self._pytket_config = QiskitConfig.from_default_config_file()
Expand All @@ -184,7 +192,9 @@ def __init__(
if service is None
else service
)
self._backend: IBMBackend = self._service.backend(backend_name)
self._backend: IBMBackend = self._service.backend(
backend_name, use_fractional_gates=use_fractional_gates
)
config: PulseBackendConfiguration = self._backend.configuration()
self._max_per_job = getattr(config, "max_experiments", 1)

Expand All @@ -198,6 +208,7 @@ def __init__(
self._session = Session(backend=self._backend)

self._primitive_gates = _get_primitive_gates(gate_set)
self._primitive_1q_gates = _get_primitive_1q_gates(gate_set)

self._supports_rz = OpType.Rz in self._primitive_gates

Expand Down Expand Up @@ -389,7 +400,9 @@ def default_compilation_pass_offline(
timeout: int = 300,
) -> BasePass:
backend_info = IBMQBackend._get_backend_info(config, props)
primitive_gates = _get_primitive_gates(_tk_gate_set(config))
tk_gate_set = _tk_gate_set(config)
primitive_gates = _get_primitive_gates(tk_gate_set)
primitive_1q_gates = _get_primitive_1q_gates(tk_gate_set)
supports_rz = OpType.Rz in primitive_gates

assert optimisation_level in range(4)
Expand All @@ -406,6 +419,7 @@ def default_compilation_pass_offline(
passlist.append(IBMQBackend.rebase_pass_offline(primitive_gates))
elif optimisation_level == 1:
passlist.append(SynthesiseTket())
passlist.append(IBMQBackend.squash_pass_offline(primitive_1q_gates))
elif optimisation_level == 2:
passlist.append(FullPeepholeOptimise())
elif optimisation_level == 3:
Expand Down Expand Up @@ -464,7 +478,11 @@ def default_compilation_pass_offline(
if optimisation_level == 3:
passlist.append(SynthesiseTket())
passlist.extend(
[IBMQBackend.rebase_pass_offline(primitive_gates), RemoveRedundancies()]
[
IBMQBackend.rebase_pass_offline(primitive_gates),
IBMQBackend.squash_pass_offline(primitive_1q_gates),
RemoveRedundancies(),
]
)
return SequencePass(passlist)

Expand Down Expand Up @@ -549,6 +567,10 @@ def rebase_pass(self) -> BasePass:
def rebase_pass_offline(primitive_gates: set[OpType]) -> BasePass:
return AutoRebase(primitive_gates)

@staticmethod
def squash_pass_offline(primitive_1q_gates: set[OpType]) -> BasePass:
return AutoSquash(primitive_1q_gates)

def process_circuits(
self,
circuits: Sequence[Circuit],
Expand Down
2 changes: 1 addition & 1 deletion pytket/extensions/qiskit/backends/ibm_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019 Cambridge Quantum Computing
# Copyright Quantinuum
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 3 additions & 1 deletion pytket/extensions/qiskit/backends/ibmq_emulator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2024 Quantinuum
# Copyright Quantinuum
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -58,13 +58,15 @@ def __init__(
instance: Optional[str] = None,
service: Optional["QiskitRuntimeService"] = None,
token: Optional[str] = None,
use_fractional_gates: bool = False,
):
super().__init__()
self._ibmq = IBMQBackend(
backend_name=backend_name,
instance=instance,
service=service,
token=token,
use_fractional_gates=use_fractional_gates,
)

# Get noise model:
Expand Down
Loading

0 comments on commit 468cd54

Please sign in to comment.