Skip to content

Commit

Permalink
Merge branch 'feature/autoqasm' into rmshaffer/oqpy-upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
rmshaffer committed Oct 16, 2023
2 parents 45df6c6 + c544b77 commit 12f6bc4
Show file tree
Hide file tree
Showing 102 changed files with 1,915 additions and 923 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
check-code-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- name: Set up Python
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1
with:
python-version: '3.x'
- name: Install dependencies
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/dependent-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11"]
dependent:
- amazon-braket-pennylane-plugin-python

steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
name: Build and publish distribution to PyPi
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- name: Set up Python
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1
with:
python-version: '3.x'
- name: Install wheel
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/twine-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
name: Check long description
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- name: Set up Python
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1
with:
python-version: '3.x'
- name: Install wheel
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ formats:
build:
os: ubuntu-22.04
tools:
python: "3.8"
python: "3.9"

# Optionally set the version of Python and requirements required to build your docs
python:
Expand Down
41 changes: 41 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,46 @@
# Changelog

## v1.57.2 (2023-10-11)

### Bug Fixes and Other Changes

* Use builtins for type hints

## v1.57.1 (2023-10-05)

### Bug Fixes and Other Changes

* docs: fix helper docstring

## v1.57.0 (2023-10-04)

### Features

* wrap non-dict results and update results on subsequent calls
* job helper functions

### Bug Fixes and Other Changes

* revert integ test changes

## v1.56.2 (2023-10-03)

### Bug Fixes and Other Changes

* Refactor Qubit and QubitSet to a separate module

## v1.56.1 (2023-09-27)

### Bug Fixes and Other Changes

* fixing search device when don't have access to a region.

## v1.56.0 (2023-09-26)

### Features

* add queue visibility information

## v1.55.1.post0 (2023-09-18)

### Documentation Changes
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ The Amazon Braket Python SDK is an open source library that provides a framework
## Prerequisites
Before you begin working with the Amazon Braket SDK, make sure that you've installed or configured the following prerequisites.

### Python 3.8 or greater
Download and install Python 3.8 or greater from [Python.org](https://www.python.org/downloads/).
### Python 3.9 or greater
Download and install Python 3.9 or greater from [Python.org](https://www.python.org/downloads/).

### Git
Install Git from https://git-scm.com/downloads. Installation instructions are provided on the download page.
Expand Down
6 changes: 2 additions & 4 deletions examples/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.

import os

from braket.aws import AwsDevice, AwsQuantumJob
from braket.circuits import Circuit
from braket.devices import Devices
from braket.jobs import save_job_result
from braket.jobs import get_job_device_arn, save_job_result


def run_job():
device = AwsDevice(os.environ.get("AMZN_BRAKET_DEVICE_ARN"))
device = AwsDevice(get_job_device_arn())

bell = Circuit().h(0).cnot(0, 1)
num_tasks = 10
Expand Down
7 changes: 3 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
name="amazon-braket-sdk",
version=version,
license="Apache License 2.0",
python_requires=">= 3.8.2",
python_requires=">= 3.9",
packages=find_namespace_packages(where="src", exclude=("test",)),
package_dir={"": "src"},
install_requires=[
Expand All @@ -32,12 +32,12 @@
# to get the version of the simulator that supports the mcm=True argument for Monte Carlo
# simulation of mid-circuit measurement, which AutoQASM requires.
# NOTE: This change should remain in the feature/autoqasm branch; do not merge to main.
"amazon-braket-default-simulator @ git+https://github.com/aws/amazon-braket-default-simulator-python.git@31d6c95f3ac250a0ccd04e1433ad61c8bfa4bde4#egg=amazon-braket-default-simulator", # noqa E501
"amazon-braket-default-simulator @ git+https://github.com/aws/amazon-braket-default-simulator-python.git@46aea776976ad7f958d847c06f29f3a7976f5cf5#egg=amazon-braket-default-simulator", # noqa E501
"oqpy~=0.3.2",
"setuptools",
"backoff",
"boltons",
"boto3>=1.22.3",
"boto3>=1.28.53",
"nest-asyncio",
"networkx",
"numpy",
Expand Down Expand Up @@ -83,7 +83,6 @@
"Natural Language :: English",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand Down
2 changes: 1 addition & 1 deletion src/braket/_sdk/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
Version number (major.minor.patch[-label])
"""

__version__ = "1.55.2.dev0"
__version__ = "1.57.3.dev0"
7 changes: 3 additions & 4 deletions src/braket/ahs/analog_hamiltonian_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

from collections import defaultdict
from functools import singledispatch
from typing import Tuple

import braket.ir.ahs as ir
from braket.ahs.atom_arrangement import AtomArrangement, SiteType
Expand Down Expand Up @@ -113,12 +112,12 @@ def discretize(self, device) -> AnalogHamiltonianSimulation: # noqa
@singledispatch
def _get_term_ir(
term: Hamiltonian,
) -> Tuple[str, dict]:
) -> tuple[str, dict]:
raise TypeError(f"Unable to convert Hamiltonian term type {type(term)}.")


@_get_term_ir.register
def _(term: ShiftingField) -> Tuple[str, ir.ShiftingField]:
def _(term: ShiftingField) -> tuple[str, ir.ShiftingField]:
return AnalogHamiltonianSimulation.SHIFTING_FIELDS_PROPERTY, ir.ShiftingField(
magnitude=ir.PhysicalField(
time_series=ir.TimeSeries(
Expand All @@ -131,7 +130,7 @@ def _(term: ShiftingField) -> Tuple[str, ir.ShiftingField]:


@_get_term_ir.register
def _(term: DrivingField) -> Tuple[str, ir.DrivingField]:
def _(term: DrivingField) -> tuple[str, ir.DrivingField]:
return AnalogHamiltonianSimulation.DRIVING_FIELDS_PROPERTY, ir.DrivingField(
amplitude=ir.PhysicalField(
time_series=ir.TimeSeries(
Expand Down
13 changes: 7 additions & 6 deletions src/braket/ahs/atom_arrangement.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@

from __future__ import annotations

from collections.abc import Iterator
from dataclasses import dataclass
from decimal import Decimal
from enum import Enum
from numbers import Number
from typing import Iterator, List, Tuple, Union
from typing import Union

import numpy as np

Expand All @@ -33,7 +34,7 @@ class SiteType(Enum):
class AtomArrangementItem:
"""Represents an item (coordinate and metadata) in an atom arrangement."""

coordinate: Tuple[Number, Number]
coordinate: tuple[Number, Number]
site_type: SiteType

def _validate_coordinate(self) -> None:
Expand Down Expand Up @@ -62,13 +63,13 @@ def __init__(self):

def add(
self,
coordinate: Union[Tuple[Number, Number], np.ndarray],
coordinate: Union[tuple[Number, Number], np.ndarray],
site_type: SiteType = SiteType.FILLED,
) -> AtomArrangement:
"""Add a coordinate to the atom arrangement.
Args:
coordinate (Union[Tuple[Number, Number], ndarray]): The coordinate of the
coordinate (Union[tuple[Number, Number], ndarray]): The coordinate of the
atom (in meters). The coordinates can be a numpy array of shape (2,)
or a tuple of int, float, Decimal
site_type (SiteType): The type of site. Optional. Default is FILLED.
Expand All @@ -78,14 +79,14 @@ def add(
self._sites.append(AtomArrangementItem(tuple(coordinate), site_type))
return self

def coordinate_list(self, coordinate_index: Number) -> List[Number]:
def coordinate_list(self, coordinate_index: Number) -> list[Number]:
"""Returns all the coordinates at the given index.
Args:
coordinate_index (Number): The index to get for each coordinate.
Returns:
List[Number]:The list of coordinates at the given index.
list[Number]:The list of coordinates at the given index.
Example:
To get a list of all x-coordinates: coordinate_list(0)
Expand Down
14 changes: 7 additions & 7 deletions src/braket/ahs/driving_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from __future__ import annotations

from typing import List, Union
from typing import Union

from braket.ahs.discretization_types import DiscretizationProperties
from braket.ahs.field import Field
Expand Down Expand Up @@ -65,7 +65,7 @@ def __init__(
self._detuning = detuning if isinstance(detuning, Field) else Field(detuning)

@property
def terms(self) -> List[Hamiltonian]:
def terms(self) -> list[Hamiltonian]:
return [self]

@property
Expand Down Expand Up @@ -141,18 +141,18 @@ def discretize(self, properties: DiscretizationProperties) -> DrivingField:

@staticmethod
def from_lists(
times: List[float], amplitudes: List[float], detunings: List[float], phases: List[float]
times: list[float], amplitudes: list[float], detunings: list[float], phases: list[float]
) -> DrivingField:
"""
Builds DrivingField Hamiltonian from lists defining time evolution
of Hamiltonian parameters (Rabi frequency, detuning, phase).
The values of the parameters at each time points are global for all atoms.
Args:
times (List[float]): The time points of the driving field
amplitudes (List[float]): The values of the amplitude
detunings (List[float]): The values of the detuning
phases (List[float]): The values of the phase
times (list[float]): The time points of the driving field
amplitudes (list[float]): The values of the amplitude
detunings (list[float]): The values of the detuning
phases (list[float]): The values of the phase
Returns:
DrivingField: DrivingField Hamiltonian.
Expand Down
8 changes: 4 additions & 4 deletions src/braket/ahs/hamiltonian.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

from __future__ import annotations

from typing import List, Optional
from typing import Optional

from braket.ahs.discretization_types import DiscretizationProperties


class Hamiltonian:
def __init__(self, terms: Optional[List[Hamiltonian]] = None):
def __init__(self, terms: Optional[list[Hamiltonian]] = None):
r"""A Hamiltonian representing a system to be simulated.
A Hamiltonian :math:`H` may be expressed as a sum of multiple terms
Expand All @@ -30,8 +30,8 @@ def __init__(self, terms: Optional[List[Hamiltonian]] = None):
self._terms = terms or []

@property
def terms(self) -> List[Hamiltonian]:
"""List[Hamiltonian]: The list of terms in this Hamiltonian."""
def terms(self) -> list[Hamiltonian]:
"""list[Hamiltonian]: The list of terms in this Hamiltonian."""
return self._terms

def discretize(self, properties: DiscretizationProperties) -> Hamiltonian:
Expand Down
9 changes: 4 additions & 5 deletions src/braket/ahs/pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,21 @@

from decimal import Decimal
from numbers import Number
from typing import List


class Pattern:
def __init__(self, series: List[Number]):
def __init__(self, series: list[Number]):
"""Represents the spatial dependence of a Field.
Args:
series (List[Number]): A series of numbers representing the the local
series (list[Number]): A series of numbers representing the the local
pattern of real numbers.
"""
self._series = series

@property
def series(self) -> List[Number]:
"""List[Number]: A series of numbers representing the local
def series(self) -> list[Number]:
"""list[Number]: A series of numbers representing the local
pattern of real numbers."""
return self._series

Expand Down
Loading

0 comments on commit 12f6bc4

Please sign in to comment.