-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'amazon-braket:main' into Hack1
- Loading branch information
Showing
31 changed files
with
156 additions
and
1,426 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "Braket" | ||
uuid = "19504a0f-b47d-4348-9127-acc6cc69ef67" | ||
authors = ["Katharine Hyatt <[email protected]>"] | ||
version = "0.9.0" | ||
version = "0.9.1" | ||
|
||
[deps] | ||
AWS = "fbe9abb3-538b-5e4e-ba9e-bc94f4f92ebc" | ||
|
@@ -49,10 +49,10 @@ DecFP = "=1.3.2" | |
Distributed = "1.6" | ||
Distributions = "=0.25.76" | ||
Downloads = "1" | ||
Graphs = "=1.11.0" | ||
HTTP = "=1.10.6" | ||
Graphs = "=1.11.1" | ||
HTTP = "=1.10.8" | ||
InteractiveUtils = "1.6" | ||
JLD2 = "=0.4.46" | ||
JLD2 = "=0.4.48" | ||
JSON3 = "=1.14.0" | ||
LinearAlgebra = "1.6" | ||
Logging = "1.6" | ||
|
@@ -63,7 +63,7 @@ OrderedCollections = "=1.6.3" | |
Pkg = "1.6" | ||
Random = "1.6" | ||
SparseArrays = "1.6" | ||
StaticArrays = "=1.9.3" | ||
StaticArrays = "=1.9.5" | ||
Statistics = "1.6" | ||
StructTypes = "=1.10.0" | ||
Symbolics = "=5.30.3" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
[deps] | ||
python = ">=3" | ||
python = ">=3.9,<=3.11" | ||
pydantic = "" | ||
scipy = "" | ||
numpy = "" | ||
|
||
[pip.deps] | ||
amazon-braket-sdk = ">=1.70.0" | ||
amazon-braket-sdk = ">=1.81.0" | ||
amazon-braket-default-simulator = ">=1.10.0" | ||
urllib3 = "<2" | ||
botocore = ">=1.34" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "PyBraket" | ||
uuid = "e85266a6-1825-490b-a80e-9b9469c53660" | ||
authors = ["Katharine Hyatt <[email protected]>"] | ||
version = "0.9.0" | ||
version = "0.9.1" | ||
|
||
[deps] | ||
Braket = "19504a0f-b47d-4348-9127-acc6cc69ef67" | ||
|
@@ -14,7 +14,7 @@ StructTypes = "856f2bd8-1eba-4b0a-8007-ebc267875bd4" | |
|
||
[compat] | ||
Aqua = "=0.8" | ||
Braket = "=0.9.0" | ||
Braket = "=0.9.1" | ||
CondaPkg = "=0.2.22" | ||
DataStructures = "=0.18.20" | ||
LinearAlgebra = "1.6" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,43 @@ | ||
struct LocalQuantumTask | ||
id::String | ||
result::Braket.AbstractQuantumTaskResult | ||
end | ||
Braket.state(b::LocalQuantumTask) = "COMPLETED" | ||
Braket.id(b::LocalQuantumTask) = b.id | ||
Braket.result(b::LocalQuantumTask) = b.result | ||
|
||
|
||
struct LocalSimulator <: Braket.Device | ||
struct PyLocalSimulator <: Braket.AbstractBraketSimulator | ||
o::Py | ||
LocalSimulator() = new(local_sim.LocalSimulator()) | ||
LocalSimulator(backend::String) = new(local_sim.LocalSimulator(backend)) | ||
PyLocalSimulator() = new(local_sim.LocalSimulator()) | ||
PyLocalSimulator(backend::String) = new(local_sim.LocalSimulator(backend)) | ||
end | ||
Braket.name(ls::LocalSimulator) = pyconvert(String, ls.name) | ||
|
||
function Base.run(d::LocalSimulator, task_spec::Braket.IR.AHSProgram; shots::Int=0, kwargs...) | ||
(ls::PyLocalSimulator)(nq::Int, shots::Int) = ls | ||
Braket.name(ls::PyLocalSimulator) = pyconvert(String, ls.name) | ||
Braket.device_id(ls::PyLocalSimulator) = pyconvert(String, ls._delegate.DEVICE_ID) | ||
Braket.properties(ls::PyLocalSimulator) = ls.properties | ||
function Braket.simulate(d::PyLocalSimulator, task_spec::Braket.IR.AHSProgram; shots::Int=0, kwargs...) | ||
py_ir = Py(task_spec) | ||
py_raw_result = d._delegate.run(py_ir, shots; kwargs...) | ||
jl_raw_result = pyconvert(Braket.AnalogHamiltonianSimulationTaskResult, py_raw_result) | ||
res = Braket.format_result(jl_raw_result) | ||
id = res.task_metadata.id | ||
LocalQuantumTask(id, res) | ||
end | ||
Base.run(d::LocalSimulator, task_spec::Braket.AnalogHamiltonianSimulation; shots::Int=0, kwargs...) = run(d, ir(task_spec); shots=shots, kwargs...) | ||
|
||
function Base.run(d::LocalSimulator, task_spec::Braket.OpenQasmProgram; shots::Int=0, inputs::Dict{String, Float64}=Dict{String,Float64}(), kwargs...) | ||
py_inputs = pydict(pystr(k)=>v for (k,v) in inputs) | ||
py_ts = pyopenqasm.Program(source=pystr(task_spec.source), inputs=py_inputs) | ||
py_raw_result = d._delegate.run_openqasm(py_ts, shots, kwargs...) | ||
jl_result = pyconvert(Braket.GateModelTaskResult, py_raw_result) | ||
t_id = jl_result.taskMetadata.id | ||
res = Braket.format_result(jl_result) | ||
LocalQuantumTask(t_id, res) | ||
return pyconvert(Braket.AnalogHamiltonianSimulationTaskResult, py_raw_result) | ||
end | ||
Braket.simulate(d::PyLocalSimulator, task_spec::Braket.AnalogHamiltonianSimulation; shots::Int=0, kwargs...) = simulate(d, ir(task_spec); shots=shots, kwargs...) | ||
|
||
function Base.run(d::LocalSimulator, task_spec::PyCircuit; shots::Int=0, inputs::Dict{String, Float64}=Dict{String,Float64}(), kwargs...) | ||
jaqcd_ir = task_spec.to_ir(ir_type=circuit.serialization.IRType.JAQCD) | ||
py_raw_result = d._delegate.run(jaqcd_ir, task_spec.qubit_count, shots, kwargs...) | ||
jl_result = pyconvert(Braket.GateModelTaskResult, py_raw_result) | ||
t_id = jl_result.taskMetadata.id | ||
res = Braket.format_result(jl_result) | ||
LocalQuantumTask(t_id, res) | ||
function Braket._run_internal(simulator::PyLocalSimulator, task_spec::AnalogHamiltonianSimulation, args...; kwargs...) | ||
raw_py_result = simulator._run_internal(Py(ir(task_spec)), args...; kwargs...) | ||
jl_task_metadata = pyconvert(Braket.TaskMetadata, raw_py_result.task_metadata) | ||
jl_measurements = map(raw_py_result.measurements) do m | ||
jl_status = pyconvert(String, pystr(m.status)) | ||
status = if jl_status == "Success" | ||
Braket.success | ||
elseif jl_status == "Partial_success" | ||
Braket.partial_success | ||
else | ||
Braket.failure | ||
end | ||
Braket.ShotResult(status, | ||
pyconvert(Any, m.pre_sequence), | ||
pyconvert(Any, m.post_sequence) | ||
) | ||
end | ||
return Braket.AnalogHamiltonianSimulationQuantumTaskResult(jl_task_metadata, jl_measurements) | ||
end | ||
Base.run(d::LocalSimulator, task_spec::Circuit; kwargs...) = run(d, PyCircuit(task_spec); kwargs...) | ||
|
||
(ls::LocalSimulator)(task_spec; kwargs...) = run(ls, task_spec; kwargs...) | ||
(ls::PyLocalSimulator)(task_spec; kwargs...) = simulate(ls, task_spec; kwargs...) | ||
|
||
Py(d::LocalSimulator) = getfield(d, :o) | ||
Base.getproperty(d::LocalSimulator, s::Symbol) = getproperty(Py(d), s) | ||
Base.getproperty(d::LocalSimulator, s::AbstractString) = getproperty(Py(d), s) | ||
Base.setproperty!(d::LocalSimulator, s::Symbol, x) = setproperty!(Py(d), s, x) | ||
Base.setproperty!(d::LocalSimulator, s::AbstractString, x) = setproperty!(Py(d), s, x) | ||
Py(d::PyLocalSimulator) = getfield(d, :o) | ||
Base.getproperty(d::PyLocalSimulator, s::Symbol) = getproperty(Py(d), s) | ||
Base.getproperty(d::PyLocalSimulator, s::AbstractString) = getproperty(Py(d), s) | ||
Base.setproperty!(d::PyLocalSimulator, s::Symbol, x) = setproperty!(Py(d), s, x) | ||
Base.setproperty!(d::PyLocalSimulator, s::AbstractString, x) = setproperty!(Py(d), s, x) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.