Skip to content
This repository was archived by the owner on Jun 26, 2026. It is now read-only.
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/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v6.0.3
- uses: actions/checkout@v7.0.0
- name: Install juliaup
uses: julia-actions/install-juliaup@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
check-code-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.3
- uses: actions/checkout@v7.0.0
- name: Set up Python
uses: actions/setup-python@v6
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
permissions:
id-token: write
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v5.0.1
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v5.0.1
- name: Set up Python
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v6.0.3
- uses: actions/checkout@v7.0.0
- name: Install juliaup
uses: julia-actions/install-juliaup@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/twine-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
name: Check long description
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.3
- uses: actions/checkout@v7.0.0
- name: Set up Python
uses: actions/setup-python@v6
with:
Expand Down
79 changes: 73 additions & 6 deletions test/unit_tests/braket/simulator_v2/test_pennylane.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import numpy as anp
import pennylane as qml
import pytest
from braket.circuits import Circuit, Gate, Noise, Observable, result_types
from braket.circuits import Circuit, FreeParameter, Gate, Noise, Observable, result_types
from braket.circuits.noise_model import GateCriteria, NoiseModel, NoiseModelInstruction
from braket.devices import LocalSimulator
from braket.pennylane_plugin import BraketLocalQubitDevice
Expand All @@ -40,17 +40,82 @@
SIM_TASK.result.return_value.result_types = []
type(SIM_TASK).id = PropertyMock(return_value="task_arn")
SIM_TASK.state.return_value = "COMPLETED"

CIRCUIT = (
Circuit()
.h(0)
.cnot(0, 1)
.i(2)
.ry(1, -np.pi / 2)
.rx(2, np.pi / 2)
.i(3)
.probability(target=[0])
.expectation(observable=Observable.Z(), target=1)
.variance(observable=Observable.Z(), target=2)
.sample(observable=Observable.Z(), target=3)
)

CIRCUIT_QUBIT_DEVICE = (
Circuit()
.h(0)
.cnot(0, 1)
.ry(1, FreeParameter("p_0"))
.rx(2, FreeParameter("p_1"))
.i(3)
.probability(target=[0])
.expectation(observable=Observable.X(), target=1)
.variance(observable=Observable.Y(), target=2)
.expectation(observable=Observable.Z(), target=1)
.variance(observable=Observable.Z(), target=2)
.sample(observable=Observable.Z(), target=3)
)
INPUTS_QUBIT_DEVICE = {"p_0": -np.pi / 2, "p_1": np.pi / 2}

RESULT_QUBIT_DEVICE = GateModelQuantumTaskResult.from_string(
json.dumps({
"braketSchemaHeader": {
"name": "braket.task_result.gate_model_task_result",
"version": "1",
},
"measurements": [[0, 0, 0, 0], [1, 1, 1, 1], [1, 1, 0, 0], [0, 0, 1, 1]],
"resultTypes": [
{"type": {"targets": [0], "type": "probability"}, "value": [0.5, 0.5]},
{
"type": {"observable": ["z"], "targets": [1], "type": "expectation"},
"value": 0.0,
},
{
"type": {"observable": ["z"], "targets": [2], "type": "variance"},
"value": 0.1,
},
{
"type": {"observable": ["z"], "targets": [3], "type": "sample"},
"value": [1, -1, 1, 1],
},
],
"measuredQubits": [0, 1, 2, 3],
"taskMetadata": {
"braketSchemaHeader": {
"name": "braket.task_result.task_metadata",
"version": "1",
},
"id": "task_arn",
"shots": 0,
"deviceId": "default",
},
"additionalMetadata": {
"action": {
"braketSchemaHeader": {
"name": "braket.ir.openqasm.program",
"version": "1",
},
"source": "qubit[2] q; cnot q[0], q[1]; measure q;",
},
},
})
)

TASK_QUBIT_DEVICE = Mock()
TASK_QUBIT_DEVICE.result.return_value = RESULT_QUBIT_DEVICE
type(TASK_QUBIT_DEVICE).id = PropertyMock(return_value="task_arn")
TASK_QUBIT_DEVICE.state.return_value = "COMPLETED"

DEVICE_ARN = "baz"

Expand Down Expand Up @@ -246,7 +311,7 @@ def test_local_none_shots(backend):
@pytest.mark.parametrize("backend", ["braket_sv_v2", "braket_dm_v2"])
def test_local_qubit_execute(mock_run, shots, backend):
"""Tests that the local qubit device is run with the correct arguments"""
mock_run.return_value = TASK
mock_run.return_value = TASK_QUBIT_DEVICE
dev = BraketLocalQubitDevice(wires=4, backend=backend, shots=shots, foo="bar")

with QuantumTape() as circuit:
Expand All @@ -258,7 +323,9 @@ def test_local_qubit_execute(mock_run, shots, backend):
qml.sample(qml.PauliZ(3))

dev.execute(circuit)
mock_run.assert_called_with(CIRCUIT, shots=shots, foo="bar", inputs={})
mock_run.assert_called_with(
CIRCUIT_QUBIT_DEVICE, shots=shots, foo="bar", inputs=INPUTS_QUBIT_DEVICE
)


def test_projection():
Expand Down
Loading