Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/pip/doc/protobuf-3.18.3
Browse files Browse the repository at this point in the history
  • Loading branch information
lillian542 authored Dec 14, 2023
2 parents f14629a + 0b37719 commit 0beb51e
Show file tree
Hide file tree
Showing 26 changed files with 264 additions and 189 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.9

- name: Install dependencies
run: pip install black
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, '3.10']
python-version: [3.9, '3.10', '3.11']

steps:
- name: Cancel Previous Runs
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
python -m pip install --upgrade pip
pip install -r requirements-ci.txt
pip install qsimcirq
pip install wheel pytest pytest-cov pytest-mock flaky --upgrade
pip install wheel pytest pytest-cov pytest-mock pytest-benchmark flaky --upgrade
- name: Install Plugin
run: |
Expand All @@ -83,6 +83,7 @@ jobs:
pl-device-test --device=cirq.simulator --tb=short --skip-ops --analytic=False --shots=20000 --cov=pennylane_cirq --cov-report=xml
pl-device-test --device=cirq.mixedsimulator --tb=short --skip-ops --analytic=True --cov=pennylane_cirq --cov-report=xml
pl-device-test --device=cirq.mixedsimulator --tb=short --skip-ops --analytic=False --shots=20000 --cov=pennylane_cirq --cov-report=xml
pl-device-test --device=cirq.pasqal --tb=short --skip-ops --analytic=False --shots=20000 --device-kwargs control_radius=2. --cov=pennylane_cirq --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
python -m pytest tests --tb=native
- name: Publish
uses: pypa/gh-action-pypi-publish@master
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI }}
7 changes: 5 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ formats:

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.8
install:
- requirements: doc/requirements.txt
- method: pip
path: .

build:
image: latest
os: ubuntu-22.04
tools:
python: "3.9"
apt_packages:
- graphviz
74 changes: 74 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,77 @@
# Release 0.34.0-dev

### New features since last release

### Improvements 🛠

### Breaking changes 💔

### Deprecations 👋

### Documentation 📝

### Bug fixes 🐛

### Tests

* The sampling tests no longer set the `_obs_queue` proprerty, as setting it has no effect on the behaviour of the plugin.
[(#159)](https://github.com/PennyLaneAI/pennylane-cirq/pull/159)

### Contributors ✍️

This release contains contributions from (in alphabetical order):

Christina Lee

---
# Release 0.33.0

### Bug fixes 🐛

* Fixes the pasqal device when more than one circuit is executed and adds support
for specifying `wires` an iterable of wire labels.
[(#151)](https://github.com/PennyLaneAI/pennylane-cirq/pull/151)

### Contributors ✍️

This release contains contributions from (in alphabetical order):

Christina Lee

---
# Release 0.32.0

### Breaking changes 💔

* Python 3.8 support is dropped and Python 3.11 support is added.
[(#146)](https://github.com/PennyLaneAI/pennylane-cirq/pull/146)

### Bug fixes 🐛

* The plugin is updated to take `qml.StatePrep` operators, the new name for `qml.QubitStateVector`.
[(#146)](https://github.com/PennyLaneAI/pennylane-cirq/pull/146)

### Contributors ✍️

This release contains contributions from (in alphabetical order):

Christina Lee

---
# Release 0.31.0

### Improvements

* Failing tests corrected to reflect the new shots validation in PennyLane
[(#138)](https://github.com/PennyLaneAI/pennylane-cirq/pull/138)

### Contributors

This release contains contributions from (in alphabetical order):

Matthew Silverman

---
# Release 0.29.0

### New features since last release
Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PennyLane-Cirq Plugin
######################

.. image:: https://img.shields.io/github/workflow/status/PennyLaneAI/pennylane-cirq/Tests/master?logo=github&style=flat-square
.. image:: https://img.shields.io/github/actions/workflow/status/PennyLaneAI/pennylane-cirq/tests.yml?branch=master&logo=github&style=flat-square
:alt: GitHub Workflow Status (branch)
:target: https://github.com/PennyLaneAI/pennylane-cirq/actions?query=workflow%3ATests

Expand Down Expand Up @@ -57,7 +57,7 @@ Features
Installation
============

This plugin requires Python version 3.8 or above, as well as PennyLane
This plugin requires Python version 3.9 or above, as well as PennyLane
and Cirq. Installation of this plugin, as well as all dependencies, can be done using ``pip``:

.. code-block:: bash
Expand All @@ -76,7 +76,7 @@ Dependencies

PennyLane-Cirq requires the following libraries be installed:

* `Python <http://python.org/>`__ >= 3.8
* `Python <http://python.org/>`__ >= 3.9

as well as the following Python packages:

Expand Down
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class TypeMock(type):

# General information about the project.
project = "PennyLane-Cirq"
copyright = "2022."
copyright = "2023."
author = "Xanadu"

add_module_names = False
Expand Down Expand Up @@ -263,7 +263,7 @@ class TypeMock(type):
],
"toc_overview": True,
"navbar_active_link": 3,
"google_analytics_tracking_id": "UA-130507810-1"
"google_analytics_tracking_id": "G-C480Z9JL0D"
}

edit_on_github_project = 'PennyLaneAI/pennylane-cirq'
Expand Down
2 changes: 1 addition & 1 deletion doc/devices/pasqal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ the ``ThreeDQubit`` and the notion of a ``control_radius``.

.. code-block:: python
from cirq.pasqal import ThreeDQubit
from cirq_pasqal import ThreeDQubit
qubits = [ThreeDQubit(x, y, z)
for x in range(2)
for y in range(2)
Expand Down
10 changes: 5 additions & 5 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,27 @@ Check out these demos to see the PennyLane-Cirq plugin in action:

.. title-card::
:name: Optimizing noisy circuits with Cirq
:description: <img src="https://pennylane.ai/qml/_images/noisy_circuit_optimization_thumbnail.png" width="100%" />
:description: <img src="https://pennylane.ai/_images/noisy_circuit_optimization_thumbnail.png" width="100%" />
:link: https://pennylane.ai/qml/demos/tutorial_noisy_circuit_optimization.html

.. title-card::
:name: Quantum Generative Adversarial Networks with Cirq + TensorFlow
:description: <img src="https://pennylane.ai/qml/_images/qgan3.png" width="100%" />
:description: <img src="https://pennylane.ai/_images/qgan3.png" width="100%" />
:link: https://pennylane.ai/qml/demos/tutorial_QGAN.html

.. title-card::
:name: Quantum computation with neutral atoms
:description: <img src="https://pennylane.ai/qml/_images/pasqal_thumbnail.png" width="100%" />
:description: <img src="https://pennylane.ai/_images/pasqal_thumbnail.png" width="100%" />
:link: https://pennylane.ai/qml/demos/tutorial_pasqal.html

.. title-card::
:name: Variationally optimizing measurement protocols
:description: <img src="https://pennylane.ai/qml/_images/illustration.png" width="100%" />
:description: <img src="https://pennylane.ai/_images/illustration.png" width="100%" />
:link: https://pennylane.ai/qml/demos/tutorial_quantum_metrology.html

.. title-card::
:name: Beyond classical computing with qsim
:description: <img src="https://pennylane.ai/qml/_images/sycamore.png" width="100%" />
:description: <img src="https://pennylane.ai/_images/sycamore.png" width="100%" />
:link: https://pennylane.ai/qml/demos/qsim_beyond_classical.html

.. raw:: html
Expand Down
4 changes: 2 additions & 2 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pytz==2021.1
PyYAML==6.0
requests==2.27.1
retworkx==0.11.0
scipy==1.7.3
scipy==1.11.2
semantic-version==2.10
six==1.16.0
snowballstemmer==2.2.0
Expand All @@ -75,7 +75,7 @@ sympy==1.9
toml==0.10.2
tqdm==4.64.0
traitlets==5.1.0
typing_extensions==3.10.0.0
typing_extensions==4.2.0
urllib3==1.26.9
# Do not pin the following
pennylane-sphinx-theme
Expand Down
2 changes: 1 addition & 1 deletion pennylane_cirq/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
Version number (major.minor.patch[-label])
"""

__version__ = "0.29.0"
__version__ = "0.34.0-dev"
10 changes: 4 additions & 6 deletions pennylane_cirq/cirq_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def __init__(self, wires, shots, qubits=None):
**{f"Pow({k})": v for k, v in _pow_operation_map.items()},
"BasisState": None,
"QubitStateVector": None,
"StatePrep": None,
"QubitUnitary": CirqOperation(cirq.MatrixGate),
"PauliX": CirqOperation(lambda: cirq.X),
"PauliY": CirqOperation(lambda: cirq.Y),
Expand Down Expand Up @@ -206,10 +207,7 @@ def reset(self):
# pylint: disable=missing-function-docstring
super().reset()

if self.cirq_device:
self.circuit = cirq.Circuit(device=self.cirq_device)
else:
self.circuit = cirq.Circuit()
self.circuit = cirq.Circuit()

@property
def observables(self):
Expand Down Expand Up @@ -271,14 +269,14 @@ def apply(self, operations, **kwargs):
rotations = kwargs.pop("rotations", [])

for i, operation in enumerate(operations):
if i > 0 and operation.name in {"BasisState", "QubitStateVector"}:
if i > 0 and operation.name in {"BasisState", "QubitStateVector", "StatePrep"}:
raise qml.DeviceError(
f"The operation {operation.name} is only supported at the beginning of a circuit."
)

if operation.name == "BasisState":
self._apply_basis_state(operation)
elif operation.name == "QubitStateVector":
elif operation.name in {"StatePrep", "QubitStateVector"}:
self._apply_qubit_state_vector(operation)
else:
self._apply_operation(operation)
Expand Down
9 changes: 7 additions & 2 deletions pennylane_cirq/pasqal_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class PasqalDevice(SimulatorDevice):
shots (int): Number of circuit evaluations/random samples used
to estimate expectation values of observables. Shots need
to be >= 1. If ``None``, expecation values are calculated analytically.
qubits (List[cirq.ThreeDGridQubit]): A list of Cirq ThreeDGridQubits that are used
qubits (List[cirq_pasqal.ThreeDGridQubit]): A list of Cirq ThreeDGridQubits that are used
as wires. If not specified, the ThreeDGridQubits are put in a linear
arrangement along the first coordinate axis, separated by a distance of
``control_radius / 2``.
Expand All @@ -40,12 +40,17 @@ class PasqalDevice(SimulatorDevice):
short_name = "cirq.pasqal"

def __init__(self, wires, control_radius, shots=None, qubits=None):
if isinstance(wires, int):
# interpret wires as the number of consecutive wires
wires = range(wires)
if not qubits:
qubits = [
cirq_pasqal.ThreeDQubit(wire * control_radius / 2, 0, 0) for wire in range(wires)
cirq_pasqal.ThreeDQubit(wire * control_radius / 2, 0, 0)
for wire in range(len(wires))
]
self.control_radius = float(control_radius)
if self.control_radius < 0:
raise ValueError("The control_radius must be a non-negative real number.")
super().__init__(wires, shots, qubits)

self.cirq_device = cirq_pasqal.PasqalVirtualDevice(self.control_radius, qubits)
2 changes: 2 additions & 0 deletions pennylane_cirq/qsim_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def operations(self):
# pylint: disable=missing-function-docstring
return set(self._base_operation_map) - {
"QubitStateVector",
"StatePrep",
"BasisState",
"CRX",
"CRY",
Expand Down Expand Up @@ -122,6 +123,7 @@ def operations(self):
# pylint: disable=missing-function-docstring
return set(self._base_operation_map) - {
"QubitStateVector",
"StatePrep",
"BasisState",
"CRX",
"CRY",
Expand Down
6 changes: 3 additions & 3 deletions pennylane_cirq/simulator_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def reset(self):
def capabilities(self): # pylint: disable=missing-function-docstring
capabilities = super().capabilities().copy()
capabilities.update(
returns_state=(self.shots is None) # State information is only set if obtaining shots
returns_state=self.shots is None # State information is only set if obtaining shots
)
return capabilities

Expand All @@ -94,7 +94,7 @@ def _apply_qubit_state_vector(self, qubit_state_vector_operation):
# pylint: disable=missing-function-docstring
if self.shots is not None:
raise qml.DeviceError(
"The operation QubitStateVector is only supported in analytic mode."
"The operations StatePrep and QubitStateVector are only supported in analytic mode."
)

self._initial_state = qubit_state_vector_operation.state_vector(
Expand Down Expand Up @@ -240,7 +240,7 @@ def __init__(self, wires, shots=None, qubits=None):
def capabilities(self): # pylint: disable=missing-function-docstring
capabilities = super().capabilities().copy()
capabilities.update(
returns_state=(self.shots is None) # State information is only set if obtaining shots
returns_state=self.shots is None # State information is only set if obtaining shots
)
return capabilities

Expand Down
2 changes: 1 addition & 1 deletion requirements-ci.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
git+https://github.com/PennyLaneAI/pennylane.git
pennylane
cirq-core
cirq-pasqal
numpy
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pennylane==0.29.0
PennyLane-Lightning==0.29.0
Pillow==9.1.1
pluggy==1.0.0
protobuf==3.15.0
protobuf==3.18.3
PubChemPy==1.0.4
py==1.10.0
pyparsing==2.4.7
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@
"Programming Language :: Python",
# Make sure to specify here the versions of Python supported
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Scientific/Engineering :: Physics",
]
Expand Down
Loading

0 comments on commit 0beb51e

Please sign in to comment.