Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/actions/setup-pyth…
Browse files Browse the repository at this point in the history
…on-5.2.0
  • Loading branch information
math411 authored Oct 17, 2024
2 parents 008cc2f + 36e32f6 commit 5e0c9fa
Show file tree
Hide file tree
Showing 16 changed files with 85 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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@8a08d616893759ef8e1aa1f2785787c0b97e20d6 # release/v1
with:
password: ${{ secrets.pypi_token }}
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## 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
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
8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"backoff",
"boltons",
"boto3>=1.28.53",
"cloudpickle==2.2.1",
"cloudpickle>=3",
"nest-asyncio",
"networkx",
"numpy",
Expand All @@ -55,11 +55,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.87.1.dev0"
__version__ = "1.88.1.dev0"
2 changes: 1 addition & 1 deletion src/braket/devices/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class _Rigetti(str, Enum):
_Aspen11 = "arn:aws:braket:::device/qpu/rigetti/Aspen-11"
_AspenM1 = "arn:aws:braket:us-west-1::device/qpu/rigetti/Aspen-M-1"
_AspenM2 = "arn:aws:braket:us-west-1::device/qpu/rigetti/Aspen-M-2"
AspenM3 = "arn:aws:braket:us-west-1::device/qpu/rigetti/Aspen-M-3"
_AspenM3 = "arn:aws:braket:us-west-1::device/qpu/rigetti/Aspen-M-3"
Ankaa2 = "arn:aws:braket:us-west-1::device/qpu/rigetti/Ankaa-2"

class _Xanadu(str, Enum):
Expand Down
5 changes: 3 additions & 2 deletions src/braket/devices/local_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,9 @@ def _(self, program: OpenQASMProgram, inputs: Optional[dict[str, float]], _shots
return program

@_construct_payload.register
def _(self, program: SerializableProgram, _inputs, _shots):
return OpenQASMProgram(source=program.to_ir(ir_type=IRType.OPENQASM))
def _(self, program: SerializableProgram, inputs: Optional[dict[str, float]], _shots):
inputs_copy = inputs.copy() if inputs is not None else {}
return OpenQASMProgram(source=program.to_ir(ir_type=IRType.OPENQASM), inputs=inputs_copy)

@_construct_payload.register
def _(self, program: AnalogHamiltonianSimulation, _inputs, _shots):
Expand Down
2 changes: 1 addition & 1 deletion test/integ_tests/test_cost_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
[
"arn:aws:braket:us-east-1::device/qpu/ionq/Harmony",
"arn:aws:braket:eu-north-1::device/qpu/iqm/Garnet",
"arn:aws:braket:us-west-1::device/qpu/rigetti/Aspen-M-3",
"arn:aws:braket:us-west-1::device/qpu/rigetti/Ankaa-2",
],
)
def test_qpu_tracking(qpu):
Expand Down
4 changes: 2 additions & 2 deletions test/integ_tests/test_device_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
from braket.aws import AwsDevice
from braket.devices import Devices

RIGETTI_ARN = "arn:aws:braket:us-west-1::device/qpu/rigetti/Aspen-M-3"
RIGETTI_ARN = "arn:aws:braket:us-west-1::device/qpu/rigetti/Ankaa-2"
IONQ_ARN = "arn:aws:braket:us-east-1::device/qpu/ionq/Aria-1"
IQM_ARN = "arn:aws:braket:eu-north-1::device/qpu/iqm/Garnet"
SIMULATOR_ARN = "arn:aws:braket:::device/quantum-simulator/amazon/sv1"
PULSE_ARN = "arn:aws:braket:us-west-1::device/qpu/rigetti/Aspen-M-3"
PULSE_ARN = "arn:aws:braket:us-west-1::device/qpu/rigetti/Ankaa-2"


@pytest.mark.parametrize(
Expand Down
65 changes: 29 additions & 36 deletions test/integ_tests/test_pulse.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@pytest.fixture
def device():
return AwsDevice("arn:aws:braket:us-west-1::device/qpu/rigetti/Aspen-M-3")
return AwsDevice("arn:aws:braket:us-west-1::device/qpu/rigetti/Ankaa-2")


@pytest.fixture
Expand Down Expand Up @@ -174,38 +174,30 @@ def h_gate(q0):
return Circuit().rz(q0, np.pi).rx(q0, np.pi / 2).rz(q0, np.pi / 2).rx(q0, -np.pi / 2)


def cz_pulse(
def make_pulse(
q0: str,
q1: str,
shift_phases_q0: float,
shift_phases_q1: float,
waveform: ArbitraryWaveform,
device: AwsDevice,
):
q0_rf_frame = device.frames[f"q{q0}_rf_frame"]
q1_rf_frame = device.frames[f"q{q1}_rf_frame"]
q0_q1_cz_frame = device.frames[f"q{q0}_q{q1}_cz_frame"]
frames = [q0_rf_frame, q1_rf_frame, q0_q1_cz_frame]
q0_drive_frame = device.frames[f"Transmon_{q0}_charge_tx"]
q1_drive_frame = device.frames[f"Transmon_{q1}_charge_tx"]
frames = [q0_drive_frame, q1_drive_frame]

dt = device.properties.pulse.ports[q0_q1_cz_frame.port.id].dt
dt = device.properties.pulse.ports[q0_drive_frame.port.id].dt
wfm_duration = len(waveform.amplitudes) * dt

pulse_sequence = (
PulseSequence()
.barrier(frames)
.play(q0_q1_cz_frame, waveform)
.delay(q0_rf_frame, wfm_duration)
.shift_phase(q0_rf_frame, shift_phases_q0)
.delay(q1_rf_frame, wfm_duration)
.shift_phase(q1_rf_frame, shift_phases_q1)
.delay(q0_drive_frame, wfm_duration)
.shift_phase(q0_drive_frame, shift_phases_q0)
.delay(q1_drive_frame, wfm_duration)
.shift_phase(q1_drive_frame, shift_phases_q1)
.barrier(frames)
)
for phase, q in [(shift_phases_q0 * 0.5, q0), (-shift_phases_q1 * 0.5, q1)]:
for neighbor in device.properties.paradigm.connectivity.connectivityGraph[str(q)]:
xy_frame_name = f"q{min(q, int(neighbor))}_q{max(q, int(neighbor))}_xy_frame"
if xy_frame_name in device.frames:
xy_frame = device.frames[xy_frame_name]
pulse_sequence.shift_phase(xy_frame, phase)
return pulse_sequence


Expand All @@ -216,17 +208,17 @@ def test_pulse_bell(arbitrary_waveform, device):
a,
b,
) = (
10,
113,
26,
33,
) # qubits used
p0, p1 = 1.1733407221086924, 6.269846678712192
theta_0, theta_1 = FreeParameter("theta_0"), FreeParameter("theta_1")
a_b_cz_waveform = arbitrary_waveform
cz = cz_pulse(a, b, theta_0, theta_1, a_b_cz_waveform, device)
a_b_waveform = arbitrary_waveform
pulse = make_pulse(a, b, theta_0, theta_1, a_b_waveform, device)

bell_pair_with_gates = Circuit().h(a).h(b).cz(a, b).h(b)
bell_pair_with_gates = Circuit().h(a).h(b).iswap(a, b).h(b)
bell_pair_with_pulses_unbound = (
h_gate(a) + h_gate(b) + Circuit().pulse_gate([a, b], cz) + h_gate(b)
h_gate(a) + h_gate(b) + Circuit().pulse_gate([a, b], pulse) + h_gate(b)
)
bell_pair_with_pulses = bell_pair_with_pulses_unbound(theta_0=p0, theta_1=p1)

Expand Down Expand Up @@ -266,27 +258,27 @@ def test_pulse_sequence(arbitrary_waveform, device):
a,
b,
) = (
10,
113,
26,
33,
) # qubits used
p0, p1 = 1.1733407221086924, 6.269846678712192
theta_0, theta_1 = FreeParameter("theta_0"), FreeParameter("theta_1")
a_b_cz_waveform = arbitrary_waveform
a_b_waveform = arbitrary_waveform

cz_with_pulses_unbound = cz_pulse(a, b, theta_0, theta_1, a_b_cz_waveform, device)
pulse_unbound = make_pulse(a, b, theta_0, theta_1, a_b_waveform, device)

q0_readout_frame = device.frames[f"q{a}_ro_rx_frame"]
q1_readout_frame = device.frames[f"q{b}_ro_rx_frame"]
cz_with_pulses = (
cz_with_pulses_unbound(theta_0=p0, theta_1=p1)
q0_readout_frame = device.frames[f"Transmon_{a}_readout_rx"]
q1_readout_frame = device.frames[f"Transmon_{b}_readout_rx"]
pulses = (
pulse_unbound(theta_0=p0, theta_1=p1)
.capture_v0(q0_readout_frame)
.capture_v0(q1_readout_frame)
)
cz_with_gates = Circuit().cz(a, b)
circuit_with_gates = Circuit().iswap(a, b)

num_shots = 1000
gate_task = device.run(cz_with_gates, shots=num_shots, disable_qubit_rewiring=True)
pulse_task = device.run(cz_with_pulses, shots=num_shots)
gate_task = device.run(circuit_with_gates, shots=num_shots, disable_qubit_rewiring=True)
pulse_task = device.run(pulses, shots=num_shots)

if not device.is_available:
try:
Expand All @@ -313,12 +305,13 @@ def test_pulse_sequence(arbitrary_waveform, device):
assert chi_squared < 10 # adjust this threshold if test is flaky


@pytest.mark.skip(reason="needs to be updated to work correctly on Ankaa-2")
def test_gate_calibration_run(device, pulse_sequence):
if device.status == "OFFLINE":
pytest.skip("Device offline")
user_gate_calibrations = GateCalibrations({(Gate.Rx(math.pi / 2), QubitSet(0)): pulse_sequence})
num_shots = 50
bell_circuit = Circuit().rx(0, math.pi / 2).rx(1, math.pi / 2).cz(0, 1).rx(1, -math.pi / 2)
bell_circuit = Circuit().rx(0, math.pi / 2).rx(1, math.pi / 2).iswap(0, 1).rx(1, -math.pi / 2)
user_calibration_task = device.run(
bell_circuit,
gate_definitions=user_gate_calibrations.pulse_sequences,
Expand Down
2 changes: 1 addition & 1 deletion test/unit_tests/braket/aws/common_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from braket.aws import AwsQuantumTaskBatch

DWAVE_ARN = "arn:aws:braket:::device/qpu/d-wave/Advantage_system1"
RIGETTI_ARN = "arn:aws:braket:::device/qpu/rigetti/Aspen-10"
RIGETTI_ARN = "arn:aws:braket:::device/qpu/rigetti/Ankaa-2"
IONQ_ARN = "arn:aws:braket:us-east-1::device/qpu/ionq/Harmony"
OQC_ARN = "arn:aws:braket:eu-west-2::device/qpu/oqc/Lucy"
SV1_ARN = "arn:aws:braket:::device/quantum-simulator/amazon/sv1"
Expand Down
4 changes: 2 additions & 2 deletions test/unit_tests/braket/aws/test_aws_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def test_mock_rigetti_schema_1():


MOCK_GATE_MODEL_QPU_1 = {
"deviceName": "Aspen-10",
"deviceName": "Ankaa-2",
"deviceType": "QPU",
"providerName": "Rigetti",
"deviceStatus": "OFFLINE",
Expand Down Expand Up @@ -1451,7 +1451,7 @@ def test_run_device_poll_interval_kwargs(
capabilities = MOCK_GATE_MODEL_QPU_CAPABILITIES_1
capabilities.service.getTaskPollIntervalMillis = poll_interval_seconds
properties = {
"deviceName": "Aspen-10",
"deviceName": "Ankaa-2",
"deviceType": "QPU",
"providerName": "provider1",
"deviceStatus": "OFFLINE",
Expand Down
2 changes: 1 addition & 1 deletion test/unit_tests/braket/aws/test_aws_quantum_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _get_job_response(**kwargs):
},
"createdAt": datetime.datetime(2021, 6, 28, 21, 4, 51),
"deviceConfig": {
"device": "arn:aws:braket:::device/qpu/rigetti/Aspen-10",
"device": "arn:aws:braket:::device/qpu/rigetti/Ankaa-2",
},
"hyperParameters": {
"foo": "bar",
Expand Down
21 changes: 19 additions & 2 deletions test/unit_tests/braket/devices/test_local_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,17 +588,34 @@ def test_run_serializable_program_model():
source="""
qubit[2] q;
bit[2] c;
h q[0];
cnot q[0], q[1];
c = measure q;
"""
)
)
assert task.result() == GateModelQuantumTaskResult.from_object(GATE_MODEL_RESULT)


def test_run_serializable_program_model_with_inputs():
dummy = DummySerializableProgramSimulator()
sim = LocalSimulator(dummy)
task = sim.run(
DummySerializableProgram(
source="""
input float a;
qubit[2] q;
bit[2] c;
h q[0];
cnot q[0], q[1];
c = measure q;
"""
),
inputs={"a": 0.1},
)
assert task.result() == GateModelQuantumTaskResult.from_object(GATE_MODEL_RESULT)


@pytest.mark.xfail(raises=ValueError)
def test_run_gate_model_value_error():
dummy = DummyCircuitSimulator()
Expand Down
2 changes: 1 addition & 1 deletion test/unit_tests/braket/jobs/test_quantum_job_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def _get_job_response(**kwargs):
},
"createdAt": datetime.datetime(2021, 6, 28, 21, 4, 51),
"deviceConfig": {
"device": "arn:aws:braket:::device/qpu/rigetti/Aspen-10",
"device": "arn:aws:braket:::device/qpu/rigetti/Ankaa-2",
},
"hyperParameters": {
"foo": "bar",
Expand Down
4 changes: 1 addition & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,9 @@ commands =
basepython = python3
deps =
{[test-deps]deps}
sphinx
sphinx-rtd-theme
sphinxcontrib-apidoc
commands =
sphinx-build -E -T -b html doc build/documentation/html -j auto
extras = docs

[testenv:serve-docs]
basepython = python3
Expand Down

0 comments on commit 5e0c9fa

Please sign in to comment.