Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v1.0.0 #746

Merged
merged 10 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.12"]
python-version: ["3.9", "3.12"]
with-torch: ["with-torch", "no-torch"]
steps:
- name: Check out Pulser
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- name: Check out Pulser
uses: actions/checkout@v4
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ jobs:
strategy:
fail-fast: false
matrix:
# 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
# Python 3.9 does not run on macos-latest (14)
# Uses macos-13 for 3.9 and macos-latest for >=3.10
os: [ubuntu-latest, macos-13, macos-latest, windows-latest]
with-torch: ["with-torch", "no-torch"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
exclude:
- os: macos-latest
python-version: "3.8"
- os: macos-latest
python-version: "3.9"
- os: macos-13
Expand Down
2 changes: 1 addition & 1 deletion .mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ warn_unused_ignores = True
disallow_untyped_defs = True

# 3rd-party libs without type hints nor stubs
[mypy-matplotlib.*,scipy.*,qutip.*,jsonschema.*,py.*]
[mypy-scipy.*,qutip.*,jsonschema.*,py.*]
follow_imports = silent
ignore_missing_imports = True

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Here are the steps you should follow to make your contribution:
git pull upstream develop
```

you will fetch the latest changes in `upstream/develop` and merge them with your working branch, at which point you'll have to solve any merge conflicts that may arise. This will keep your working branch in sync with `upstream/develop`.
you will fetch the latest changes in `upstream/develop` and merge them with your working branch, at which point you'll have to solve any merge conflicts that may arise. This will keep your working branch in sync with `upstream/develop`.

5. Finally, you push your code to your local branch:

Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ For a comprehensive overview of Pulser, check out [Pulser's white paper](https:/

## Installation

**Note**: *Pulser v0.6 introduced a split of the ``pulser`` package that prevents it from being correctly upgraded. If you have an older version of ``pulser`` installed and wish to upgrade, make sure to uninstall it first by running ``pip uninstall pulser``.*

To install the latest release of ``pulser``, have Python 3.8 or higher installed, then use ``pip``:
To install the latest release of ``pulser``, have Python 3.9 or higher installed, then use ``pip``:

```bash
pip install pulser
Expand Down
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.20.1
1.0.0
4 changes: 1 addition & 3 deletions docs/source/apidoc/simulation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ QutipEmulator

:class:`QutipEmulator` is the class to simulate :class:`SequenceSamples`, that are samples of a :class:`Sequence`.
It is possible to simulate directly a :class:`Sequence` object by using the class method
``QutipEmulator.from_sequence``. Since version 0.14.0, the :class:`Simulation` class is deprecated
in favour of :class:`QutipEmulator`.
``QutipEmulator.from_sequence``.

.. autoclass:: pulser_simulation.simulation.QutipEmulator
:members:

.. autoclass:: pulser_simulation.simulation.Simulation

SimConfig
----------------------
Expand Down
11 changes: 1 addition & 10 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
Installation
==============

.. warning::
Pulser v0.6 introduced a split of the ``pulser`` package that prevents
it from being correctly upgraded. If you have an older version of ``pulser`` installed
and wish to upgrade, make sure to uninstall it first by running: ::

pip uninstall pulser

before proceeding to any of the steps below.

To install the latest release of ``pulser``, have Python 3.8 or higher
To install the latest release of ``pulser``, have Python 3.9 or higher
installed, then use ``pip``: ::

pip install pulser
Expand Down
78 changes: 2 additions & 76 deletions pulser-core/pulser/backend/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@
from __future__ import annotations

import typing
import warnings
from abc import ABC, abstractmethod
from collections.abc import Callable
from enum import Enum, auto
from functools import wraps
from types import TracebackType
from typing import Any, Mapping, Type, TypedDict, TypeVar, cast
from typing import Any, Mapping, Type, TypedDict, cast

from pulser.backend.abc import Backend
from pulser.devices import Device
Expand All @@ -37,23 +34,8 @@ class JobParams(TypedDict, total=False):
variables: dict[str, Any]


class SubmissionStatus(Enum):
"""Status of a remote submission."""

PENDING = auto()
RUNNING = auto()
DONE = auto()
CANCELED = auto()
TIMED_OUT = auto()
ERROR = auto()
PAUSED = auto()


class BatchStatus(Enum):
"""Status of a batch.

Same as SubmissionStatus, needed because we renamed Submission -> Batch.
"""
"""Status of a batch."""

PENDING = auto()
RUNNING = auto()
Expand Down Expand Up @@ -81,38 +63,9 @@ class RemoteResultsError(Exception):
pass


F = TypeVar("F", bound=Callable)


def _deprecate_submission_id(func: F) -> F:
@wraps(func)
def wrapper(self: RemoteResults, *args: Any, **kwargs: Any) -> Any:
if "submission_id" in kwargs:
# 'batch_id' is the first positional arg so if len(args) > 0,
# then it is being given
if "batch_id" in kwargs or args:
raise ValueError(
"'submission_id' and 'batch_id' cannot be simultaneously"
" specified. Please provide only the 'batch_id'."
)
warnings.warn(
"'submission_id' has been deprecated and replaced by "
"'batch_id'.",
category=DeprecationWarning,
stacklevel=3,
)
kwargs["batch_id"] = kwargs.pop("submission_id")
return func(self, *args, **kwargs)

return cast(F, wrapper)


class RemoteResults(Results):
"""A collection of results obtained through a remote connection.

Warns:
DeprecationWarning: If 'submission_id' is given instead of 'batch_id'.

Args:
batch_id: The ID that identifies the batch linked to the results.
connection: The remote connection over which to get the batch's
Expand All @@ -122,7 +75,6 @@ class RemoteResults(Results):
all jobs are included.
"""

@_deprecate_submission_id
def __init__(
self,
batch_id: str,
Expand All @@ -147,17 +99,6 @@ def results(self) -> tuple[Result, ...]:
"""The actual results, obtained after execution is done."""
return self._results

@property
def _submission_id(self) -> str:
"""The same as the batch ID, kept for backwards compatibility."""
warnings.warn(
"'RemoteResults._submission_id' has been deprecated, please use"
"'RemoteResults.batch_id' instead.",
category=DeprecationWarning,
stacklevel=2,
)
return self._batch_id

@property
def batch_id(self) -> str:
"""The ID of the batch containing these results."""
Expand All @@ -170,21 +111,6 @@ def job_ids(self) -> list[str]:
return self._connection._get_job_ids(self._batch_id)
return self._job_ids

def get_status(self) -> SubmissionStatus:
"""Gets the status of the remote submission.

Warning:
This method has been deprecated, please use
`RemoteResults.get_batch_status()` instead.
"""
warnings.warn(
"'RemoteResults.get_status()' has been deprecated, please use"
"'RemoteResults.get_batch_status()' instead.",
category=DeprecationWarning,
stacklevel=2,
)
return SubmissionStatus[self.get_batch_status().name]

def get_batch_status(self) -> BatchStatus:
"""Gets the status of the batch linked to these results."""
return self._connection._get_batch_status(self._batch_id)
Expand Down
6 changes: 0 additions & 6 deletions pulser-core/pulser/devices/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,13 @@
from pulser.devices._device_datacls import Device, VirtualDevice
from pulser.devices._devices import (
AnalogDevice,
Chadoq2,
DigitalAnalogDevice,
IroiseMVP,
)
from pulser.devices._mock_device import MockDevice

# Registers which devices can be used to avoid definition of custom devices
_mock_devices: tuple[VirtualDevice, ...] = (MockDevice,)
_valid_devices: tuple[Device, ...] = (
Chadoq2,
IroiseMVP,
AnalogDevice,
DigitalAnalogDevice,
)
Expand All @@ -41,6 +37,4 @@
"AnalogDevice",
"DigitalAnalogDevice",
"MockDevice",
"Chadoq2",
"IroiseMVP",
]
32 changes: 0 additions & 32 deletions pulser-core/pulser/devices/_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Examples of realistic devices."""
import dataclasses

import numpy as np

from pulser.channels import DMM, Raman, Rydberg
Expand Down Expand Up @@ -99,33 +97,3 @@
),
pre_calibrated_layouts=(TriangularLatticeLayout(61, 5),),
)

# Legacy devices (deprecated, should not be used in new sequences)

Chadoq2 = dataclasses.replace(DigitalAnalogDevice, name="Chadoq2")

IroiseMVP = Device(
name="IroiseMVP",
dimensions=2,
rydberg_level=60,
max_atom_num=100,
max_radial_distance=60,
min_atom_distance=5,
channel_objects=(
Rydberg.Global(
max_abs_detuning=2 * np.pi * 4,
max_amp=2 * np.pi * 3,
clock_period=4,
min_duration=16,
max_duration=2**26,
mod_bandwidth=4,
eom_config=RydbergEOM(
limiting_beam=RydbergBeam.RED,
max_limiting_amp=40 * 2 * np.pi,
intermediate_detuning=700 * 2 * np.pi,
mod_bandwidth=24,
controlled_beams=(RydbergBeam.BLUE,),
),
),
),
)
48 changes: 2 additions & 46 deletions pulser-core/pulser/noise_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class NoiseModel:

Supported noise types:

- "leakage": Adds an error state 'x' to the computational
- **leakage**: Adds an error state 'x' to the computational
basis, that can interact with the other states via an
effective noise channel. Must be defined with an effective
noise channel, but is incompatible with dephasing and
Expand Down Expand Up @@ -132,10 +132,6 @@ class NoiseModel:
``p_false_pos`` and ``p_false_neg``.

Args:
noise_types: *Deprecated, simply define the approriate parameters
instead*. Noise types to include in the emulation. Defining
noise in this way will rely on legacy defaults for the relevant
parameters whenever a custom value is not provided.
runs: When reconstructing the Hamiltonian from random noise is
necessary, this determines how many times that happens. Not
to be confused with the number of times the resulting
Expand Down Expand Up @@ -188,7 +184,6 @@ class NoiseModel:

def __init__(
self,
noise_types: tuple[NoiseTypes, ...] | None = None,
runs: int | None = None,
samples_per_run: int | None = None,
state_prep_error: float | None = None,
Expand Down Expand Up @@ -229,30 +224,6 @@ def to_tuple(obj: tuple) -> tuple:
eff_noise_opers=to_tuple(eff_noise_opers),
with_leakage=with_leakage,
)
if noise_types is not None:
with warnings.catch_warnings():
warnings.simplefilter("always")
warnings.warn(
"The explicit definition of noise types is deprecated; "
"doing so will use legacy default values for all relevant "
"parameters that are not given a custom value. Instead, "
"defining only the necessary parameters is recommended; "
"doing so (when the noise types are not explicitly given) "
"will disregard all undefined parameters.",
DeprecationWarning,
stacklevel=2,
)
self._check_noise_types(noise_types)
for nt_ in noise_types:
if nt_ == "leakage":
raise ValueError(
"'leakage' cannot be explicitely defined in the noise"
" types. Set 'with_leakage' to True instead."
)
for p_ in _NOISE_TYPE_PARAMS[nt_]:
# Replace undefined relevant params by the legacy default
if param_vals[p_] is None:
param_vals[p_] = _LEGACY_DEFAULTS[p_]
true_noise_types: set[NoiseTypes] = {
_PARAM_TO_NOISE_TYPE[p_]
for p_ in param_vals
Expand All @@ -262,7 +233,7 @@ def to_tuple(obj: tuple) -> tuple:
self._check_eff_noise(
cast(tuple, param_vals["eff_noise_rates"]),
cast(tuple, param_vals["eff_noise_opers"]),
"eff_noise" in (noise_types or true_noise_types),
"eff_noise" in true_noise_types,
with_leakage=cast(bool, param_vals["with_leakage"]),
)

Expand All @@ -277,21 +248,6 @@ def to_tuple(obj: tuple) -> tuple:
cast(Union[float, None], param_vals["laser_waist"]),
)

if noise_types is not None:
if true_noise_types != set(noise_types):
raise ValueError(
"The explicit definition of noise types (deprecated) is"
" not compatible with the modification of unrelated noise "
"parameters. Defining only the relevant noise parameters "
"(without specifying the noise types) is recommended."
)
# Only now that we know the relevant_params can we determine if
# we need to use the legacy defaults for the run parameters (ie in
# case they were not provided by the user)
run_params_ = relevant_params & {"runs", "samples_per_run"}
for p_ in run_params_:
param_vals[p_] = param_vals[p_] or _LEGACY_DEFAULTS[p_]

relevant_param_vals = {
p: param_vals[p]
for p in param_vals
Expand Down
Loading