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

feature: Add IQM Garnet device, retire OQC Lucy device #93

Merged
merged 5 commits into from
Jul 3, 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
9 changes: 6 additions & 3 deletions src/device.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
```
"""
abstract type BraketDevice end
for provider in (:AmazonDevice, :_XanaduDevice, :_DWaveDevice, :OQCDevice, :QuEraDevice, :IonQDevice, :RigettiDevice)
for provider in (:AmazonDevice, :_XanaduDevice, :_DWaveDevice, :_OQCDevice, :IQMDevice, :QuEraDevice, :IonQDevice, :RigettiDevice)
@eval begin
abstract type $provider <: BraketDevice end
end
Expand Down Expand Up @@ -67,8 +67,11 @@
struct Aquila <: QuEraDevice end
Base.convert(::Type{String}, d::Aquila) = "arn:aws:braket:us-east-1::device/qpu/quera/Aquila"

struct Lucy <: OQCDevice end
Base.convert(::Type{String}, d::Lucy) = "arn:aws:braket:eu-west-2::device/qpu/oqc/Lucy"
struct _Lucy <: _OQCDevice end
Base.convert(::Type{String}, d::_Lucy) = "arn:aws:braket:eu-west-2::device/qpu/oqc/Lucy"

Check warning on line 71 in src/device.jl

View check run for this annotation

Codecov / codecov/patch

src/device.jl#L71

Added line #L71 was not covered by tests

struct Garnet <: IQMDevice end
Base.convert(::Type{String}, d::Garnet) = "arn:aws:braket:eu-north-1::device/qpu/iqm/Garnet"

Check warning on line 74 in src/device.jl

View check run for this annotation

Codecov / codecov/patch

src/device.jl#L74

Added line #L74 was not covered by tests

for (d, d_arn) in zip((:_Aspen8, :_Aspen9, :_Aspen10, :_Aspen11, :_AspenM1, :_AspenM2, :AspenM3),
("arn:aws:braket:::device/qpu/rigetti/Aspen-8",
Expand Down
41 changes: 38 additions & 3 deletions src/raw_schema.jl

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/task.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ function _device_parameters_from_dict(device_parameters::Dict{String,<:Any}, dev
occursin("ionq", device_arn) && return IonqDeviceParameters(header_dict[IonqDeviceParameters], paradigm_parameters, processed_em)
occursin("rigetti", device_arn) && return RigettiDeviceParameters(header_dict[RigettiDeviceParameters], paradigm_parameters)
occursin("oqc", device_arn) && return OqcDeviceParameters(header_dict[OqcDeviceParameters], paradigm_parameters)
occursin("iqm", device_arn) && return IqmDeviceParameters(header_dict[IqmDeviceParameters], paradigm_parameters)
return GateModelSimulatorDeviceParameters(header_dict[GateModelSimulatorDeviceParameters], paradigm_parameters)
end

Expand Down
2 changes: 1 addition & 1 deletion test/annealing_task_result.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ using Braket, JSON3, Test
Dict(0=>0.3333, 1=>-0.333, 4=>-0.333, 5=>0.333),
Dict("0,4"=> 0.667, "0,5"=> -1, "1,4"=> 0.667, "1,5"=> 0.667),
)
additional_metadata = Braket.AdditionalMetadata(problem, dwave_metadata, nothing, nothing, nothing, nothing, nothing, nothing)
additional_metadata = Braket.AdditionalMetadata(problem, dwave_metadata, nothing, nothing, nothing, nothing, nothing, nothing, nothing)
function result_str_1()
result = Braket.AnnealingTaskResult(Braket.header_dict[Braket.AnnealingTaskResult],
solutions,
Expand Down
12 changes: 6 additions & 6 deletions test/gate_model_task_result.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ non_zero_shots_result(task_mtd, add_mtd) = Braket.GateModelTaskResult(
action = Braket.Program(c)
@testset for (shots, result) in zip([0, 100], [zero_shots_result, non_zero_shots_result])
task_metadata = Braket.TaskMetadata(Braket.header_dict[Braket.TaskMetadata], "task_arn", shots, "arn1", nothing, nothing, nothing, nothing, nothing)
additional_metadata = Braket.AdditionalMetadata(action, nothing, nothing, nothing, nothing, nothing, nothing, nothing)
additional_metadata = Braket.AdditionalMetadata(action, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing)
r = result(task_metadata, additional_metadata)
g = Braket.format_result(r)
@test g isa Braket.GateModelQuantumTaskResult
Expand All @@ -45,7 +45,7 @@ non_zero_shots_result(task_mtd, add_mtd) = Braket.GateModelTaskResult(
end
end
task_metadata = Braket.TaskMetadata(Braket.header_dict[Braket.TaskMetadata], "task_arn", 0, "arn1", nothing, nothing, nothing, nothing, nothing)
additional_metadata = Braket.AdditionalMetadata(action, nothing, nothing, nothing, nothing, nothing, nothing, nothing)
additional_metadata = Braket.AdditionalMetadata(action, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing)
result = Braket.GateModelQuantumTaskResult(task_metadata, JSON3.read(JSON3.write(additional_metadata), Braket.AdditionalMetadata), nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing)
@test JSON3.read("{\"task_metadata\": $(JSON3.write(task_metadata)), \"additional_metadata\": $(JSON3.write(additional_metadata))}", Braket.GateModelQuantumTaskResult) == result
end
Expand Down Expand Up @@ -78,7 +78,7 @@ end
],
[])
task_metadata_shots = Braket.TaskMetadata(Braket.header_dict[Braket.TaskMetadata], "task_arn", length(measurements), "arn1", nothing, nothing, nothing, nothing, nothing)
additional_metadata = Braket.AdditionalMetadata(action, nothing, nothing, nothing, nothing, nothing, nothing, nothing)
additional_metadata = Braket.AdditionalMetadata(action, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing)
task_result = Braket.GateModelTaskResult(Braket.header_dict[Braket.GateModelTaskResult],
measurements,
nothing,
Expand All @@ -104,7 +104,7 @@ end
],
[])
task_metadata_shots = Braket.TaskMetadata(Braket.header_dict[Braket.TaskMetadata], "task_arn", length(measurements), "arn1", nothing, nothing, nothing, nothing, nothing)
additional_metadata = Braket.AdditionalMetadata(action, nothing, nothing, nothing, nothing, nothing, nothing, nothing)
additional_metadata = Braket.AdditionalMetadata(action, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing)
task_result = Braket.GateModelTaskResult(Braket.header_dict[Braket.GateModelTaskResult],
measurements,
nothing,
Expand All @@ -120,7 +120,7 @@ end

@testset "result without measurements or measurementProbabilities" begin
task_metadata_shots = Braket.TaskMetadata(Braket.header_dict[Braket.TaskMetadata], "task_arn", length(measurements), "arn1", nothing, nothing, nothing, nothing, nothing)
additional_metadata = Braket.AdditionalMetadata(action, nothing, nothing, nothing, nothing, nothing, nothing, nothing)
additional_metadata = Braket.AdditionalMetadata(action, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing)
task_result = Braket.GateModelTaskResult(Braket.header_dict[Braket.GateModelTaskResult],
nothing,
nothing,
Expand All @@ -134,7 +134,7 @@ end
@testset "bad result type in results for shots > 0" begin
action = Braket.Program(Braket.header_dict[Braket.Program], [Braket.IR.CNot(0, 1, "cnot"), Braket.IR.CNot(2, 3, "cnot")], [Braket.IR.DensityMatrix([1,3], "densitymatrix")], [])
task_metadata_shots = Braket.TaskMetadata(Braket.header_dict[Braket.TaskMetadata], "task_arn", length(measurements), "arn1", nothing, nothing, nothing, nothing, nothing)
additional_metadata = Braket.AdditionalMetadata(action, nothing, nothing, nothing, nothing, nothing, nothing, nothing)
additional_metadata = Braket.AdditionalMetadata(action, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing)
task_result = Braket.GateModelTaskResult(Braket.header_dict[Braket.GateModelTaskResult],
measurements,
nothing,
Expand Down
2 changes: 1 addition & 1 deletion test/integ_tests/cost_tracking.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using AWS: @service, AWSConfig, global_aws_config
circuit = Circuit([(H, 0)])
t = Braket.Tracker()
n_available = 0
for arn = ("arn:aws:braket:eu-west-2::device/qpu/oqc/Lucy", "arn:aws:braket:us-west-1::device/qpu/rigetti/Aspen-M-3", "arn:aws:braket:us-east-1::device/qpu/ionq/Harmony")
for arn = ("arn:aws:braket:eu-west-2::device/qpu/oqc/Lucy", "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-east-1::device/qpu/ionq/Harmony")
d = AwsDevice(arn)
if Braket.isavailable(d)
d(circuit, shots=10)
Expand Down
11 changes: 5 additions & 6 deletions test/integ_tests/device_creation.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using Braket, Test

DWAVE_ARN = "arn:aws:braket:::device/qpu/d-wave/DW_2000Q_6"
RIGETTI_ARN = "arn:aws:braket:::device/qpu/rigetti/Aspen-11"
RIGETTI_ARN = "arn:aws:braket:::device/qpu/rigetti/Aspen-M-3"
IONQ_ARN = "arn:aws:braket:us-east-1::device/qpu/ionq/Aria-1"
SIMULATOR_ARN = "arn:aws:braket:::device/quantum-simulator/amazon/sv1"
OQC_ARN = "arn:aws:braket:eu-west-2::device/qpu/oqc/Lucy"
IQM_ARN = "arn:aws:braket:eu-north-1::device/qpu/iqm/Garnet"

@testset "Device Creation" begin
@testset for dev_arn in (RIGETTI_ARN, IONQ_ARN, DWAVE_ARN, OQC_ARN, SIMULATOR_ARN)
@testset for dev_arn in (RIGETTI_ARN, IONQ_ARN, IQM_ARN, SIMULATOR_ARN)
device = AwsDevice(dev_arn)
@test arn(device) == dev_arn
@test !isnothing(name(device)) && !isempty(name(device))
Expand All @@ -17,7 +16,7 @@ OQC_ARN = "arn:aws:braket:eu-west-2::device/qpu/oqc/Lucy"
@test !isnothing(properties(device))
end
@testset "get_devices" begin
@testset for dev_arn in [RIGETTI_ARN, IONQ_ARN, DWAVE_ARN, OQC_ARN, SIMULATOR_ARN]
@testset for dev_arn in [RIGETTI_ARN, IONQ_ARN, IQM_ARN, SIMULATOR_ARN]
results = get_devices(arns=[dev_arn])
@test arn(first(results)) == dev_arn
end
Expand All @@ -35,7 +34,7 @@ OQC_ARN = "arn:aws:braket:eu-west-2::device/qpu/oqc/Lucy"
end
@testset "all" begin
result_arns = arn.(get_devices())
for dev_arn in [DWAVE_ARN, RIGETTI_ARN, IONQ_ARN, SIMULATOR_ARN, OQC_ARN]
for dev_arn in [RIGETTI_ARN, IONQ_ARN, SIMULATOR_ARN, IQM_ARN]
@test dev_arn ∈ result_arns
end
end
Expand Down
3 changes: 2 additions & 1 deletion test/integ_tests/measure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ SHOTS = 8000
IONQ_ARN = "arn:aws:braket:us-east-1::device/qpu/ionq/Harmony"
SIMULATOR_ARN = "arn:aws:braket:::device/quantum-simulator/amazon/sv1"
OQC_ARN = "arn:aws:braket:eu-west-2::device/qpu/oqc/Lucy"
IQM_ARN = "arn:aws:braket:eu-north-1::device/qpu/iqm/Garnet"

@testset "Measure operator" begin
@testset "Unsupported devices" begin
Expand All @@ -17,7 +18,7 @@ OQC_ARN = "arn:aws:braket:eu-west-2::device/qpu/oqc/Lucy"
end
end
@testset "Supported devices" begin
@testset "Arn $arn" for arn in (OQC_ARN,)
@testset "Arn $arn" for arn in (OQC_ARN, IQM_ARN)
device = AwsDevice(arn)
status(device) == "OFFLINE" && continue
circ = Circuit([(H, 0), (CNot, 0, 1), (Measure, 0)])
Expand Down
Loading
Loading