Skip to content

Commit

Permalink
Release v0.18.0
Browse files Browse the repository at this point in the history
Main changes:

21a47f3 Remove Register.rotate() (#642)
20e6765 FIX: Redefine slope of RampWaveform (#644)
c2d5b6c Enabling definition of multiple noise channels and noise channels in XY (#647)
bcb78cc Enable digital simulation (#652)
0f6e3dd Improve access to output modulation durations (#663)
188d21d Remove deprecated noise arguments (#674)
f303138 Adding relaxation noise channel (#675)
716b86b Centralize all backend imports from a single pulser.backends module (#678)
96a8c34 Add hyperfine dephasing rate to NoiseModel (#680)
4981ca6 Add optional default noise models to devices (#676)
c695373 Rectangular lattice register and layout (#665)
  • Loading branch information
HGSilveri authored Apr 29, 2024
2 parents 5d10f6c + ddc6682 commit 82c282b
Show file tree
Hide file tree
Showing 66 changed files with 1,957 additions and 1,065 deletions.
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ per-file-ignores =
# F401 Module imported but unused
tests/*: D100, D101, D102, D103
__init__.py: F401
pulser-core/pulser/backends.py: F401
setup.py: D100
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out Pulser
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Pulser + flake8 install
uses: ./.github/workflows/pulser-setup
with:
Expand All @@ -23,7 +23,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out Pulser
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Pulser + black install
uses: ./.github/workflows/pulser-setup
with:
Expand All @@ -34,7 +34,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out Pulser
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Pulser + isort install
uses: ./.github/workflows/pulser-setup
with:
Expand All @@ -45,7 +45,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out Pulser
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Pulser + mypy install
uses: ./.github/workflows/pulser-setup
with:
Expand All @@ -61,7 +61,7 @@ jobs:
python-version: ["3.8", "3.11"]
steps:
- name: Check out Pulser
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Pulser + pytest install
uses: ./.github/workflows/pulser-setup
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
id-token: write
steps:
- name: Check out Pulser
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install Python dependencies
Expand Down Expand Up @@ -69,11 +69,11 @@ jobs:
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- name: Check out Pulser
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Pulser from PyPI
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/pulser-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ inputs:
python-version:
description: Python version
required: false
default: '3.9'
default: "3.9"
extra-packages:
description: Extra packages to install (give to grep)
required: false
default: ''
default: ""
runs:
using: 'composite'
steps:
using: "composite"
steps:
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
cache: 'pip'
cache: "pip"
- name: Install Pulser
shell: bash
run: |
Expand All @@ -28,4 +28,4 @@ runs:
run: |
grep -e ${{ inputs.extra-packages }} dev_requirements.txt \
| sed 's/ //g' \
| xargs pip install
| xargs pip install
15 changes: 13 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,22 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
# Python 3.8 and 3.9 does not run on macos-latest (14)
# Uses macos-13 for 3.8 and 3.9 and macos-latest for >=3.10
os: [ubuntu-latest, macos-13, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
exclude:
- os: macos-latest
python-version: "3.8"
- os: macos-latest
python-version: "3.9"
- os: macos-13
python-version: "3.10"
- os: macos-13
python-version: "3.11"
steps:
- name: Check out Pulser
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Pulser + pytest setup
uses: ./.github/workflows/pulser-setup
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out base branch
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.ref }}
- name: Get old version
Expand All @@ -19,7 +19,7 @@ jobs:
echo "Old version: $old_version"
echo "old_version=$old_version" >> $GITHUB_ENV
- name: Check out head branch
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Get new version
run: |
new_version="$(head -1 VERSION.txt)"
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 23.10.1
rev: 24.4.0
hooks:
- id: black-jupyter

Expand Down
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.17.4
0.18.0
2 changes: 1 addition & 1 deletion dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# tests
black[jupyter] ~= 23.1
black[jupyter] ~= 24.3
flake8
flake8-docstrings
isort
Expand Down
5 changes: 5 additions & 0 deletions docs/source/apidoc/backend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ QPU
Emulators
----------

Configuration
^^^^^^^^^^^^^^
.. autoclass:: pulser.EmulatorConfig
:members:

Local
^^^^^^^
.. autoclass:: pulser_simulation.QutipBackend
Expand Down
5 changes: 4 additions & 1 deletion docs/source/apidoc/core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ which when associated with a :class:`pulser.Sequence` condition its development.

.. autodata:: pulser.devices.DigitalAnalogDevice


Noise Model
--------------
.. automodule:: pulser.noise_model
:members:

Channels
---------------------
Expand Down
2 changes: 1 addition & 1 deletion docs/source/apidoc/simulation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ in favour of :class:`QutipEmulator`.
SimConfig
----------------------

.. automodule:: pulser_simulation.simconfig
.. autoclass:: pulser_simulation.SimConfig
:members:

Simulation Results
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ computers and simulators, check the pages in :doc:`review`.
tutorials/noisy_sim
tutorials/spam
tutorials/laser_noise
tutorials/kraus_ops
tutorials/effective_noise

.. toctree::
:maxdepth: 1
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions pulser-core/MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ include pulser/json/abstract_repr/schemas/device-schema.json
include pulser/json/abstract_repr/schemas/sequence-schema.json
include pulser/json/abstract_repr/schemas/register-schema.json
include pulser/json/abstract_repr/schemas/layout-schema.json
include pulser/json/abstract_repr/schemas/noise-schema.json
6 changes: 4 additions & 2 deletions pulser-core/pulser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
)
from pulser.pulse import Pulse
from pulser.register import Register, Register3D
from pulser.noise_model import NoiseModel
from pulser.devices import AnalogDevice, DigitalAnalogDevice, MockDevice
from pulser.sequence import Sequence
from pulser.backend import (
EmulatorConfig,
NoiseModel,
QPUBackend,
)

Expand All @@ -42,6 +42,7 @@
devices as devices,
sampler as sampler,
backend as backend,
backends as backends,
)

__all__ = [
Expand All @@ -58,6 +59,8 @@
# pulser.register
"Register",
"Register3D",
# pulser.noise_model
"NoiseModel",
# pulser.devices
"AnalogDevice",
"DigitalAnalogDevice",
Expand All @@ -66,6 +69,5 @@
"Sequence",
# pulser.backends
"EmulatorConfig",
"NoiseModel",
"QPUBackend",
]
3 changes: 2 additions & 1 deletion pulser-core/pulser/backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
# limitations under the License.
"""Classes for backend execution."""

import pulser.noise_model as noise_model # For backwards compat
from pulser.backend.config import EmulatorConfig
from pulser.backend.noise_model import NoiseModel
from pulser.noise_model import NoiseModel # For backwards compat
from pulser.backend.qpu import QPUBackend

__all__ = ["EmulatorConfig", "NoiseModel", "QPUBackend"]
9 changes: 8 additions & 1 deletion pulser-core/pulser/backend/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import numpy as np

from pulser.backend.noise_model import NoiseModel
from pulser.noise_model import NoiseModel

EVAL_TIMES_LITERAL = Literal["Full", "Minimal", "Final"]

Expand Down Expand Up @@ -63,15 +63,22 @@ class EmulatorConfig(BackendConfig):
- "all-ground" for all atoms in the ground state
- An array of floats with a shape compatible with the system
with_modulation: Whether to emulate the sequence with the programmed
input or the expected output.
prefer_device_noise_model: If the sequence's device has a default noise
model, this option signals the backend to prefer it over the noise
model given with this configuration.
noise_model: An optional noise model to emulate the sequence with.
Ignored if the sequence's device has default noise model and
`prefer_device_noise_model=True`.
"""

sampling_rate: float = 1.0
evaluation_times: float | Sequence[float] | EVAL_TIMES_LITERAL = "Full"
initial_state: Literal["all-ground"] | Sequence[complex] = "all-ground"
with_modulation: bool = False
prefer_device_noise_model: bool = False
noise_model: NoiseModel = field(default_factory=NoiseModel)

def __post_init__(self) -> None:
Expand Down
52 changes: 52 additions & 0 deletions pulser-core/pulser/backends.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright 2024 Pulser Development Team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""A module gathering all available backends."""
from __future__ import annotations

import importlib
from typing import TYPE_CHECKING, Type

from pulser.backend.abc import Backend

if TYPE_CHECKING:
from pulser.backend import QPUBackend as QPUBackend
from pulser_pasqal import EmuFreeBackend as EmuFreeBackend
from pulser_pasqal import EmuTNBackend as EmuTNBackend
from pulser_simulation import QutipBackend as QutipBackend

_BACKENDS = {
"QPUBackend": "pulser.backend",
"QutipBackend": "pulser_simulation",
"EmuFreeBackend": "pulser_pasqal",
"EmuTNBackend": "pulser_pasqal",
}


# This prevents * imports to attempt importing unavailable backends
__all__: list[str] = []


def __getattr__(name: str) -> Type[Backend]:
if name not in _BACKENDS:
raise AttributeError(f"Module {__name__!r} has no attribute {name!r}.")
try:
return getattr( # type: ignore
importlib.import_module(_BACKENDS[name]),
name,
)
except ModuleNotFoundError:
raise AttributeError(
f"{name!r} requires the {_BACKENDS[name]!r} package. To install "
f"it, run `pip install {_BACKENDS[name]}`."
)
2 changes: 1 addition & 1 deletion pulser-core/pulser/channels/base_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class Channel(ABC):
clock_period: int = 1 # ns
min_duration: int = 1 # ns
max_duration: Optional[int] = int(1e8) # ns
min_avg_amp: int = 0
min_avg_amp: float = 0
mod_bandwidth: Optional[float] = None # MHz
eom_config: Optional[BaseEOM] = field(init=False, default=None)

Expand Down
Loading

0 comments on commit 82c282b

Please sign in to comment.