Skip to content

Commit

Permalink
Merge branch 'main' into only_validation
Browse files Browse the repository at this point in the history
  • Loading branch information
speller26 authored Dec 4, 2024
2 parents baccbb1 + aead183 commit 371fc8f
Show file tree
Hide file tree
Showing 43 changed files with 691 additions and 269 deletions.
5 changes: 5 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ exclude_lines =
# Avoid situation where system version causes coverage issues
if sys.version_info.minor == 9:

# Avoid type checking import conditionals
if TYPE_CHECKING:



[html]
directory = build/coverage

Expand Down
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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Set up Python
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: '3.9'
- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dependent-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:
- amazon-braket-pennylane-plugin-python

steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-title-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: "Check PR Title"
uses: thehanimo/pr-title-checker@v1.4.2
uses: thehanimo/pr-title-checker@v1.4.3
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
pass_on_octokit_error: false
Expand Down
6 changes: 3 additions & 3 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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Set up Python
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: '3.x'
- name: Install wheel
Expand All @@ -26,6 +26,6 @@ jobs:
- name: Build a binary wheel and a source tarball
run: python setup.py sdist bdist_wheel
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # release/v1
uses: pypa/gh-action-pypi-publish@15c56dba361d8335944d31a2ecd17d700fc7bcbc # release/v1
with:
password: ${{ secrets.pypi_token }}
6 changes: 3 additions & 3 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ jobs:
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand All @@ -36,7 +36,7 @@ jobs:
run: |
tox -e unit-tests
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5.0.7
with:
token: ${{ secrets.CODECOV_TOKEN }}
if: ${{ strategy.job-index }} == 0
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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Set up Python
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: '3.x'
- name: Install wheel
Expand Down
63 changes: 63 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,68 @@
# Changelog

## v1.88.2.post0 (2024-11-25)

### Documentation Changes

* add dual navigation buttons and cleanup some docstrings

## v1.88.2 (2024-11-18)

### Bug Fixes and Other Changes

* Pin cloudpickle==2.2.1

## v1.88.1 (2024-10-21)

### Bug Fixes and Other Changes

* correct typing for task results methods

## v1.88.0 (2024-09-27)

### Deprecations and Removals

* Mark Aspen-M-3 as deprecated, replace with Ankaa-2 in tests

### Bug Fixes and Other Changes

* Update pulse integration tests for Ankaa-2 device

## v1.87.1 (2024-09-23)

### Bug Fixes and Other Changes

* Pass through inputs for SerializableProgram simulation

## v1.87.0 (2024-09-05)

### Deprecations and Removals

* Retire IonQ Harmony

### Bug Fixes and Other Changes

* Return observable target if absent for RT

## v1.86.1 (2024-08-29)

### Bug Fixes and Other Changes

* Use observable targets for targetless results

## v1.86.0 (2024-08-26)

### Features

* Rigetti Ankaa
* add off_center to erf_square

## v1.85.0 (2024-08-20)

### Features

* Allow early qubit binding of observables

## v1.84.0 (2024-07-30)

### Features
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ import boto3
from braket.circuits import Circuit
from braket.aws import AwsDevice

device = AwsDevice("arn:aws:braket:::device/qpu/rigetti/Aspen-8")
device = AwsDevice("arn:aws:braket:::device/qpu/rigetti/Ankaa-2")

bell = Circuit().h(0).cnot(0, 1)
task = device.run(bell)
Expand Down
7 changes: 6 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,23 @@
]

source_suffix = ".rst"
master_doc = "index"
root_doc = "index"

autoclass_content = "both"
autodoc_member_order = "bysource"
default_role = "py:obj"

html_theme = "sphinx_rtd_theme"
html_theme_options = {
"prev_next_buttons_location": "both",
}
htmlhelp_basename = f"{project}doc"

language = "en"

napoleon_use_rtype = False
napoleon_google_docstring = True
napoleon_numpy_docstring = False

apidoc_module_dir = "../src/braket"
apidoc_output_dir = "_apidoc"
Expand Down
10 changes: 5 additions & 5 deletions examples/bell_result_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.

from braket.circuits import Circuit, Observable
from braket.circuits import Circuit, observables
from braket.devices import LocalSimulator

device = LocalSimulator()
Expand All @@ -24,7 +24,7 @@
.h(0)
.cnot(0, 1)
.probability(target=[0])
.expectation(observable=Observable.Z(), target=[1])
.expectation(observable=observables.Z(1))
.amplitude(state=["00"])
.state_vector()
)
Expand All @@ -45,9 +45,9 @@
Circuit()
.h(0)
.cnot(0, 1)
.expectation(observable=Observable.Y() @ Observable.X(), target=[0, 1])
.variance(observable=Observable.Y() @ Observable.X(), target=[0, 1])
.sample(observable=Observable.Y() @ Observable.X(), target=[0, 1])
.expectation(observable=observables.Y(0) @ observables.X(1))
.variance(observable=observables.Y(0) @ observables.X(1))
.sample(observable=observables.Y(0) @ observables.X(1))
)

# When shots>0 for a simulator, probability, expectation, variance are calculated from measurements
Expand Down
4 changes: 2 additions & 2 deletions examples/hybrid_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# language governing permissions and limitations under the License.

from braket.aws import AwsDevice
from braket.circuits import Circuit, FreeParameter, Observable
from braket.circuits import Circuit, FreeParameter, observables
from braket.devices import Devices
from braket.jobs import get_job_device_arn, hybrid_job
from braket.jobs.metrics import log_metric
Expand All @@ -34,7 +34,7 @@ def run_hybrid_job(num_tasks=1):
circ = Circuit()
circ.rx(0, FreeParameter("theta"))
circ.cnot(0, 1)
circ.expectation(observable=Observable.X(), target=0)
circ.expectation(observable=observables.X(0))

# initial parameter
theta = 0.0
Expand Down
4 changes: 2 additions & 2 deletions examples/hybrid_job_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


from braket.aws import AwsDevice, AwsQuantumJob
from braket.circuits import Circuit, FreeParameter, Observable
from braket.circuits import Circuit, FreeParameter, observables
from braket.devices import Devices
from braket.jobs import get_job_device_arn, save_job_result
from braket.jobs.metrics import log_metric
Expand All @@ -27,7 +27,7 @@ def run_hybrid_job(num_tasks: int):
circ = Circuit()
circ.rx(0, FreeParameter("theta"))
circ.cnot(0, 1)
circ.expectation(observable=Observable.X(), target=0)
circ.expectation(observable=observables.X(0))

# initial parameter
theta = 0.0
Expand Down
4 changes: 2 additions & 2 deletions examples/local_noise_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.

from braket.circuits import Circuit, Noise
from braket.circuits import Circuit, noises
from braket.devices import LocalSimulator

device = LocalSimulator("braket_dm")
Expand All @@ -23,7 +23,7 @@


circuit = Circuit().x(0).x(1)
noise = Noise.BitFlip(probability=0.1)
noise = noises.BitFlip(probability=0.1)
circuit.apply_gate_noise(noise)
print("Second example: ")
print(circuit)
Expand Down
8 changes: 6 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
"backoff",
"boltons",
"boto3>=1.28.53",
# SageMaker pinned cloudpickle==2.2.1
# see https://github.com/aws/sagemaker-python-sdk/issues/4871
"cloudpickle==2.2.1",
"nest-asyncio",
"networkx",
Expand All @@ -55,11 +57,13 @@
"pytest-cov",
"pytest-rerunfailures",
"pytest-xdist[psutil]",
"tox",
],
"docs": [
"sphinx",
"sphinx-rtd-theme",
"sphinxcontrib-apidoc",
"tox",
]
],
},
include_package_data=True,
url="https://github.com/amazon-braket/amazon-braket-sdk-python",
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.84.1.dev0"
__version__ = "1.88.3.dev0"
1 change: 1 addition & 0 deletions src/braket/aws/aws_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class AwsDevice(Device):
"Cz": "CZ",
"Cphaseshift": "CPhaseShift",
"Xy": "XY",
"Iswap": "ISwap",
}

def __init__(
Expand Down
29 changes: 25 additions & 4 deletions src/braket/aws/aws_quantum_task_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import time
from concurrent.futures.thread import ThreadPoolExecutor
from itertools import repeat
from typing import Any, Union
from typing import TYPE_CHECKING, Any, Union

from braket.ahs.analog_hamiltonian_simulation import AnalogHamiltonianSimulation
from braket.annealing import Problem
Expand All @@ -30,6 +30,14 @@
from braket.registers.qubit_set import QubitSet
from braket.tasks.quantum_task_batch import QuantumTaskBatch

if TYPE_CHECKING:
from braket.tasks.analog_hamiltonian_simulation_quantum_task_result import (
AnalogHamiltonianSimulationQuantumTaskResult,
)
from braket.tasks.annealing_quantum_task_result import AnnealingQuantumTaskResult
from braket.tasks.gate_model_quantum_task_result import GateModelQuantumTaskResult
from braket.tasks.photonic_model_quantum_task_result import PhotonicModelQuantumTaskResult


class AwsQuantumTaskBatch(QuantumTaskBatch):
"""Executes a batch of quantum tasks in parallel.
Expand Down Expand Up @@ -331,7 +339,12 @@ def results(
fail_unsuccessful: bool = False,
max_retries: int = MAX_RETRIES,
use_cached_value: bool = True,
) -> list[AwsQuantumTask]:
) -> list[
GateModelQuantumTaskResult
| AnnealingQuantumTaskResult
| PhotonicModelQuantumTaskResult
| AnalogHamiltonianSimulationQuantumTaskResult
]:
"""Retrieves the result of every quantum task in the batch.
Polling for results happens in parallel; this method returns when all quantum tasks
Expand All @@ -348,7 +361,8 @@ def results(
even when results have already been cached. Default: `True`.
Returns:
list[AwsQuantumTask]: The results of all of the quantum tasks in the batch.
list[GateModelQuantumTaskResult | AnnealingQuantumTaskResult | PhotonicModelQuantumTaskResult | AnalogHamiltonianSimulationQuantumTaskResult]: The # noqa: E501
results of all of the quantum tasks in the batch.
`FAILED`, `CANCELLED`, or timed out quantum tasks will have a result of None
"""
if not self._results or not use_cached_value:
Expand All @@ -369,7 +383,14 @@ def results(
return self._results

@staticmethod
def _retrieve_results(tasks: list[AwsQuantumTask], max_workers: int) -> list[AwsQuantumTask]:
def _retrieve_results(
tasks: list[AwsQuantumTask], max_workers: int
) -> list[
GateModelQuantumTaskResult
| AnnealingQuantumTaskResult
| PhotonicModelQuantumTaskResult
| AnalogHamiltonianSimulationQuantumTaskResult
]:
with ThreadPoolExecutor(max_workers=max_workers) as executor:
result_futures = [executor.submit(task.result) for task in tasks]
return [future.result() for future in result_futures]
Expand Down
Loading

0 comments on commit 371fc8f

Please sign in to comment.