diff --git a/PyBraket/CondaPkg.toml b/PyBraket/CondaPkg.toml index 87c0f149..48fd26b0 100644 --- a/PyBraket/CondaPkg.toml +++ b/PyBraket/CondaPkg.toml @@ -6,3 +6,4 @@ numpy = "" [pip.deps] amazon-braket-sdk = ">=1.70.0" +amazon-braket-default-simulator = ">=1.10.0" diff --git a/PyBraket/README.md b/PyBraket/README.md index 6e401094..44eb600b 100644 --- a/PyBraket/README.md +++ b/PyBraket/README.md @@ -2,8 +2,7 @@ **PyBraket.jl is not an officially supported AWS product.** -This package provides Julia-Python interoperability between `Braket.jl` and Python features of the Amazon Braket SDK, such as the Amazon Braket [Local Simulators](https://docs.aws.amazon.com/braket/latest/developerguide/braket-send-to-local-simulator.html) and -[Local Jobs](https://docs.aws.amazon.com/braket/latest/developerguide/braket-jobs-local-mode.html). +This package provides Julia-Python interoperability between `Braket.jl` and Python features of the Amazon Braket SDK, such as the Amazon Braket [Local Simulators](https://docs.aws.amazon.com/braket/latest/developerguide/braket-send-to-local-simulator.html) and support for unpickling the [results of Braket Jobs](https://docs.aws.amazon.com/braket/latest/developerguide/braket-jobs-save-results.html). This is *experimental* software, and support may be discontinued in the future. For a fully supported SDK, please use the [Python SDK](https://github.com/aws/amazon-braket-sdk-python). We may change, remove, or deprecate parts of the API when making new releases. @@ -11,12 +10,12 @@ Please review the [CHANGELOG](CHANGELOG.md) for information about changes in eac ## Installation & Prerequisites -You'll need [`PythonCall.jl`](https://cjdoris.github.io/PythonCall.jl). +You'll need [`PythonCall.jl`](https://cjdoris.github.io/PythonCall.jl) installed to use this package. ### Use `CondaPkg.jl` `PyBraket.jl` now supports [`CondaPkg.jl`](https://github.com/cjdoris/CondaPkg.jl)! The package and its tests come with `CondaPkg.toml` files ready to go. -`CondaPkg` will install all necessary dependencies for you. +`CondaPkg.jl` will install all necessary dependencies for you. ### Use native Python installation diff --git a/PyBraket/src/PyBraket.jl b/PyBraket/src/PyBraket.jl index 301e2895..a2d1e9f2 100644 --- a/PyBraket/src/PyBraket.jl +++ b/PyBraket/src/PyBraket.jl @@ -5,35 +5,28 @@ module PyBraket import Braket: Instruction using Braket.IR import Braket.IR: TimeSeries, AtomArrangement, DrivingField, PhysicalField, ShiftingField, Setup, Hamiltonian, AHSProgram - export LocalSimulator, PyCircuit + export PyLocalSimulator import PythonCall: Py const awsbraket = PythonCall.pynew() - const braketobs = PythonCall.pynew() const local_sim = PythonCall.pynew() + const default_sim = PythonCall.pynew() const tasks = PythonCall.pynew() - const circuit = PythonCall.pynew() - const pyjaqcd = PythonCall.pynew() const pyahs = PythonCall.pynew() const pyopenqasm = PythonCall.pynew() - const pygates = PythonCall.pynew() - const pynoises = PythonCall.pynew() const collections = PythonCall.pynew() function __init__() # must set these when this code is actually loaded PythonCall.pycopy!(awsbraket, pyimport("braket.aws")) - PythonCall.pycopy!(braketobs, pyimport("braket.circuits.observables")) PythonCall.pycopy!(local_sim, pyimport("braket.devices.local_simulator")) - PythonCall.pycopy!(circuit, pyimport("braket.circuits")) - PythonCall.pycopy!(pygates, pyimport("braket.circuits.gates")) - PythonCall.pycopy!(pynoises, pyimport("braket.circuits.noises")) - PythonCall.pycopy!(pyjaqcd, pyimport("braket.ir.jaqcd")) + PythonCall.pycopy!(default_sim, pyimport("braket.default_simulator")) PythonCall.pycopy!(pyopenqasm, pyimport("braket.ir.openqasm")) PythonCall.pycopy!(pyahs, pyimport("braket.ir.ahs")) PythonCall.pycopy!(tasks, pyimport("braket.tasks")) PythonCall.pycopy!(collections, pyimport("collections")) PythonCall.pyconvert_add_rule("collections:Counter", Accumulator, counter_to_acc) + Braket._simulator_devices[]["braket_ahs"] = PyLocalSimulator("braket_ahs") end function counter_to_acc(::Type{Accumulator}, x::Py) return counter((pyconvert(Any, el) for el in x.elements())) @@ -64,24 +57,8 @@ module PyBraket end return args end - - for (irT, pyT) in ((:(Braket.IR.Expectation), :(pyjaqcd.Expectation)), - (:(Braket.IR.Variance), :(pyjaqcd.Variance)), - (:(Braket.IR.Sample), :(pyjaqcd.Sample)), - (:(Braket.IR.Amplitude), :(pyjaqcd.Amplitude)), - (:(Braket.IR.StateVector), :(pyjaqcd.StateVector)), - (:(Braket.IR.Probability), :(pyjaqcd.Probability)), - (:(Braket.IR.DensityMatrix), :(pyjaqcd.DensityMatrix))) - @eval begin - Py(o::$irT) = $pyT(;arg_gen(o, fieldnames($irT))...) - end - end - include("pyahs.jl") - include("pygates.jl") - include("pynoises.jl") include("pyschema.jl") using .PySchema - include("pycircuit.jl") include("local_simulator.jl") end diff --git a/PyBraket/src/local_simulator.jl b/PyBraket/src/local_simulator.jl index d88034db..2b7b0495 100644 --- a/PyBraket/src/local_simulator.jl +++ b/PyBraket/src/local_simulator.jl @@ -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) diff --git a/PyBraket/src/pycircuit.jl b/PyBraket/src/pycircuit.jl deleted file mode 100644 index 6724c6e1..00000000 --- a/PyBraket/src/pycircuit.jl +++ /dev/null @@ -1,49 +0,0 @@ -mutable struct PyCircuit - o::Py - PyCircuit(o::Py) = new(o) - PyCircuit(v::Vector{Py}) = new(circuit.Circuit(pylist(v))) - PyCircuit() = new(circuit.Circuit()) -end -(c::PyCircuit)(arg::Number; kwargs...) = PyCircuit(Py(c)(arg; kwargs...)) -(c::PyCircuit)(; kwargs...) = PyCircuit(Py(c)(; kwargs...)) -Base.:(==)(c1::PyCircuit, c2::PyCircuit) = pyconvert(Bool, Py(c1) == Py(c2)) -Py(c::PyCircuit) = getfield(c, :o) -Base.getproperty(c::PyCircuit, s::Symbol) = pyconvert(Any, getproperty(Py(c), s)) -Base.getproperty(c::PyCircuit, s::AbstractString) = pyconvert(Any, getproperty(Py(c), s)) -Base.setproperty!(c::PyCircuit, s::Symbol, x) = pyconvert(Any, setproperty!(Py(c), s, x)) -Base.setproperty!(c::PyCircuit, s::AbstractString, x) = pyconvert(Any, setproperty!(Py(c), s, x)) -function Base.show(io::IO, c::PyCircuit) - if isempty(c.result_types) - print(io, "PyCircuit('instructions': $(c.instructions))") - else - print(io, "PyCircuit('instructions': $(c.instructions), 'result_types': $(c.result_types))") - end -end - -Py(ix::Instruction) = circuit.Instruction(Py(ix.operator), pylist(ix.target isa Int ? [ix.target] : ix.target)) -function Base.convert(::Type{PyCircuit}, c::Circuit) - addables = vcat(map(Py, c.instructions), map(Py, c.result_types)) - pc = PyCircuit(addables) - return pc -end -PyCircuit(c::Circuit) = convert(PyCircuit, c) - -Py(o::Braket.Observables.HermitianObservable) = braketobs.Hermitian(Py(o.matrix)) -Py(o::Braket.Observables.TensorProduct) = o.coefficient * braketobs.TensorProduct(pylist(map(Py, o.factors))) -Py(o::Braket.Observables.Sum) = braketobs.Sum(pylist(map(Py, o.summands))) -Py(o::AdjointGradient) = circuit.result_types.AdjointGradient(Py(o.observable), pylist(o.target), pylist(o.parameters)) -Py(o::Expectation) = circuit.result_types.Expectation(Py(o.observable), pylist(o.targets)) -Py(o::Variance) = circuit.result_types.Variance(Py(o.observable), pylist(o.targets)) -Py(o::Sample) = circuit.result_types.Sample(Py(o.observable), pylist(o.targets)) -Py(o::Probability) = circuit.result_types.Probability(pylist(o.targets)) -Py(o::DensityMatrix) = circuit.result_types.DensityMatrix(pylist(o.targets)) -Py(o::Amplitude) = circuit.result_types.Amplitude(pylist(map(s->Py(s), o.states))) -Py(o::StateVector) = circuit.result_types.StateVector() - -for (typ, py_typ, label) in ((:(Braket.Observables.H), :H, "h"), (:(Braket.Observables.X), :X, "x"), (:(Braket.Observables.Y), :Y, "y"), (:(Braket.Observables.Z), :Z, "z"), (:(Braket.Observables.I), :I, "i")) - @eval begin - Py(o::$typ) = o.coefficient * braketobs.$py_typ() - end -end - -Py(p::Braket.FreeParameter) = circuit.FreeParameter(pystr(String(p.name))) diff --git a/PyBraket/src/pygates.jl b/PyBraket/src/pygates.jl deleted file mode 100644 index c220b2d3..00000000 --- a/PyBraket/src/pygates.jl +++ /dev/null @@ -1,84 +0,0 @@ -Py(x::IR.H) = pyjaqcd.H(; arg_gen(x, fieldnames(IR.H))...) -Py(x::H) = pygates.H(; arg_gen(x, fieldnames(H))...) -Py(x::IR.I) = pyjaqcd.I(; arg_gen(x, fieldnames(IR.I))...) -Py(x::I) = pygates.I(; arg_gen(x, fieldnames(I))...) -Py(x::IR.X) = pyjaqcd.X(; arg_gen(x, fieldnames(IR.X))...) -Py(x::X) = pygates.X(; arg_gen(x, fieldnames(X))...) -Py(x::IR.Y) = pyjaqcd.Y(; arg_gen(x, fieldnames(IR.Y))...) -Py(x::Y) = pygates.Y(; arg_gen(x, fieldnames(Y))...) -Py(x::IR.Z) = pyjaqcd.Z(; arg_gen(x, fieldnames(IR.Z))...) -Py(x::Z) = pygates.Z(; arg_gen(x, fieldnames(Z))...) -Py(x::IR.S) = pyjaqcd.S(; arg_gen(x, fieldnames(IR.S))...) -Py(x::S) = pygates.S(; arg_gen(x, fieldnames(S))...) -Py(x::IR.Si) = pyjaqcd.Si(; arg_gen(x, fieldnames(IR.Si))...) -Py(x::Si) = pygates.Si(; arg_gen(x, fieldnames(Si))...) -Py(x::IR.T) = pyjaqcd.T(; arg_gen(x, fieldnames(IR.T))...) -Py(x::T) = pygates.T(; arg_gen(x, fieldnames(T))...) -Py(x::IR.Ti) = pyjaqcd.Ti(; arg_gen(x, fieldnames(IR.Ti))...) -Py(x::Ti) = pygates.Ti(; arg_gen(x, fieldnames(Ti))...) -Py(x::IR.V) = pyjaqcd.V(; arg_gen(x, fieldnames(IR.V))...) -Py(x::V) = pygates.V(; arg_gen(x, fieldnames(V))...) -Py(x::IR.Vi) = pyjaqcd.Vi(; arg_gen(x, fieldnames(IR.Vi))...) -Py(x::Vi) = pygates.Vi(; arg_gen(x, fieldnames(Vi))...) -Py(x::IR.CNot) = pyjaqcd.CNot(; arg_gen(x, fieldnames(IR.CNot))...) -Py(x::CNot) = pygates.CNot(; arg_gen(x, fieldnames(CNot))...) -Py(x::IR.Swap) = pyjaqcd.Swap(; arg_gen(x, fieldnames(IR.Swap))...) -Py(x::Swap) = pygates.Swap(; arg_gen(x, fieldnames(Swap))...) -Py(x::IR.ISwap) = pyjaqcd.ISwap(; arg_gen(x, fieldnames(IR.ISwap))...) -Py(x::ISwap) = pygates.ISwap(; arg_gen(x, fieldnames(ISwap))...) -Py(x::IR.CV) = pyjaqcd.CV(; arg_gen(x, fieldnames(IR.CV))...) -Py(x::CV) = pygates.CV(; arg_gen(x, fieldnames(CV))...) -Py(x::IR.CY) = pyjaqcd.CY(; arg_gen(x, fieldnames(IR.CY))...) -Py(x::CY) = pygates.CY(; arg_gen(x, fieldnames(CY))...) -Py(x::IR.CZ) = pyjaqcd.CZ(; arg_gen(x, fieldnames(IR.CZ))...) -Py(x::CZ) = pygates.CZ(; arg_gen(x, fieldnames(CZ))...) -Py(x::IR.ECR) = pyjaqcd.ECR(; arg_gen(x, fieldnames(IR.ECR))...) -Py(x::ECR) = pygates.ECR(; arg_gen(x, fieldnames(ECR))...) -Py(x::IR.CCNot) = pyjaqcd.CCNot(; arg_gen(x, fieldnames(IR.CCNot))...) -Py(x::CCNot) = pygates.CCNot(; arg_gen(x, fieldnames(CCNot))...) -Py(x::IR.CSwap) = pyjaqcd.CSwap(; arg_gen(x, fieldnames(IR.CSwap))...) -Py(x::CSwap) = pygates.CSwap(; arg_gen(x, fieldnames(CSwap))...) -Py(x::IR.Unitary) = pyjaqcd.Unitary(; arg_gen(x, fieldnames(IR.Unitary))...) -Py(x::Unitary) = pygates.Unitary(; arg_gen(x, fieldnames(Unitary))...) -Py(x::IR.Rx) = pyjaqcd.Rx(; arg_gen(x, fieldnames(IR.Rx))...) -Py(x::Rx) = pygates.Rx(; arg_gen(x, fieldnames(Rx))...) -Py(x::IR.Ry) = pyjaqcd.Ry(; arg_gen(x, fieldnames(IR.Ry))...) -Py(x::Ry) = pygates.Ry(; arg_gen(x, fieldnames(Ry))...) -Py(x::IR.Rz) = pyjaqcd.Rz(; arg_gen(x, fieldnames(IR.Rz))...) -Py(x::Rz) = pygates.Rz(; arg_gen(x, fieldnames(Rz))...) -Py(x::IR.PhaseShift) = pyjaqcd.PhaseShift(; arg_gen(x, fieldnames(IR.PhaseShift))...) -Py(x::PhaseShift) = pygates.PhaseShift(; arg_gen(x, fieldnames(PhaseShift))...) -Py(x::IR.PSwap) = pyjaqcd.PSwap(; arg_gen(x, fieldnames(IR.PSwap))...) -Py(x::PSwap) = pygates.PSwap(; arg_gen(x, fieldnames(PSwap))...) -Py(x::IR.XY) = pyjaqcd.XY(; arg_gen(x, fieldnames(IR.XY))...) -Py(x::XY) = pygates.XY(; arg_gen(x, fieldnames(XY))...) -Py(x::IR.CPhaseShift) = pyjaqcd.CPhaseShift(; arg_gen(x, fieldnames(IR.CPhaseShift))...) -Py(x::CPhaseShift) = pygates.CPhaseShift(; arg_gen(x, fieldnames(CPhaseShift))...) -Py(x::IR.CPhaseShift00) = pyjaqcd.CPhaseShift00(; arg_gen(x, fieldnames(IR.CPhaseShift00))...) -Py(x::CPhaseShift00) = pygates.CPhaseShift00(; arg_gen(x, fieldnames(CPhaseShift00))...) -Py(x::IR.CPhaseShift01) = pyjaqcd.CPhaseShift01(; arg_gen(x, fieldnames(IR.CPhaseShift01))...) -Py(x::CPhaseShift01) = pygates.CPhaseShift01(; arg_gen(x, fieldnames(CPhaseShift01))...) -Py(x::IR.CPhaseShift10) = pyjaqcd.CPhaseShift10(; arg_gen(x, fieldnames(IR.CPhaseShift10))...) -Py(x::CPhaseShift10) = pygates.CPhaseShift10(; arg_gen(x, fieldnames(CPhaseShift10))...) -Py(x::IR.XX) = pyjaqcd.XX(; arg_gen(x, fieldnames(IR.XX))...) -Py(x::XX) = pygates.XX(; arg_gen(x, fieldnames(XX))...) -Py(x::IR.YY) = pyjaqcd.YY(; arg_gen(x, fieldnames(IR.YY))...) -Py(x::YY) = pygates.YY(; arg_gen(x, fieldnames(YY))...) -Py(x::IR.ZZ) = pyjaqcd.ZZ(; arg_gen(x, fieldnames(IR.ZZ))...) -Py(x::ZZ) = pygates.ZZ(; arg_gen(x, fieldnames(ZZ))...) -Py(x::IR.GPi) = pyjaqcd.GPi(; arg_gen(x, fieldnames(IR.GPi))...) -Py(x::GPi) = pygates.GPi(; arg_gen(x, fieldnames(GPi))...) -Py(x::IR.GPi2) = pyjaqcd.GPi2(; arg_gen(x, fieldnames(IR.GPi2))...) -Py(x::GPi2) = pygates.GPi2(; arg_gen(x, fieldnames(GPi2))...) -function Py(x::IR.MS) - fns = fieldnames(IR.MS) - args = Dict(arg_gen(x, fns)...) - mapped_args = Dict(zip([:angle_1, :angle_2, :angle_3], args[:angle])) - return pyjaqcd.MS(; mapped_args...) -end -function Py(x::MS) - fns = fieldnames(MS) - args = Dict(arg_gen(x, fns)...) - mapped_args = Dict(zip([:angle_1, :angle_2, :angle_3], args[:angle])) - return pygates.MS(; mapped_args...) -end diff --git a/PyBraket/src/pynoises.jl b/PyBraket/src/pynoises.jl deleted file mode 100644 index 4ac707a5..00000000 --- a/PyBraket/src/pynoises.jl +++ /dev/null @@ -1,110 +0,0 @@ -function Py(x::IR.BitFlip) - fns = fieldnames(IR.BitFlip) - args = (fn=>getproperty(x, fn) for fn in fns) - return pyjaqcd.BitFlip(; args...) -end -function Py(x::BitFlip) - fns = fieldnames(BitFlip) - args = (fn=>getproperty(x, fn) for fn in fns) - return pynoises.BitFlip(; args...) -end -function Py(x::IR.PhaseDamping) - fns = fieldnames(IR.PhaseDamping) - args = (fn=>getproperty(x, fn) for fn in fns) - return pyjaqcd.PhaseDamping(; args...) -end -function Py(x::PhaseDamping) - fns = fieldnames(PhaseDamping) - args = (fn=>getproperty(x, fn) for fn in fns) - return pynoises.PhaseDamping(; args...) -end -function Py(x::IR.TwoQubitDepolarizing) - fns = fieldnames(IR.TwoQubitDepolarizing) - args = arg_gen(x, fns) - return pyjaqcd.TwoQubitDepolarizing(; args...) -end -function Py(x::TwoQubitDepolarizing) - fns = fieldnames(TwoQubitDepolarizing) - args = (fn=>Py(getproperty(x, fn)) for fn in fns) - return pynoises.TwoQubitDepolarizing(; args...) -end -function Py(x::IR.PauliChannel) - fns = fieldnames(IR.PauliChannel) - args = (fn=>getproperty(x, fn) for fn in fns) - return pyjaqcd.PauliChannel(; args...) -end -function Py(x::PauliChannel) - fns = fieldnames(PauliChannel) - args = (fn=>getproperty(x, fn) for fn in fns) - return pynoises.PauliChannel(; args...) -end -function Py(x::IR.Kraus) - fns = fieldnames(IR.Kraus) - args = arg_gen(x, fns) - return pyjaqcd.Kraus(; args...) -end -function Py(x::Kraus) - fns = fieldnames(Kraus) - args = (fn=>Py(getproperty(x, fn)) for fn in fns) - return pynoises.Kraus(; args...) -end -function Py(x::IR.MultiQubitPauliChannel) - fns = fieldnames(IR.MultiQubitPauliChannel) - args = arg_gen(x, fns) - return pyjaqcd.MultiQubitPauliChannel(; args...) -end -function Py(x::TwoQubitPauliChannel) - fns = fieldnames(TwoQubitPauliChannel) - args = arg_gen(x, fns) - return pynoises.TwoQubitPauliChannel(; args...) -end -function Py(x::IR.Depolarizing) - fns = fieldnames(IR.Depolarizing) - args = (fn=>getproperty(x, fn) for fn in fns) - return pyjaqcd.Depolarizing(; args...) -end -function Py(x::Depolarizing) - fns = fieldnames(Depolarizing) - args = (fn=>getproperty(x, fn) for fn in fns) - return pynoises.Depolarizing(; args...) -end -function Py(x::IR.AmplitudeDamping) - fns = fieldnames(IR.AmplitudeDamping) - args = (fn=>getproperty(x, fn) for fn in fns) - return pyjaqcd.AmplitudeDamping(; args...) -end -function Py(x::AmplitudeDamping) - fns = fieldnames(AmplitudeDamping) - args = (fn=>Py(getproperty(x, fn)) for fn in fns) - return pynoises.AmplitudeDamping(; args...) -end -function Py(x::IR.TwoQubitDephasing) - fns = fieldnames(IR.TwoQubitDephasing) - args = arg_gen(x, fns) - return pyjaqcd.TwoQubitDephasing(; args...) -end -function Py(x::TwoQubitDephasing) - fns = fieldnames(TwoQubitDephasing) - args = (fn=>Py(getproperty(x, fn)) for fn in fns) - return pynoises.TwoQubitDephasing(; args...) -end -function Py(x::IR.GeneralizedAmplitudeDamping) - fns = fieldnames(IR.GeneralizedAmplitudeDamping) - args = (fn=>getproperty(x, fn) for fn in fns) - return pyjaqcd.GeneralizedAmplitudeDamping(; args...) -end -function Py(x::GeneralizedAmplitudeDamping) - fns = fieldnames(GeneralizedAmplitudeDamping) - args = (fn=>getproperty(x, fn) for fn in fns) - return pynoises.GeneralizedAmplitudeDamping(; args...) -end -function Py(x::IR.PhaseFlip) - fns = fieldnames(IR.PhaseFlip) - args = (fn=>getproperty(x, fn) for fn in fns) - return pyjaqcd.PhaseFlip(; args...) -end -function Py(x::PhaseFlip) - fns = fieldnames(PhaseFlip) - args = (fn=>getproperty(x, fn) for fn in fns) - return pynoises.PhaseFlip(; args...) -end diff --git a/PyBraket/src/pyschema.jl b/PyBraket/src/pyschema.jl index d762423c..f9df845d 100644 --- a/PyBraket/src/pyschema.jl +++ b/PyBraket/src/pyschema.jl @@ -1,333 +1,68 @@ module PySchema include("py_type_conversion.jl") -import Braket: DwaveTiming, GateModelQpuParadigmProperties, ResultTypeValue, AdditionalMetadata, GateFidelity2Q, OneQubitProperties, OqcDeviceCapabilities, DwaveAdvantageDeviceLevelParameters, IonqDeviceCapabilities, TwoQubitProperties, IonqDeviceParameters, NativeQuilMetadata, QueraDeviceCapabilities, ExecutionDay, StandardizedGateModelQpuDeviceProperties, XanaduDeviceCapabilities, DeviceExecutionWindow, DwaveDeviceParameters, CoherenceTime, Frame, DwaveMetadata, DeviceCost, Dwave2000QDeviceLevelParameters, FidelityType, QueraMetadata, OqcProviderProperties, DeviceServiceProperties, XanaduDeviceParameters, BlackbirdProgram, Geometry, Fidelity1Q, DwaveProviderProperties, AnalogHamiltonianSimulationShotResult, RigettiDeviceCapabilities, AnnealingTaskResult, DeviceActionProperties, DwaveProviderLevelParameters, Direction, PulseDeviceActionProperties, JaqcdDeviceActionProperties, PerformanceRydberg, DeviceActionType, BlackbirdDeviceActionProperties, PerformanceLattice, IonqProviderProperties, BraketSchemaBase, PersistedJobDataFormat, PhotonicModelTaskResult, DeviceDocumentation, ContinuousVariableQpuParadigmProperties, XanaduProviderProperties, QubitDirection, PulseFunctionArgument, DwaveAdvantageDeviceParameters, RigettiDeviceParameters, TaskMetadata, AnalogHamiltonianSimulationTaskResult, GateModelSimulatorParadigmProperties, GateModelTaskResult, RigettiProviderProperties, OqcDeviceParameters, DeviceConnectivity, PulseFunction, Rydberg, PerformanceRydbergGlobal, RydbergGlobal, GateModelSimulatorDeviceCapabilities, XanaduMetadata, GateModelParameters, Performance, GateModelSimulatorDeviceParameters, AnalogHamiltonianSimulationShotMeasurement, DwaveDeviceCapabilities, QueraAhsParadigmProperties, Lattice, PersistedJobData, OqcMetadata, ProblemType, RigettiMetadata, SimulatorMetadata, Area, Problem, ResultType, PostProcessingType, ResultFormat, Dwave2000QDeviceParameters, AnalogHamiltonianSimulationShotMetadata, braketSchemaHeader, OpenQasmProgram, Port, OpenQASMDeviceActionProperties, AbstractProgram -import Braket.IR: Z, Sample, CPhaseShift01, PhaseDamping, Rz, GeneralizedAmplitudeDamping, XX, ZZ, PhaseFlip, Vi, Depolarizing, Variance, TwoQubitDepolarizing, Setup, DensityMatrix, CPhaseShift00, ECR, Hamiltonian, CompilerDirective, CCNot, Unitary, BitFlip, ShiftingField, Y, Swap, AtomArrangement, CZ, EndVerbatimBox, TimeSeries, Program, CNot, PhysicalField, AdjointGradient, CSwap, Ry, I, Si, AmplitudeDamping, StateVector, ISwap, H, XY, YY, T, AHSProgram, TwoQubitDephasing, X, Ti, CV, StartVerbatimBox, PauliChannel, PSwap, Expectation, Probability, PhaseShift, V, DrivingField, CPhaseShift, S, Rx, Kraus, Amplitude, CPhaseShift10, MultiQubitPauliChannel, CY, AbstractProgramResult, MS, GPi, GPi2, IRObservable +import Braket: OneQubitProperties, TwoQubitProperties, CoherenceTime, FidelityType, Geometry, AnalogHamiltonianSimulationShotResult, DeviceActionProperties, Direction, DeviceActionType, BraketSchemaBase, PersistedJobDataFormat, DeviceDocumentation, TaskMetadata, AnalogHamiltonianSimulationTaskResult, DeviceConnectivity, Rydberg, RydbergGlobal, AnalogHamiltonianSimulationShotMeasurement, QueraAhsParadigmProperties, Lattice, PersistedJobData, Area, ResultType, ResultFormat, AnalogHamiltonianSimulationShotMetadata, braketSchemaHeader, AbstractProgram +import Braket.IR: Setup, PhysicalField -const instructions = PythonCall.pynew() -const dwave_metadata_v1 = PythonCall.pynew() -const gate_model_qpu_paradigm_properties_v1 = PythonCall.pynew() -const gate_model_task_result_v1 = PythonCall.pynew() -const results = PythonCall.pynew() -const additional_metadata = PythonCall.pynew() -const standardized_gate_model_qpu_device_properties_v1 = PythonCall.pynew() -const oqc_device_capabilities_v1 = PythonCall.pynew() -const dwave_advantage_device_level_parameters_v1 = PythonCall.pynew() -const ionq_device_capabilities_v1 = PythonCall.pynew() -const ionq_device_parameters_v1 = PythonCall.pynew() -const rigetti_metadata_v1 = PythonCall.pynew() -const quera_device_capabilities_v1 = PythonCall.pynew() +const analog_hamiltonian_simulation_task_result_v1 = PythonCall.pynew() const device_execution_window = PythonCall.pynew() -const xanadu_device_capabilities_v1 = PythonCall.pynew() const shifting_field = PythonCall.pynew() -const dwave_device_parameters_v1 = PythonCall.pynew() -const frame_v1 = PythonCall.pynew() -const device_service_properties_v1 = PythonCall.pynew() -const dwave_2000Q_device_level_parameters_v1 = PythonCall.pynew() -const quera_metadata_v1 = PythonCall.pynew() -const oqc_provider_properties_v1 = PythonCall.pynew() -const xanadu_device_parameters_v1 = PythonCall.pynew() -const program_v1 = PythonCall.pynew() -const quera_ahs_paradigm_properties_v1 = PythonCall.pynew() -const dwave_provider_properties_v1 = PythonCall.pynew() const atom_arrangement = PythonCall.pynew() const analog_hamiltonian_simulation_task_result_v1 = PythonCall.pynew() -const rigetti_device_capabilities_v1 = PythonCall.pynew() -const annealing_task_result_v1 = PythonCall.pynew() const driving_field = PythonCall.pynew() const device_action_properties = PythonCall.pynew() -const dwave_provider_level_parameters_v1 = PythonCall.pynew() -const port_v1 = PythonCall.pynew() -const pulse_device_action_properties_v1 = PythonCall.pynew() -const jaqcd_device_action_properties = PythonCall.pynew() -const blackbird_device_action_properties = PythonCall.pynew() -const ionq_provider_properties_v1 = PythonCall.pynew() const schema_base = PythonCall.pynew() const persisted_job_data_v1 = PythonCall.pynew() -const photonic_model_task_result_v1 = PythonCall.pynew() const time_series = PythonCall.pynew() -const continuous_variable_qpu_paradigm_properties_v1 = PythonCall.pynew() -const xanadu_provider_properties_v1 = PythonCall.pynew() -const pulse_function_v1 = PythonCall.pynew() -const dwave_advantage_device_parameters_v1 = PythonCall.pynew() -const rigetti_device_parameters_v1 = PythonCall.pynew() const task_metadata_v1 = PythonCall.pynew() -const gate_model_simulator_paradigm_properties_v1 = PythonCall.pynew() -const rigetti_provider_properties_v1 = PythonCall.pynew() -const oqc_device_parameters_v1 = PythonCall.pynew() -const device_connectivity = PythonCall.pynew() const physical_field = PythonCall.pynew() -const gate_model_simulator_device_capabilities_v1 = PythonCall.pynew() -const xanadu_metadata_v1 = PythonCall.pynew() -const gate_model_parameters_v1 = PythonCall.pynew() -const gate_model_simulator_device_parameters_v1 = PythonCall.pynew() -const dwave_device_capabilities_v1 = PythonCall.pynew() -const oqc_metadata_v1 = PythonCall.pynew() -const problem_v1 = PythonCall.pynew() -const simulator_metadata_v1 = PythonCall.pynew() const result_type = PythonCall.pynew() -const dwave_2000Q_device_parameters_v1 = PythonCall.pynew() const hamiltonian = PythonCall.pynew() const shared_models = PythonCall.pynew() const schema_header = PythonCall.pynew() -const openqasm_device_action_properties = PythonCall.pynew() - -function jl_convert(::Type{AbstractProgramResult}, x::Py) - T = Dict("variance"=>Variance, "expectation"=>Expectation, "densitymatrix"=>DensityMatrix, "probability"=>Probability, "sample"=>Sample, "amplitude"=>Amplitude, "statevector"=>StateVector, "adjoint_gradient"=>AdjointGradient) - return PythonCall.pyconvert_return(pyconvert(T[pyconvert(String, x.type)], x)) -end +const program_v1 = PythonCall.pynew() function jl_convert(::Type{AbstractProgram}, x::Py) T = Braket.lookup_type(pyconvert(braketSchemaHeader, pygetattr(x, "braketSchemaHeader"))) return PythonCall.pyconvert_return(pyconvert(T, x)) end - function __init__() - PythonCall.pycopy!(instructions, pyimport("braket.ir.jaqcd.instructions")) - PythonCall.pycopy!(dwave_metadata_v1, pyimport("braket.task_result.dwave_metadata_v1")) - PythonCall.pycopy!(gate_model_qpu_paradigm_properties_v1, pyimport("braket.device_schema.gate_model_qpu_paradigm_properties_v1")) - PythonCall.pycopy!(gate_model_task_result_v1, pyimport("braket.task_result.gate_model_task_result_v1")) - PythonCall.pycopy!(results, pyimport("braket.ir.jaqcd.results")) - PythonCall.pycopy!(additional_metadata, pyimport("braket.task_result.additional_metadata")) - PythonCall.pycopy!(standardized_gate_model_qpu_device_properties_v1, pyimport("braket.device_schema.standardized_gate_model_qpu_device_properties_v1")) - PythonCall.pycopy!(oqc_device_capabilities_v1, pyimport("braket.device_schema.oqc.oqc_device_capabilities_v1")) - PythonCall.pycopy!(dwave_advantage_device_level_parameters_v1, pyimport("braket.device_schema.dwave.dwave_advantage_device_level_parameters_v1")) - PythonCall.pycopy!(ionq_device_capabilities_v1, pyimport("braket.device_schema.ionq.ionq_device_capabilities_v1")) - PythonCall.pycopy!(ionq_device_parameters_v1, pyimport("braket.device_schema.ionq.ionq_device_parameters_v1")) - PythonCall.pycopy!(rigetti_metadata_v1, pyimport("braket.task_result.rigetti_metadata_v1")) - PythonCall.pycopy!(quera_device_capabilities_v1, pyimport("braket.device_schema.quera.quera_device_capabilities_v1")) - PythonCall.pycopy!(device_execution_window, pyimport("braket.device_schema.device_execution_window")) - PythonCall.pycopy!(xanadu_device_capabilities_v1, pyimport("braket.device_schema.xanadu.xanadu_device_capabilities_v1")) PythonCall.pycopy!(shifting_field, pyimport("braket.ir.ahs.shifting_field")) - PythonCall.pycopy!(dwave_device_parameters_v1, pyimport("braket.device_schema.dwave.dwave_device_parameters_v1")) - PythonCall.pycopy!(frame_v1, pyimport("braket.device_schema.pulse.frame_v1")) - PythonCall.pycopy!(device_service_properties_v1, pyimport("braket.device_schema.device_service_properties_v1")) - PythonCall.pycopy!(dwave_2000Q_device_level_parameters_v1, pyimport("braket.device_schema.dwave.dwave_2000Q_device_level_parameters_v1")) - PythonCall.pycopy!(quera_metadata_v1, pyimport("braket.task_result.quera_metadata_v1")) - PythonCall.pycopy!(oqc_provider_properties_v1, pyimport("braket.device_schema.oqc.oqc_provider_properties_v1")) - PythonCall.pycopy!(xanadu_device_parameters_v1, pyimport("braket.device_schema.xanadu.xanadu_device_parameters_v1")) - PythonCall.pycopy!(program_v1, pyimport("braket.ir.blackbird.program_v1")) - PythonCall.pycopy!(quera_ahs_paradigm_properties_v1, pyimport("braket.device_schema.quera.quera_ahs_paradigm_properties_v1")) - PythonCall.pycopy!(dwave_provider_properties_v1, pyimport("braket.device_schema.dwave.dwave_provider_properties_v1")) PythonCall.pycopy!(atom_arrangement, pyimport("braket.ir.ahs.atom_arrangement")) PythonCall.pycopy!(analog_hamiltonian_simulation_task_result_v1, pyimport("braket.task_result.analog_hamiltonian_simulation_task_result_v1")) - PythonCall.pycopy!(rigetti_device_capabilities_v1, pyimport("braket.device_schema.rigetti.rigetti_device_capabilities_v1")) - PythonCall.pycopy!(annealing_task_result_v1, pyimport("braket.task_result.annealing_task_result_v1")) PythonCall.pycopy!(driving_field, pyimport("braket.ir.ahs.driving_field")) PythonCall.pycopy!(device_action_properties, pyimport("braket.device_schema.device_action_properties")) - PythonCall.pycopy!(dwave_provider_level_parameters_v1, pyimport("braket.device_schema.dwave.dwave_provider_level_parameters_v1")) - PythonCall.pycopy!(port_v1, pyimport("braket.device_schema.pulse.port_v1")) - PythonCall.pycopy!(pulse_device_action_properties_v1, pyimport("braket.device_schema.pulse.pulse_device_action_properties_v1")) - PythonCall.pycopy!(jaqcd_device_action_properties, pyimport("braket.device_schema.jaqcd_device_action_properties")) - PythonCall.pycopy!(blackbird_device_action_properties, pyimport("braket.device_schema.blackbird_device_action_properties")) - PythonCall.pycopy!(ionq_provider_properties_v1, pyimport("braket.device_schema.ionq.ionq_provider_properties_v1")) PythonCall.pycopy!(schema_base, pyimport("braket.schema_common.schema_base")) PythonCall.pycopy!(persisted_job_data_v1, pyimport("braket.jobs_data.persisted_job_data_v1")) - PythonCall.pycopy!(photonic_model_task_result_v1, pyimport("braket.task_result.photonic_model_task_result_v1")) PythonCall.pycopy!(time_series, pyimport("braket.ir.ahs.time_series")) - PythonCall.pycopy!(continuous_variable_qpu_paradigm_properties_v1, pyimport("braket.device_schema.continuous_variable_qpu_paradigm_properties_v1")) - PythonCall.pycopy!(xanadu_provider_properties_v1, pyimport("braket.device_schema.xanadu.xanadu_provider_properties_v1")) - PythonCall.pycopy!(pulse_function_v1, pyimport("braket.device_schema.pulse.pulse_function_v1")) - PythonCall.pycopy!(dwave_advantage_device_parameters_v1, pyimport("braket.device_schema.dwave.dwave_advantage_device_parameters_v1")) - PythonCall.pycopy!(rigetti_device_parameters_v1, pyimport("braket.device_schema.rigetti.rigetti_device_parameters_v1")) PythonCall.pycopy!(program_v1, pyimport("braket.ir.ahs.program_v1")) - PythonCall.pycopy!(program_v1, pyimport("braket.ir.jaqcd.program_v1")) PythonCall.pycopy!(task_metadata_v1, pyimport("braket.task_result.task_metadata_v1")) - PythonCall.pycopy!(gate_model_simulator_paradigm_properties_v1, pyimport("braket.device_schema.simulators.gate_model_simulator_paradigm_properties_v1")) - PythonCall.pycopy!(rigetti_provider_properties_v1, pyimport("braket.device_schema.rigetti.rigetti_provider_properties_v1")) - PythonCall.pycopy!(oqc_device_parameters_v1, pyimport("braket.device_schema.oqc.oqc_device_parameters_v1")) - PythonCall.pycopy!(device_connectivity, pyimport("braket.device_schema.device_connectivity")) PythonCall.pycopy!(physical_field, pyimport("braket.ir.ahs.physical_field")) - PythonCall.pycopy!(gate_model_simulator_device_capabilities_v1, pyimport("braket.device_schema.simulators.gate_model_simulator_device_capabilities_v1")) - PythonCall.pycopy!(xanadu_metadata_v1, pyimport("braket.task_result.xanadu_metadata_v1")) - PythonCall.pycopy!(gate_model_parameters_v1, pyimport("braket.device_schema.gate_model_parameters_v1")) - PythonCall.pycopy!(gate_model_simulator_device_parameters_v1, pyimport("braket.device_schema.simulators.gate_model_simulator_device_parameters_v1")) - PythonCall.pycopy!(dwave_device_capabilities_v1, pyimport("braket.device_schema.dwave.dwave_device_capabilities_v1")) - PythonCall.pycopy!(oqc_metadata_v1, pyimport("braket.task_result.oqc_metadata_v1")) - PythonCall.pycopy!(problem_v1, pyimport("braket.ir.annealing.problem_v1")) - PythonCall.pycopy!(simulator_metadata_v1, pyimport("braket.task_result.simulator_metadata_v1")) - PythonCall.pycopy!(result_type, pyimport("braket.device_schema.result_type")) - PythonCall.pycopy!(dwave_2000Q_device_parameters_v1, pyimport("braket.device_schema.dwave.dwave_2000Q_device_parameters_v1")) PythonCall.pycopy!(hamiltonian, pyimport("braket.ir.ahs.hamiltonian")) PythonCall.pycopy!(shared_models, pyimport("braket.ir.jaqcd.shared_models")) PythonCall.pycopy!(schema_header, pyimport("braket.schema_common.schema_header")) - PythonCall.pycopy!(program_v1, pyimport("braket.ir.openqasm.program_v1")) - PythonCall.pycopy!(openqasm_device_action_properties, pyimport("braket.device_schema.openqasm_device_action_properties")) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:Z", Z, jl_convert) - PythonCall.pyconvert_add_rule("braket.task_result.dwave_metadata_v1:DwaveTiming", DwaveTiming, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:Si", Si, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.gate_model_qpu_paradigm_properties_v1:GateModelQpuParadigmProperties", GateModelQpuParadigmProperties, jl_convert) - PythonCall.pyconvert_add_rule("braket.task_result.gate_model_task_result_v1:ResultTypeValue", ResultTypeValue, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.results:Sample", Sample, jl_convert) - PythonCall.pyconvert_add_rule("braket.task_result.additional_metadata:AdditionalMetadata", AdditionalMetadata, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.standardized_gate_model_qpu_device_properties_v1:GateFidelity2Q", GateFidelity2Q, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.standardized_gate_model_qpu_device_properties_v1:OneQubitProperties", OneQubitProperties, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.oqc.oqc_device_capabilities_v1:OqcDeviceCapabilities", OqcDeviceCapabilities, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.dwave.dwave_advantage_device_level_parameters_v1:DwaveAdvantageDeviceLevelParameters", DwaveAdvantageDeviceLevelParameters, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.ionq.ionq_device_capabilities_v1:IonqDeviceCapabilities", IonqDeviceCapabilities, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:CPhaseShift01", CPhaseShift01, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:PSwap", PSwap, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.standardized_gate_model_qpu_device_properties_v1:TwoQubitProperties", TwoQubitProperties, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.ionq.ionq_device_parameters_v1:IonqDeviceParameters", IonqDeviceParameters, jl_convert) - PythonCall.pyconvert_add_rule("braket.task_result.rigetti_metadata_v1:NativeQuilMetadata", NativeQuilMetadata, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:AmplitudeDamping", AmplitudeDamping, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.quera.quera_device_capabilities_v1:QueraDeviceCapabilities", QueraDeviceCapabilities, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.device_execution_window:ExecutionDay", ExecutionDay, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.standardized_gate_model_qpu_device_properties_v1:StandardizedGateModelQpuDeviceProperties", StandardizedGateModelQpuDeviceProperties, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.results:Expectation", Expectation, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:BitFlip", BitFlip, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.xanadu.xanadu_device_capabilities_v1:XanaduDeviceCapabilities", XanaduDeviceCapabilities, jl_convert) PythonCall.pyconvert_add_rule("braket.ir.ahs.shifting_field:ShiftingField", ShiftingField, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:PhaseDamping", PhaseDamping, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.device_execution_window:DeviceExecutionWindow", DeviceExecutionWindow, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:Rz", Rz, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:Y", Y, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.dwave.dwave_device_parameters_v1:DwaveDeviceParameters", DwaveDeviceParameters, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.standardized_gate_model_qpu_device_properties_v1:CoherenceTime", CoherenceTime, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.pulse.frame_v1:Frame", Frame, jl_convert) - PythonCall.pyconvert_add_rule("braket.task_result.dwave_metadata_v1:DwaveMetadata", DwaveMetadata, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.device_service_properties_v1:DeviceCost", DeviceCost, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.dwave.dwave_2000Q_device_level_parameters_v1:Dwave2000QDeviceLevelParameters", Dwave2000QDeviceLevelParameters, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.standardized_gate_model_qpu_device_properties_v1:FidelityType", FidelityType, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:GeneralizedAmplitudeDamping", GeneralizedAmplitudeDamping, jl_convert) - PythonCall.pyconvert_add_rule("braket.task_result.quera_metadata_v1:QueraMetadata", QueraMetadata, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.results:Probability", Probability, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.oqc.oqc_provider_properties_v1:OqcProviderProperties", OqcProviderProperties, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.device_service_properties_v1:DeviceServiceProperties", DeviceServiceProperties, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.xanadu.xanadu_device_parameters_v1:XanaduDeviceParameters", XanaduDeviceParameters, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.blackbird.program_v1:BlackbirdProgram", BlackbirdProgram, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:PhaseShift", PhaseShift, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:V", V, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.quera.quera_ahs_paradigm_properties_v1:Geometry", Geometry, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.results:StateVector", StateVector, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.standardized_gate_model_qpu_device_properties_v1:Fidelity1Q", Fidelity1Q, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:XX", XX, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:ZZ", ZZ, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.dwave.dwave_provider_properties_v1:DwaveProviderProperties", DwaveProviderProperties, jl_convert) PythonCall.pyconvert_add_rule("braket.ir.ahs.atom_arrangement:AtomArrangement", AtomArrangement, jl_convert) PythonCall.pyconvert_add_rule("braket.task_result.analog_hamiltonian_simulation_task_result_v1:AnalogHamiltonianSimulationShotResult", AnalogHamiltonianSimulationShotResult, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.rigetti.rigetti_device_capabilities_v1:RigettiDeviceCapabilities", RigettiDeviceCapabilities, jl_convert) - PythonCall.pyconvert_add_rule("braket.task_result.annealing_task_result_v1:AnnealingTaskResult", AnnealingTaskResult, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:Swap", Swap, jl_convert) PythonCall.pyconvert_add_rule("braket.ir.ahs.driving_field:DrivingField", DrivingField, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.device_action_properties:DeviceActionProperties", DeviceActionProperties, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.dwave.dwave_provider_level_parameters_v1:DwaveProviderLevelParameters", DwaveProviderLevelParameters, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:ISwap", ISwap, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.pulse.port_v1:Direction", Direction, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.pulse.pulse_device_action_properties_v1:PulseDeviceActionProperties", PulseDeviceActionProperties, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:H", H, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.jaqcd_device_action_properties:JaqcdDeviceActionProperties", JaqcdDeviceActionProperties, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:CPhaseShift", CPhaseShift, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:Vi", Vi, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.quera.quera_ahs_paradigm_properties_v1:PerformanceRydberg", PerformanceRydberg, jl_convert) PythonCall.pyconvert_add_rule("braket.device_schema.device_action_properties:DeviceActionType", DeviceActionType, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.blackbird_device_action_properties:BlackbirdDeviceActionProperties", BlackbirdDeviceActionProperties, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.quera.quera_ahs_paradigm_properties_v1:PerformanceLattice", PerformanceLattice, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:PhaseFlip", PhaseFlip, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:XY", XY, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.ionq.ionq_provider_properties_v1:IonqProviderProperties", IonqProviderProperties, jl_convert) PythonCall.pyconvert_add_rule("braket.schema_common.schema_base:BraketSchemaBase", BraketSchemaBase, jl_convert) PythonCall.pyconvert_add_rule("braket.jobs_data.persisted_job_data_v1:PersistedJobDataFormat", PersistedJobDataFormat, jl_convert) - PythonCall.pyconvert_add_rule("braket.task_result.photonic_model_task_result_v1:PhotonicModelTaskResult", PhotonicModelTaskResult, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:S", S, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:CZ", CZ, jl_convert) PythonCall.pyconvert_add_rule("braket.device_schema.device_service_properties_v1:DeviceDocumentation", DeviceDocumentation, jl_convert) PythonCall.pyconvert_add_rule("braket.ir.ahs.time_series:TimeSeries", TimeSeries, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:Depolarizing", Depolarizing, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.continuous_variable_qpu_paradigm_properties_v1:ContinuousVariableQpuParadigmProperties", ContinuousVariableQpuParadigmProperties, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:Rx", Rx, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.xanadu.xanadu_provider_properties_v1:XanaduProviderProperties", XanaduProviderProperties, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.standardized_gate_model_qpu_device_properties_v1:QubitDirection", QubitDirection, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:YY", YY, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:EndVerbatimBox", EndVerbatimBox, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.results:Variance", Variance, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.pulse.pulse_function_v1:PulseFunctionArgument", PulseFunctionArgument, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.dwave.dwave_advantage_device_parameters_v1:DwaveAdvantageDeviceParameters", DwaveAdvantageDeviceParameters, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:T", T, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.rigetti.rigetti_device_parameters_v1:RigettiDeviceParameters", RigettiDeviceParameters, jl_convert) PythonCall.pyconvert_add_rule("braket.ir.ahs.program_v1:AHSProgram", AHSProgram, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.program_v1:Program", Program, jl_convert) PythonCall.pyconvert_add_rule("braket.task_result.task_metadata_v1:TaskMetadata", TaskMetadata, jl_convert) PythonCall.pyconvert_add_rule("braket.task_result.analog_hamiltonian_simulation_task_result_v1:AnalogHamiltonianSimulationTaskResult", AnalogHamiltonianSimulationTaskResult, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:CNot", CNot, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:TwoQubitDepolarizing", TwoQubitDepolarizing, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.simulators.gate_model_simulator_paradigm_properties_v1:GateModelSimulatorParadigmProperties", GateModelSimulatorParadigmProperties, jl_convert) - PythonCall.pyconvert_add_rule("braket.task_result.gate_model_task_result_v1:GateModelTaskResult", GateModelTaskResult, jl_convert) PythonCall.pyconvert_add_rule("braket.ir.ahs.program_v1:Setup", Setup, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:Kraus", Kraus, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.rigetti.rigetti_provider_properties_v1:RigettiProviderProperties", RigettiProviderProperties, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.results:DensityMatrix", DensityMatrix, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.oqc.oqc_device_parameters_v1:OqcDeviceParameters", OqcDeviceParameters, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.device_connectivity:DeviceConnectivity", DeviceConnectivity, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.pulse.pulse_function_v1:PulseFunction", PulseFunction, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:TwoQubitDephasing", TwoQubitDephasing, jl_convert) PythonCall.pyconvert_add_rule("braket.ir.ahs.physical_field:PhysicalField", PhysicalField, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.quera.quera_ahs_paradigm_properties_v1:Rydberg", Rydberg, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.results:Amplitude", Amplitude, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:X", X, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.quera.quera_ahs_paradigm_properties_v1:PerformanceRydbergGlobal", PerformanceRydbergGlobal, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:CPhaseShift10", CPhaseShift10, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:CPhaseShift00", CPhaseShift00, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.quera.quera_ahs_paradigm_properties_v1:RydbergGlobal", RydbergGlobal, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:MultiQubitPauliChannel", MultiQubitPauliChannel, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.simulators.gate_model_simulator_device_capabilities_v1:GateModelSimulatorDeviceCapabilities", GateModelSimulatorDeviceCapabilities, jl_convert) - PythonCall.pyconvert_add_rule("braket.task_result.xanadu_metadata_v1:XanaduMetadata", XanaduMetadata, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.gate_model_parameters_v1:GateModelParameters", GateModelParameters, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:Ti", Ti, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:CV", CV, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:StartVerbatimBox", StartVerbatimBox, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.quera.quera_ahs_paradigm_properties_v1:Performance", Performance, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.simulators.gate_model_simulator_device_parameters_v1:GateModelSimulatorDeviceParameters", GateModelSimulatorDeviceParameters, jl_convert) PythonCall.pyconvert_add_rule("braket.task_result.analog_hamiltonian_simulation_task_result_v1:AnalogHamiltonianSimulationShotMeasurement", AnalogHamiltonianSimulationShotMeasurement, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.dwave.dwave_device_capabilities_v1:DwaveDeviceCapabilities", DwaveDeviceCapabilities, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.quera.quera_ahs_paradigm_properties_v1:QueraAhsParadigmProperties", QueraAhsParadigmProperties, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.quera.quera_ahs_paradigm_properties_v1:Lattice", Lattice, jl_convert) PythonCall.pyconvert_add_rule("braket.jobs_data.persisted_job_data_v1:PersistedJobData", PersistedJobData, jl_convert) - PythonCall.pyconvert_add_rule("braket.task_result.oqc_metadata_v1:OqcMetadata", OqcMetadata, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.annealing.problem_v1:ProblemType", ProblemType, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:ECR", ECR, jl_convert) - PythonCall.pyconvert_add_rule("braket.task_result.rigetti_metadata_v1:RigettiMetadata", RigettiMetadata, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.results:AdjointGradient", AdjointGradient, jl_convert) - PythonCall.pyconvert_add_rule("braket.task_result.simulator_metadata_v1:SimulatorMetadata", SimulatorMetadata, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.quera.quera_ahs_paradigm_properties_v1:Area", Area, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.annealing.problem_v1:Problem", Problem, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.result_type:ResultType", ResultType, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.dwave.dwave_provider_level_parameters_v1:PostProcessingType", PostProcessingType, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.dwave.dwave_provider_level_parameters_v1:ResultFormat", ResultFormat, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.dwave.dwave_2000Q_device_parameters_v1:Dwave2000QDeviceParameters", Dwave2000QDeviceParameters, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:CSwap", CSwap, jl_convert) PythonCall.pyconvert_add_rule("braket.ir.ahs.hamiltonian:Hamiltonian", Hamiltonian, jl_convert) PythonCall.pyconvert_add_rule("braket.task_result.analog_hamiltonian_simulation_task_result_v1:AnalogHamiltonianSimulationShotMetadata", AnalogHamiltonianSimulationShotMetadata, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.shared_models:CompilerDirective", CompilerDirective, jl_convert) PythonCall.pyconvert_add_rule("braket.schema_common.schema_header:BraketSchemaHeader", braketSchemaHeader, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.openqasm.program_v1:OpenQasmProgram", OpenQasmProgram, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:Ry", Ry, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:CY", CY, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:CCNot", CCNot, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:PauliChannel", PauliChannel, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.pulse.port_v1:Port", Port, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:I", I, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:Unitary", Unitary, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.openqasm_device_action_properties:OpenQASMDeviceActionProperties", OpenQASMDeviceActionProperties, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.results:Amplitude", AbstractProgramResult, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.results:Expectation", AbstractProgramResult, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.results:Probability", AbstractProgramResult, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.results:Sample", AbstractProgramResult, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.results:StateVector", AbstractProgramResult, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.results:DensityMatrix", AbstractProgramResult, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.results:Variance", AbstractProgramResult, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.results:AdjointGradient", AbstractProgramResult, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.program_v1:Program", AbstractProgram, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.blackbird.program_v1:BlackbirdProgram", AbstractProgram, jl_convert) PythonCall.pyconvert_add_rule("braket.ir.ahs.program_v1:AHSProgram", AbstractProgram, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.openqasm.program_v1:OpenQasmProgram", AbstractProgram, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.annealing.problem_v1:Problem", AbstractProgram, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.program_v1:Program", AbstractProgram, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.blackbird.program_v1:Program", AbstractProgram, jl_convert) PythonCall.pyconvert_add_rule("braket.ir.ahs.program_v1:Program", AbstractProgram, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.openqasm.program_v1:Program", AbstractProgram, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.annealing.problem_v1:Program", AbstractProgram, jl_convert) end end #module diff --git a/PyBraket/test/ahs.jl b/PyBraket/test/ahs.jl index da68e540..911338a2 100644 --- a/PyBraket/test/ahs.jl +++ b/PyBraket/test/ahs.jl @@ -43,8 +43,8 @@ using Braket: AtomArrangement, AtomArrangementItem, TimeSeries, DrivingField, Aw drive = DrivingField(Ω, ϕ, Δ) ahs_program = AnalogHamiltonianSimulation(register, drive) - ahs_local = PyBraket.LocalSimulator("braket_ahs") - local_result = result(run(ahs_local, ahs_program, shots=1_000)) + ahs_local = LocalSimulator(PyLocalSimulator("braket_ahs")) + local_result = result(simulate(ahs_local, ahs_program, shots=1_000)) @test length(local_result.measurements) == 1_000 @@ -82,8 +82,8 @@ end drive = DrivingField(Ω, ϕ, Δ) ahs_program = AnalogHamiltonianSimulation(register, drive) - ahs_local = PyBraket.LocalSimulator("braket_ahs") - local_result = result(run(ahs_local, ahs_program, shots=1_000)) + ahs_local = LocalSimulator(PyLocalSimulator("braket_ahs")) + local_result = result(simulate(ahs_local, ahs_program, shots=1_000)) g_count = 0 for meas in local_result.measurements diff --git a/PyBraket/test/circuits.jl b/PyBraket/test/circuits.jl deleted file mode 100644 index c2e8a2e2..00000000 --- a/PyBraket/test/circuits.jl +++ /dev/null @@ -1,184 +0,0 @@ -using Braket, PyBraket, Test, LinearAlgebra, PythonCall -using PythonCall: pyconvert, Py, pyisinstance -@testset "PyBraket circuits" begin - @testset for ir_type in (:JAQCD, :OpenQASM) - Braket.IRType[] = ir_type - @testset "Expectation" begin - c = Circuit([(H, 0), (CNot, 0, 1), (Expectation, Braket.Observables.Z(), 0)]) - dev = PyBraket.LocalSimulator() - braket_task = run(dev, c, shots=0) - res = result(braket_task) - @test res.values[1] ≈ 0.0 atol=1e-12 - end - - @testset "Variance" begin - c = Circuit() |> (ci->H(ci, 0)) |> (ci->CNot(ci, 0, 1)) |> (ci->Variance(ci, Braket.Observables.Z(), 0)) - dev = PyBraket.LocalSimulator() - braket_task = run(dev, c, shots=0) - res = result(braket_task) - @test res.values[1] ≈ 1.0 atol=1e-12 - end - - @testset "Probability" begin - c = Circuit() |> (ci->H(ci, 0)) |> (ci->CNot(ci, 0, 1)) |> (ci->Probability(ci)) - dev = PyBraket.LocalSimulator() - braket_task = run(dev, c, shots=0) - res = result(braket_task) - @test res.values[1] ≈ [0.5, 0.0, 0.0, 0.5] atol=1e-12 - end - - @testset "DensityMatrix" begin - c = Circuit() |> (ci->H(ci, 0)) |> (ci->CNot(ci, 0, 1)) |> (ci->DensityMatrix(ci)) - dev = PyBraket.LocalSimulator() - braket_task = run(dev, c, shots=0) - res = result(braket_task) - ρ = zeros(ComplexF64, 4, 4) - ρ[1, 1] = 0.5 - ρ[1, 4] = 0.5 - ρ[4, 1] = 0.5 - ρ[4, 4] = 0.5 - for i in 1:4, j in 1:4 - @test res.values[1][i][j] ≈ ρ[i,j] atol=1e-12 - end - end - - @testset "Results type" begin - c = Circuit() |> (ci->H(ci, 0)) |> (ci->CNot(ci, 0, 1)) |> (ci->Expectation(ci, Braket.Observables.Z(), 0)) - dev = PyBraket.LocalSimulator() - braket_task = run(dev, c, shots=0) - res = result(braket_task) - @test res.values[1] ≈ 0.0 atol=1e-12 - @test sprint(show, res) == "GateModelQuantumTaskResult\n" - end - - @testset "Observable on all qubits" begin - c = Circuit() |> (ci->H(ci, 0)) |> (ci->CNot(ci, 0, 1)) |> (ci->Expectation(ci, Braket.Observables.Z())) - dev = PyBraket.LocalSimulator() - res = result(run(dev, c, shots=0)) - @test pyconvert(Vector{Float64}, res.values[1]) ≈ [0.0, 0.0] atol=1e-12 - end - - @testset "Unitary" begin - c = Circuit() - ccz_mat = Matrix(Diagonal(ones(ComplexF64, 2^3))) - ccz_mat[end,end] = -one(ComplexF64) - H(c, [0, 1, 2]) - Unitary(c, [0, 1, 2], ccz_mat) - H(c, [0, 1, 2]) - StateVector(c) - dev = PyBraket.LocalSimulator() - braket_task = run(dev, c, shots=0) - res = result(braket_task) - @test res.values[1] ≈ ComplexF64[0.75, 0.25, 0.25, -0.25, 0.25, -0.25, -0.25, 0.25] atol=1e-12 - end - - @testset "PyCircuit" begin - c = Circuit() - ccz_mat = Matrix(Diagonal(ones(ComplexF64, 2^3))) - ccz_mat[end,end] = -one(ComplexF64) - H(c, [0, 1, 2]) - Unitary(c, [0, 1, 2], ccz_mat) - H(c, [0, 1, 2]) - StateVector(c) - pc = PyCircuit(c) - @test qubit_count(c) == PythonCall.pyconvert(Int, pc.qubit_count) - @test length(c.result_types) == PythonCall.pyconvert(Int, length(getproperty(pc, "_result_types"))) - end - if ir_type == :JAQCD - @testset "Conversion of result types" begin - @testset for (rt, ir_rt) in ((Braket.Expectation, Braket.IR.Expectation), - (Braket.Variance, Braket.IR.Variance), - (Braket.Sample, Braket.IR.Sample)) - o = Braket.Observables.H() - obs = rt(o, [0]) - py_obs = Py(obs) - ir_obs = ir(obs) - @test pyconvert(Bool, py_obs.to_ir() == Py(ir_obs)) - @test pyconvert(ir_rt, Py(ir_obs)) == ir_obs - end - @testset for (rt, ir_rt) in ((Braket.Probability, Braket.IR.Probability), - (Braket.DensityMatrix, Braket.IR.DensityMatrix)) - obs = rt([0]) - py_obs = Py(obs) - ir_obs = ir(obs) - @test pyconvert(Bool, py_obs.to_ir() == Py(ir_obs)) - @test pyconvert(ir_rt, Py(ir_obs)) == ir_obs - - obs = rt() - py_obs = Py(obs) - ir_obs = ir(obs) - @test pyconvert(Bool, py_obs.to_ir() == Py(ir_obs)) - @test pyconvert(ir_rt, Py(ir_obs)) == ir_obs - end - @testset "(rt, ir_rt) = (Amplitude, IR.Amplitude)" begin - obs = Braket.Amplitude(["0000"]) - py_obs = Py(obs) - ir_obs = ir(obs) - @test pyconvert(Bool, py_obs.to_ir() == Py(ir_obs)) - @test pyconvert(Braket.IR.Amplitude, Py(ir_obs)) == ir_obs - end - @testset "(rt, ir_rt) = (StateVector, IR.StateVector)" begin - obs = Braket.StateVector() - py_obs = Py(obs) - ir_obs = ir(obs) - @test pyconvert(Bool, py_obs.to_ir() == Py(ir_obs)) - @test pyconvert(Braket.IR.StateVector, Py(ir_obs)) == ir_obs - end - @testset "HermitianObservable and TensorProduct" begin - m = [1. -im; im -1.] - ho = Braket.Observables.HermitianObservable(kron(m, m)) - tp = Braket.Observables.TensorProduct([ho, ho]) - py_obs = Py(tp) - @test pyisinstance(py_obs, PyBraket.braketobs.TensorProduct) - @test pyisinstance(py_obs.factors[0], PyBraket.braketobs.Hermitian) - end - @testset "Coefficient handling" begin - o = 3.0 * Braket.Observables.Z() - py_obs = Py(o) - @test pyisinstance(py_obs, PyBraket.braketobs.Z) - @test pyconvert(Bool, py_obs.coefficient == 3.0) - end - @testset "Sum" begin - m = [1. -im; im -1.] - ho = Braket.Observables.HermitianObservable(kron(m, m)) - tp = Braket.Observables.TensorProduct([Braket.Observables.HermitianObservable(m), Braket.Observables.HermitianObservable(m)]) - py_obs = Py(2.0*tp + ho) - @test pyisinstance(py_obs, PyBraket.braketobs.Sum) - @test pyisinstance(py_obs.summands[0], PyBraket.braketobs.TensorProduct) - @test pyconvert(Float64, py_obs.summands[0].coefficient) == 2.0 - @test pyisinstance(py_obs.summands[1], PyBraket.braketobs.Hermitian) - end - end - end - @testset "FreeParameter" begin - α = FreeParameter(:alpha) - θ = FreeParameter(:theta) - circ = Circuit() - circ = H(circ, 0) - circ = Rx(circ, 1, α) - circ = Ry(circ, 0, θ) - circ = Probability(circ) - new_circ = circ(theta=2.0, alpha=1.0) - non_para_circ = Circuit() |> (ci->H(ci, 0)) |> (ci->Rx(ci, 1, 1.0)) |> (ci->Ry(ci, 0, 2.0)) |> Probability - py_c1 = PyCircuit(circ) - py_c2 = PyCircuit(non_para_circ) - @test py_c2 == py_c1(theta = 2.0, alpha=1.0) - - non_para_circ = Circuit() |> (ci->H(ci, 0)) |> (ci->Rx(ci, 1, 1.0)) |> (ci->Ry(ci, 0, 1.0)) |> Probability - py_c2 = PyCircuit(non_para_circ) - @test py_c2 == py_c1(1.0) - @testset "running with inputs" begin - dev = PyBraket.LocalSimulator() - oq3_circ = ir(circ, Val(:OpenQASM)) - braket_task = run(dev, oq3_circ, shots=0, inputs=Dict(string(α)=>1.0, string(θ)=>2.0)) - res = result(braket_task) - non_para_circ = Circuit() |> (ci->H(ci, 0)) |> (ci->Rx(ci, 1, 1.0)) |> (ci->Ry(ci, 0, 2.0)) |> Probability - oq3_circ2 = ir(non_para_circ, Val(:OpenQASM)) - braket_task2 = run(dev, oq3_circ2, shots=0) - res2 = result(braket_task2) - @test res.values == res2.values - end - end - end - Braket.IRType[] = :OpenQASM -end diff --git a/PyBraket/test/gates.jl b/PyBraket/test/gates.jl deleted file mode 100644 index 686ecf70..00000000 --- a/PyBraket/test/gates.jl +++ /dev/null @@ -1,84 +0,0 @@ -using Test, PyBraket, Braket, Braket.IR, PythonCall -using PythonCall: Py, pyconvert - -using Braket: I - -@testset "Gates" begin - Braket.IRType[] = :JAQCD - @testset for (gate, ir_gate) in ((H, IR.H), - (I, IR.I), - (X, IR.X), - (Y, IR.Y), - (Z, IR.Z), - (S, IR.S), - (Si, IR.Si), - (T, IR.T), - (Ti, IR.Ti), - (V, IR.V), - (Vi, IR.Vi) - ) - g = gate() - ir_g = Braket.ir(g, 0) - py_g = Py(g) - @test pyconvert(Bool, py_g.to_ir([0]) == Py(ir_g)) - @test pyconvert(ir_gate, Py(ir_g)) == ir_g - end - @testset for (gate, ir_gate) in ((PhaseShift, IR.PhaseShift), - (Rx, IR.Rx), - (Ry, IR.Ry), - (Rz, IR.Rz), - ) - angle = rand() - g = gate(angle) - ir_g = Braket.ir(g, 0) - py_g = Py(g) - @test pyconvert(Bool, py_g.to_ir([0]) == Py(ir_g)) - @test pyconvert(ir_gate, Py(ir_g)) == ir_g - end - @testset for (gate, ir_gate) in ((CNot, IR.CNot), - (Swap, IR.Swap), - (ISwap, IR.ISwap), - (CZ, IR.CZ), - (CY, IR.CY), - (CV, IR.CV), - (ECR, IR.ECR), - ) - g = gate() - ir_g = Braket.ir(g, [0, 1]) - py_g = Py(g) - @test pyconvert(Bool, py_g.to_ir([0, 1]) == Py(ir_g)) - @test pyconvert(ir_gate, Py(ir_g)) == ir_g - end - @testset for (gate, ir_gate) in ((CPhaseShift, IR.CPhaseShift), - (CPhaseShift00, IR.CPhaseShift00), - (CPhaseShift01, IR.CPhaseShift01), - (CPhaseShift10, IR.CPhaseShift10), - (XX, IR.XX), - (YY, IR.YY), - (ZZ, IR.ZZ), - (PSwap, IR.PSwap) - ) - angle = rand() - g = gate(angle) - ir_g = Braket.ir(g, [0, 1]) - py_g = Py(g) - @test pyconvert(Bool, py_g.to_ir([0, 1]) == Py(ir_g)) - @test pyconvert(ir_gate, Py(ir_g)) == ir_g - end - @testset for (gate, ir_gate) in ((CCNot, IR.CCNot), (CSwap, IR.CSwap)) - g = gate() - ir_g = Braket.ir(g, [0, 1, 2]) - py_g = Py(g) - @test pyconvert(Bool, py_g.to_ir([0, 1, 2]) == Py(ir_g)) - @test pyconvert(ir_gate, Py(ir_g)) == ir_g - end - @testset "(gate, ir_gate) = (Unitary, IR.Unitary)" begin - mat = complex([0. 1.; 1. 0.]) - n = Unitary(mat) - ir_n = Braket.ir(n, 0) - py_n = Py(n) - @test pyconvert(Bool, py_n.to_ir([0]) == Py(ir_n)) - @test pyconvert(IR.Unitary, Py(ir_n)) == ir_n - end - Braket.IRType[] = :OpenQASM -end diff --git a/PyBraket/test/integ_tests/job_test_script.py b/PyBraket/test/integ_tests/job_test_script.py deleted file mode 100644 index 7071ffd6..00000000 --- a/PyBraket/test/integ_tests/job_test_script.py +++ /dev/null @@ -1,53 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"). You -# may not use this file except in compliance with the License. A copy of -# the License is located at -# -# http://aws.amazon.com/apache2.0/ -# -# or in the "license" file accompanying this file. This file is -# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF -# ANY KIND, either express or implied. See the License for the specific -# language governing permissions and limitations under the License. - -import json -import os - -from braket.aws import AwsDevice -from braket.circuits import Circuit -from braket.jobs import save_job_checkpoint, save_job_result -from braket.jobs_data import PersistedJobDataFormat - - -def start_here(): - hp_file = os.environ["AMZN_BRAKET_HP_FILE"] - with open(hp_file, "r") as f: - hyperparameters = json.load(f) - - if hyperparameters["test_case"] == "completed": - completed_job_script() - else: - failed_job_script() - - -def failed_job_script(): - print("Test job started!!!!!") - assert 0 - - -def completed_job_script(): - print("Test job started!!!!!") - - # Use the device declared in the Orchestration Script - device = AwsDevice(os.environ["AMZN_BRAKET_DEVICE_ARN"]) - - bell = Circuit().h(0).cnot(0, 1) - for count in range(5): - task = device.run(bell, shots=100) - print(task.result().measurement_counts) - save_job_result({"converged": True, "energy": -0.2}) - save_job_checkpoint({"some_data": "abc"}, checkpoint_file_suffix="plain_data") - save_job_checkpoint({"some_data": "abc"}, data_format=PersistedJobDataFormat.PICKLED_V4) - - print("Test job completed!!!!!") diff --git a/PyBraket/test/integ_tests/local_braket_simulator.jl b/PyBraket/test/integ_tests/local_braket_simulator.jl deleted file mode 100644 index 93998fcd..00000000 --- a/PyBraket/test/integ_tests/local_braket_simulator.jl +++ /dev/null @@ -1,360 +0,0 @@ -using Braket, Braket.Observables, LinearAlgebra, PyBraket, Statistics, Test -using Braket: I - -PURE_DEVICE = PyBraket.LocalSimulator() -NOISE_DEVICE = PyBraket.LocalSimulator("braket_dm") -SHOTS = 8000 - -get_tol(shots::Int) = return (shots > 0 ? Dict("atol"=> 0.1, "rtol"=>0.15) : Dict("atol"=>0.01, "rtol"=>0)) - -bell_circ() = Circuit([(H, 0), (CNot, 0, 1)]) -three_qubit_circuit(θ::Float64, ϕ::Float64, φ::Float64, obs::Observables.Observable, obs_targets::Vector{Int}) = Circuit([(Rx, 0, θ), (Rx, 1, ϕ), (Rx, 2, φ), (CNot, 0, 1), (CNot, 1, 2), (Variance, obs, obs_targets), (Expectation, obs, obs_targets)]) - -@inline function variance_expectation_sample_result(res::Braket.GateModelQuantumTaskResult, shots::Int, expected_var::Float64, expected_mean::Float64, expected_eigs::Vector{Float64}) - tol = get_tol(shots) - variance = res.values[1] - expectation = res.values[2] - if shots > 0 - samples = res.values[3] - sign_fix(x) = iszero(x) ? 0.0 : x - @test isapprox(sort(collect(unique(sign_fix, samples))), sort(collect(unique(sign_fix, expected_eigs))), rtol=tol["rtol"], atol=tol["atol"]) - @test isapprox(mean(samples), expected_mean, rtol=tol["rtol"], atol=tol["atol"]) - @test isapprox(var(samples), expected_var, rtol=tol["rtol"], atol=tol["atol"]) - end - @test isapprox(expectation, expected_mean, rtol=tol["rtol"], atol=tol["atol"]) - @test isapprox(variance, expected_var, rtol=tol["rtol"], atol=tol["atol"]) -end - -@testset "Local Braket Simulator" begin - @testset for (backend, device_name) in [("default", "StateVectorSimulator"), - ("braket_sv", "StateVectorSimulator"), - ("braket_dm", "DensityMatrixSimulator")] - local_simulator_device = PyBraket.LocalSimulator(backend) - @test name(local_simulator_device) == device_name - end - @testset for DEVICE in (PURE_DEVICE, NOISE_DEVICE) - @testset "qubit ordering" begin - device = DEVICE - state_110 = Circuit([(X, 0), (X, 1), (I, 2)]) - state_001 = Circuit([(I, 0), (I, 1), (X, 2)]) - @testset for (state, most_com) in ((state_110, "110"), (state_001, "001")) - tasks = (state, ir(state, Val(:OpenQASM))) - @testset for task in tasks - res = result(device(task, shots=SHOTS)) - mc = argmax(res.measurement_counts) - @test mc == most_com - end - end - end - - @testset "Bell pair nonzero shots" begin - circuit = bell_circ() - circuit(Expectation, Observables.H() * Observables.X(), [0, 1]) - circuit(Sample, Observables.H() * Observables.X(), [0, 1]) - tasks = (circuit, ir(circuit, Val(:OpenQASM))) - @testset for task in tasks - device = DEVICE - res = result(device(task, shots=SHOTS)) - @test length(res.result_types) == 2 - @test 0.6 < res[Expectation(Observables.H() * Observables.X(), [0, 1])] < 0.8 - @test length(res[Sample(Observables.H() * Observables.X(), [0, 1])]) == SHOTS - end - end - @testset "Bell pair full probability" begin - circuit = bell_circ() - circuit(Probability) - tasks = (circuit, ir(circuit, Val(:OpenQASM))) - tol = get_tol(SHOTS) - @testset for task in tasks - device = DEVICE - res = result(device(task, shots=SHOTS)) - @test length(res.result_types) == 1 - @test isapprox(res[Probability()], [0.5, 0.0, 0.0, 0.5], rtol=tol["rtol"], atol=tol["atol"]) - end - end - @testset "Bell pair marginal probability" begin - circuit = bell_circ() - circuit(Probability, 0) - tasks = (ir(circuit, Val(:OpenQASM)),) - tol = get_tol(SHOTS) - @testset for task in tasks - device = DEVICE - res = result(device(task, shots=SHOTS)) - @test length(res.result_types) == 1 - @test isapprox(res[Probability(0)], [0.5, 0.5], rtol=tol["rtol"], atol=tol["atol"]) - end - end - @testset "Result types x x y" begin - θ = 0.432 - ϕ = 0.123 - φ = -0.543 - obs = Observables.X() * Observables.Y() - obs_targets = [0, 2] - circuit = three_qubit_circuit(θ, ϕ, φ, obs, obs_targets) - expected_mean = sin(θ) * sin(ϕ) * sin(φ) - expected_var = (8*sin(θ)^2 * cos(2φ) * sin(ϕ)^2 - cos(2(θ - ϕ))- cos(2(θ + ϕ)) + 2*cos(2θ) + 2*cos(2ϕ) + 14) / 16 - expected_eigs = [-1.0, 1.0] - device = DEVICE - shots = SHOTS - circuit = three_qubit_circuit(θ, ϕ, φ, obs, obs_targets) - shots > 0 && circuit(Sample, obs, obs_targets) - tasks = (circuit, ir(circuit, Val(:OpenQASM))) - for task in tasks - res = result(device(task, shots=shots)) - variance_expectation_sample_result(res, shots, expected_var, expected_mean, expected_eigs) - end - end - @testset "Result types z x h x y" begin - θ = 0.432 - ϕ = 0.123 - φ = -0.543 - obs = Observables.Z() * Observables.H() * Observables.Y() - obs_targets = [0, 1, 2] - circuit = three_qubit_circuit(θ, ϕ, φ, obs, obs_targets) - expected_mean = -(cos(φ)*sin(ϕ)+sin(φ)*cos(θ))/√2 - expected_var = (3 + cos(2ϕ)*cos(φ)^2 - cos(2θ)*sin(φ)^2 - 2*cos(θ)*sin(ϕ)*sin(2φ)) / 4 - expected_eigs = [-1.0, 1.0] - device = DEVICE - shots = SHOTS - circuit = three_qubit_circuit(θ, ϕ, φ, obs, obs_targets) - shots > 0 && circuit(Sample, obs, obs_targets) - tasks = (circuit, ir(circuit, Val(:OpenQASM))) - for task in tasks - res = result(device(task, shots=shots)) - variance_expectation_sample_result(res, shots, expected_var, expected_mean, expected_eigs) - end - end - @testset "Result types z x z" begin - θ = 0.432 - ϕ = 0.123 - φ = -0.543 - obs = Observables.Z() * Observables.Z() - obs_targets = [0, 2] - circuit = three_qubit_circuit(θ, ϕ, φ, obs, obs_targets) - expected_mean = 0.849694136476246 - expected_var = 0.27801987443788634 - expected_eigs = [-1.0, 1.0] - device = DEVICE - shots = SHOTS - circuit = three_qubit_circuit(θ, ϕ, φ, obs, obs_targets) - shots > 0 && circuit(Sample, obs, obs_targets) - tasks = (circuit, ir(circuit, Val(:OpenQASM))) - for task in tasks - res = result(device(task, shots=shots)) - variance_expectation_sample_result(res, shots, expected_var, expected_mean, expected_eigs) - end - end - @testset "Result types tensor {y,z,Hermitian} x Hermitian" begin - θ = 0.432 - ϕ = 0.123 - φ = -0.543 - ho_mat = [-6 2+im -3 -5+2im; - 2-im 0 2-im -5+4im; - -3 2+im 0 -4+3im; - -5-2im -5-4im -4-3im -6] - @test ishermitian(ho_mat) - ho = Observables.HermitianObservable(ho_mat) - ho_mat2 = [1 2; 2 4] - ho2 = Observables.HermitianObservable(ho_mat2) - - meany = 1.4499810303182408 - meanz = 0.5 *(-6 * cos(θ) * (cos(φ) + 1) - 2 * sin(φ) * (cos(θ) + sin(ϕ) - 2 * cos(ϕ)) + 3 * cos(φ) * sin(ϕ) + sin(ϕ)) - meanh = -4.30215023196904 - - vary = 74.03174647518193 - varz = (1057 - cos(2ϕ) + 12*(27 + cos(2ϕ))*cos(φ) - 2*cos(2φ)*sin(ϕ)*(16*cos(ϕ) + 21*sin(ϕ)) + 16*sin(2ϕ) - 8*(-17 + cos(2ϕ) + 2 * sin(2ϕ)) * sin(φ) - 8 * cos(2θ) * (3 + 3*cos(φ) + sin(φ))^2 - 24*cos(ϕ)*(cos(ϕ) + 2*sin(ϕ)) * sin(2φ) - 8*cos(θ)*(4*cos(ϕ)*(4 + 8*cos(φ) + cos(2φ) - (1 + 6*cos(φ))*sin(φ)) + sin(ϕ)*(15 + 8*cos(φ) - 11*cos(2φ) + 42*sin(φ) + 3*sin(2φ)))) / 16 - varh = 370.71292282796804 - - y_array = [0 -im; im 0] - z_array = diagm([1, -1]) - eigsy = eigvals(kron(y_array, ho_mat)) - eigsz = eigvals(kron(z_array, ho_mat)) - eigsh = [-70.90875406, -31.04969387, 0, 3.26468993, 38.693758] - obs_targets = [0, 1, 2] - @testset for (obs, expected_mean, expected_var, expected_eigs) in [(Observables.Y() * ho, meany, vary, eigsy), - (Observables.Z() * ho, meanz, varz, eigsz), - (ho2 * ho, meanh, varh, eigsh)] - device = DEVICE - shots = SHOTS - circuit = three_qubit_circuit(θ, ϕ, φ, obs, obs_targets) - shots > 0 && circuit(Sample, obs, obs_targets) - tasks = (circuit, ir(circuit, Val(:OpenQASM))) - for task in tasks - res = result(device(task, shots=shots)) - variance_expectation_sample_result(res, shots, expected_var, expected_mean, expected_eigs) - end - end - end - @testset "Result types all selected" begin - θ = 0.543 - ho_mat = [1 2im; -2im 0] - ho = Observables.HermitianObservable(ho_mat) - expected_mean = 2*sin(θ) + 0.5*cos(θ) + 0.5 - var_ = 0.25 * (sin(θ) - 4*cos(θ))^2 - expected_var = [var_, var_] - expected_eigs = eigvals(Hermitian(ho_mat)) - device = DEVICE - shots = SHOTS - circuit = Circuit([(Rx, 0, θ), (Rx, 1, θ), (Variance, ho), (Expectation, ho, 0)]) - shots > 0 && circuit(Sample, ho, 1) - for task in (circuit, ir(circuit, Val(:OpenQASM))) - res = result(device(task, shots=shots)) - tol = get_tol(shots) - variance = res.values[1] - expectation = res.values[2] - if shots > 0 - samples = res.values[3] - @test isapprox(sort(collect(unique(samples))), sort(collect(unique(expected_eigs))), rtol=tol["rtol"], atol=tol["atol"]) - @test isapprox(mean(samples), expected_mean, rtol=tol["rtol"], atol=tol["atol"]) - @test isapprox(var(samples), var_, rtol=tol["rtol"], atol=tol["atol"]) - end - @test isapprox(expectation, expected_mean, rtol=tol["rtol"], atol=tol["atol"]) - @test isapprox(variance, expected_var, rtol=tol["rtol"], atol=tol["atol"]) - end - end - @testset "Result types noncommuting" begin - shots = 0 - θ = 0.432 - ϕ = 0.123 - φ = -0.543 - ho_mat = [-6 2+im -3 -5+2im; - 2-im 0 2-im -5+4im; - -3 2+im 0 -4+3im; - -5-2im -5-4im -4-3im -6] - obs1 = Observables.X() * Observables.Y() - obs1_targets = [0, 2] - obs2 = Observables.Z() * Observables.Z() - obs2_targets = [0, 2] - obs3 = Observables.Y() * Observables.HermitianObservable(ho_mat) - obs3_targets = [0, 1, 2] - obs3_targets = [0, 1, 2] - circuit = three_qubit_circuit(θ, ϕ, φ, obs1, obs1_targets) - circuit(Expectation, obs2, obs2_targets) - circuit(Expectation, obs3, obs3_targets) - - expected_mean1 = sin(θ) * sin(ϕ) * sin(φ) - expected_var1 = (8*sin(θ)^2 * cos(2φ) * sin(ϕ)^2 - cos(2(θ - ϕ))- cos(2(θ + ϕ)) + 2*cos(2θ) + 2*cos(2ϕ) + 14) / 16 - expected_mean2 = 0.849694136476246 - expected_mean3 = 1.4499810303182408 - - tasks = (circuit, ir(circuit, Val(:OpenQASM))) - @testset for task in tasks - device = DEVICE - res = result(device(task, shots=shots)) - @test isapprox(res.values[1], expected_var1) - @test isapprox(res.values[2], expected_mean1) - @test isapprox(res.values[3], expected_mean2) - @test isapprox(res.values[4], expected_mean3) - end - end - @testset "Result types noncommuting flipped targets" begin - circuit = bell_circ() - tp = Observables.TensorProduct(["h", "x"]) - circuit = Expectation(circuit, tp, [0, 1]) - circuit = Expectation(circuit, tp, [1, 0]) - tasks = (circuit, ir(circuit, Val(:OpenQASM))) - @testset for task in tasks - device = DEVICE - res = result(device(task, shots=0)) - @test isapprox(res.values[1], √2 / 2) - @test isapprox(res.values[2], √2 / 2) - end - end - @testset "Result types all noncommuting" begin - circuit = bell_circ() - ho = [1 2im; -2im 0] - circuit(Expectation, Observables.HermitianObservable(ho)) - circuit(Expectation, Observables.X()) - tasks = (circuit, ir(circuit, Val(:OpenQASM))) - @testset for task in tasks - device = DEVICE - res = result(device(task, shots=0)) - @test isapprox(res.values[1], [0.5, 0.5]) - @test isapprox(res.values[2], [0, 0]) - end - end - @testset "Result types observable not in instructions" begin - bell = bell_circ() - bell(Expectation, Observables.X(), 2) - bell(Variance, Observables.Y(), 3) - bell_qasm = ir(bell, Val(:OpenQASM)) - @test qubit_count(bell) == 4 - shots = SHOTS - device = DEVICE - @testset for task in (bell, bell_qasm) - tol = get_tol(shots) - res = result(device(task, shots=shots)) - @test isapprox(res.values[1], 0, rtol=tol["rtol"], atol=tol["atol"]) - @test isapprox(res.values[2], 1, rtol=tol["rtol"], atol=tol["atol"]) - end - end - end - @testset for DEVICE in (PURE_DEVICE,) - @testset "Result types no shots" begin - @testset for include_amplitude in [true, false] - circuit = bell_circ() - circuit(Expectation, Observables.H() * Observables.X(), 0, 1) - include_amplitude && circuit(Amplitude, ["01", "10", "00", "11"]) - tasks = (circuit, ir(circuit, Val(:OpenQASM))) - @testset for task in tasks - device = DEVICE - shots = 0 - res = result(device(task, shots=0)) - @test length(res.result_types) == (include_amplitude ? 2 : 1) - @test isapprox(res[Expectation(Observables.H() * Observables.X(), [0, 1])], 1/√2) - if include_amplitude - amps = res[Amplitude(["01", "10", "00", "11"])] - @test isapprox(amps["01"], 0) - @test isapprox(amps["10"], 0) - @test isapprox(amps["00"], 1/√2) - @test isapprox(amps["11"], 1/√2) - end - end - end - end - @testset "Multithreaded Bell pair" begin - tol = get_tol(SHOTS) - tasks = (bell_circ, (()->ir(bell_circ(), Val(:OpenQASM)))) - device = DEVICE - @testset for task in tasks - run_circuit(circuit) = result(device(circuit, shots=SHOTS)) - task_array = [task() for ii in 1:Threads.nthreads()] - futures = [Threads.@spawn run_circuit(c) for c in task_array] - future_results = fetch.(futures) - for r in future_results - @test isapprox(r.measurement_probabilities["00"], 0.5, rtol=tol["rtol"], atol=tol["atol"]) - @test isapprox(r.measurement_probabilities["11"], 0.5, rtol=tol["rtol"], atol=tol["atol"]) - @test length(r.measurements) == SHOTS - end - end - end - end - @testset for DEVICE in (NOISE_DEVICE,) - @testset "noisy circuit 1 qubit noise full probability" begin - shots = SHOTS - tol = get_tol(shots) - circuit = Circuit([(X, 0), (X, 1), (BitFlip, 0, 0.1), (Probability,)]) - tasks = (circuit, ir(circuit, Val(:OpenQASM))) - device = DEVICE - for task in tasks - res = result(device(task, shots=shots)) - @test length(res.result_types) == 1 - @test isapprox(res[Probability()], [0.0, 0.1, 0, 0.9], rtol=tol["rtol"], atol=tol["atol"]) - end - end - @testset "noisy circuit 2 qubit noise full probability" begin - shots = SHOTS - tol = get_tol(shots) - K0 = √0.9 * diagm(ones(4)) - K1 = √0.1 * kron([0.0 1.0; 1.0 0.0], [0.0 1.0; 1.0 0.0]) - circuit = Circuit([(X, 0), (X, 1), (Kraus, [0, 1], [K0, K1]), (Probability,)]) - tasks = (circuit, ir(circuit, Val(:OpenQASM))) - device = DEVICE - for task in tasks - res = result(device(task, shots=shots)) - @test length(res.result_types) == 1 - @test isapprox(res[Probability()], [0.1, 0.0, 0, 0.9], rtol=tol["rtol"], atol=tol["atol"]) - end - end - end -end diff --git a/PyBraket/test/integ_tests/runtests.jl b/PyBraket/test/integ_tests/runtests.jl deleted file mode 100644 index 42735343..00000000 --- a/PyBraket/test/integ_tests/runtests.jl +++ /dev/null @@ -1,3 +0,0 @@ -using Braket, PyBraket, Test - -include("local_braket_simulator.jl") diff --git a/PyBraket/test/noise.jl b/PyBraket/test/noise.jl deleted file mode 100644 index 6a9eb1d2..00000000 --- a/PyBraket/test/noise.jl +++ /dev/null @@ -1,87 +0,0 @@ -using Test, PyBraket, Braket, Braket.IR, PythonCall -using PythonCall: Py, pyconvert - -@testset "Noise" begin - circ = CNot(H(Circuit(), 0), 0, 1) - noise = BitFlip(0.1) - circ = Braket.apply_gate_noise!(circ, noise) - - device = PyBraket.LocalSimulator("braket_dm") - # run the circuit on the local simulator - task = run(device, circ, shots=1000) - - t_result = result(task) - measurement = t_result.measurement_counts - @test haskey(measurement, "10") - @test haskey(measurement, "01") - - noise = TwoQubitDephasing(0.1) - circ = Z(X(CNot(Y(X(Circuit(), 0), 1), 0, 1), 1), 0) - circ = Braket.apply_initialization_noise!(circ, noise) - @test circ.instructions[1] == Braket.Instruction(TwoQubitDephasing(0.1), [0, 1]) - circ = Braket.apply_readout_noise!(circ, PhaseFlip(0.2)) - @test circ.instructions[end-1] == Braket.Instruction(PhaseFlip(0.2), 0) - @test circ.instructions[end] == Braket.Instruction(PhaseFlip(0.2), 1) - - orig_len = length(circ.moments) - ts = Braket.time_slices(circ.moments) - @test length(circ.moments) == orig_len - @test length(ts) == orig_len - @testset "Conversions to/from Python" begin - Braket.IRType[] = :JAQCD - @testset for (noise, ir_noise) in ( (BitFlip, IR.BitFlip), - (PhaseFlip, IR.PhaseFlip), - (AmplitudeDamping, IR.AmplitudeDamping), - (PhaseDamping, IR.PhaseDamping), - (Depolarizing, IR.Depolarizing)) - n = noise(0.1) - ir_n = Braket.ir(n, 0) - py_n = Py(n) - @test pyconvert(Bool, py_n.to_ir([0]) == Py(ir_n)) - @test pyconvert(ir_noise, Py(ir_n)) == ir_n - end - @testset "(noise, ir_noise) = (PauliChannel, IR.PauliChannel)" begin - n = PauliChannel(0.1, 0.2, 0.1) - ir_n = Braket.ir(n, 0) - py_n = Py(n) - @test pyconvert(Bool, py_n.to_ir([0]) == Py(ir_n)) - @test pyconvert(IR.PauliChannel, Py(ir_n)) == ir_n - end - @testset "(noise, ir_noise) = (MultiQubitPauliChannel{1}, IR.MultiQubitPauliChannel)" begin - n = MultiQubitPauliChannel{1}(Dict("X"=>0.1, "Y"=>0.2)) - ir_n = Braket.ir(n, 0) - @test pyconvert(IR.MultiQubitPauliChannel, Py(ir_n)) == ir_n - end - @testset "(noise, ir_noise) = (TwoQubitPauliChannel, IR.MultiQubitPauliChannel)" begin - n = TwoQubitPauliChannel(Dict("XX"=>0.1, "YY"=>0.2)) - ir_n = Braket.ir(n, [0, 1]) - py_n = Py(n) - @test pyconvert(Bool, py_n.to_ir([0, 1]) == Py(ir_n)) - @test pyconvert(IR.MultiQubitPauliChannel, Py(ir_n)) == ir_n - end - @testset for (noise, ir_noise) in ((TwoQubitDephasing, IR.TwoQubitDephasing), - (TwoQubitDepolarizing, IR.TwoQubitDepolarizing)) - n = noise(0.4) - ir_n = Braket.ir(n, [0, 1]) - py_n = Py(n) - @test pyconvert(Bool, py_n.to_ir([0, 1]) == Py(ir_n)) - @test pyconvert(ir_noise, Py(ir_n)) == ir_n - end - @testset "(noise, ir_noise) = (GeneralizedAmplitudeDamping, IR.GeneralizedAmplitudeDamping)" begin - n = GeneralizedAmplitudeDamping(0.1, 0.2) - ir_n = Braket.ir(n, 0) - py_n = Py(n) - @test pyconvert(Bool, py_n.to_ir([0]) == Py(ir_n)) - @test pyconvert(IR.GeneralizedAmplitudeDamping, Py(ir_n)) == ir_n - end - @testset "(noise, ir_noise) = (Kraus, IR.Kraus)" begin - mat = complex([0. 1.; 1. 0.]) - n = Kraus([mat]) - ir_n = Braket.ir(n, 0) - py_n = Py(n) - @test pyconvert(Bool, py_n.to_ir([0]) == Py(ir_n)) - @test pyconvert(IR.Kraus, Py(ir_n)) == ir_n - end - Braket.IRType[] = :OpenQASM - end -end diff --git a/PyBraket/test/runtests.jl b/PyBraket/test/runtests.jl index ef624576..6e1eec1b 100644 --- a/PyBraket/test/runtests.jl +++ b/PyBraket/test/runtests.jl @@ -18,7 +18,7 @@ end const GROUP = get(ENV, "GROUP", "PyBraket-unit") -groups = GROUP == "All" ? ["PyBraket-integ", "PyBraket-unit"] : [GROUP] +groups = GROUP == "All" ? ["PyBraket-unit"] : [GROUP] for group in groups @info "Testing $group" @@ -28,11 +28,6 @@ for group in groups set_aws_creds(test_type) if test_type == "unit" - include(joinpath(@__DIR__, "circuits.jl")) - include(joinpath(@__DIR__, "noise.jl")) - include(joinpath(@__DIR__, "gates.jl")) include(joinpath(@__DIR__, "ahs.jl")) - elseif test_type == "integ" - include(joinpath(@__DIR__, "integ_tests/runtests.jl")) end end diff --git a/README.md b/README.md index 755ae3ac..25ec28dc 100644 --- a/README.md +++ b/README.md @@ -16,12 +16,14 @@ Please review the [CHANGELOG](CHANGELOG.md) for information about changes in eac ## Installation & Prerequisites You do *not* need a Python installation or the Python Amazon Braket SDK installed to use this package. -However, to use the Amazon Braket [Local Simulators](https://docs.aws.amazon.com/braket/latest/developerguide/braket-send-to-local-simulator.html) +However, to use the Amazon Braket Analog Hamiltonian Simulation [Local Simulator](https://docs.aws.amazon.com/braket/latest/developerguide/braket-send-to-local-simulator.html) you'll need to install the sub-package `PyBraket.jl`, included in this repository. See its [`README`](PyBraket/README.md) for more information. - + +For *gate based* local simulations, with or without noise, see [`BraketSimulator.jl`](https://github.com/amazon-braket/braketsimulator.jl). + All necessary Julia packages will be installed for you when you run `Pkg.add("Braket")` -or `] instantiate` (if you're doing a `dev` install). +or `] instantiate` (if you're doing a [`dev`](https://pkgdocs.julialang.org/v1/managing-packages/#developing) install). If you want to run tasks on Amazon Braket's [managed simulators or QPUs](https://docs.aws.amazon.com/braket/latest/developerguide/braket-devices.html) or run [managed jobs](https://docs.aws.amazon.com/braket/latest/developerguide/braket-jobs-works.html), @@ -57,10 +59,26 @@ c = H(c, 0) c = CNot(c, 0, 1) c = Expectation(c, Observables.X()) # measure X on all qubits -dev = AwsDevice("arn:aws:braket:::device/qpu/ionq/ionQdevice") +dev = AwsDevice("arn:aws:braket:us-east-1::device/qpu/ionq/Harmony") res = result(dev(c, shots=10)) ``` +Simulating a noisy circuit locally: + +```julia +using BraketSimulator, Braket + +c = Circuit() +c = H(c, 0) # qubits are 0-indexed +c = CNot(c, 0, 1) +c = BitFlip(c, 0, 0.1) +c = PhaseFlip(c, 1, 0.2) +c = Probability(c) + +dev = LocalSimulator("braket_dm_v2") +res = result(simulate(dev, c, shots=200)) +``` + ## TODO and development roadmap As Amazon Braket expands its featureset, we welcome contributions and development from the Julia community. @@ -69,6 +87,7 @@ What's currently implemented in *pure* Julia: - All of the [`Amazon Braket schemas`](https://github.com/aws/amazon-braket-schemas-python). - Submitting [`Amazon Braket Hybrid Jobs`](https://docs.aws.amazon.com/braket/latest/developerguide/braket-jobs.html) +- Abstract interface for `LocalSimulator`s - Local jobs - Building and submitting circuits to managed simulators and QPUs - Reading results from managed simulators and QPUs diff --git a/docs/src/local_simulator.md b/docs/src/local_simulator.md index 701686d2..2297e0e2 100644 --- a/docs/src/local_simulator.md +++ b/docs/src/local_simulator.md @@ -2,7 +2,43 @@ Local simulators allow you to *classically* simulate your [`Circuit`](@ref) or `OpenQasmProgram` on local hardware, rather than sending it to the cloud for on-demand execution. Local simulators -can run task *batches* in parallel using multithreading. +can run task *batches* in parallel using multithreading. Gate-based simulators are provided in the +[`BraketSimulator.jl`](https://github.com/amazon-braket/braketsimulator.jl) package. + +Developers wishing to implement their own `LocalSimulator` should extend the `simulate` function. +New simulator backends must be subtypes of the `AbstractLocalSimulator` type. +Additionally, new simulators should "register" themselves in `Braket._simulator_devices` in their +parent module's `__init__` function so that they can be referred to by name, like so: + +```julia +module NewLocalSimulator + +using Braket + +struct NewSimulator <: Braket.AbstractLocalSimulator +# implementation of a new local simulator backend +# with name "new_simulator" +end + +function Braket.simulate() + # simulation implementation here +end + +function __init__() + Braket._simulator_devices[]["new_simulator"] = NewLocalSimulator() +end + +end +``` + +Then users can use the new simulator like so: + +```julia +using NewLocalSimulator, Braket + +dev = LocalSimulator("new_simulator") +simulate(dev, task_specification, args...; kwargs...) +``` ```@docs Braket._simulator_devices diff --git a/docs/src/pybraket.md b/docs/src/pybraket.md index 824fa186..6ffb6b2b 100644 --- a/docs/src/pybraket.md +++ b/docs/src/pybraket.md @@ -1,4 +1,10 @@ # PyBraket +`PyBraket.jl` is used to interface with the Python BDK to provide functionality that is not yet implemented in Julia. +Currently, there are two such features: + +- Local simulation of analog Hamiltonian simulators (the `"braket_ahs"` local simulator) +- Unpickling of results from Amazon Braket Hybrid Jobs + ```@docs ``` diff --git a/examples/Project.toml b/examples/Project.toml index 72b1c960..70d8f793 100644 --- a/examples/Project.toml +++ b/examples/Project.toml @@ -1,5 +1,6 @@ [deps] Braket = "19504a0f-b47d-4348-9127-acc6cc69ef67" +BraketSimulator = "76d27892-9a0b-406c-98e4-7c178e9b3dff" Cairo = "159f3aea-2a34-519c-b102-8c37f9878175" Colors = "5ae59095-9a9b-59fe-a467-6f913c188581" Compose = "a81c6b42-2e10-5240-aca2-a61377ecd94b" diff --git a/examples/ahs_rabi.jl b/examples/ahs_rabi.jl index 7ff5c7fc..d06093cf 100644 --- a/examples/ahs_rabi.jl +++ b/examples/ahs_rabi.jl @@ -103,7 +103,7 @@ md"Now we'll run each program on the AHS local simulator with 1000 shots." device = PyBraket.LocalSimulator("braket_ahs") # ╔═╡ 14a896f6-f218-43e4-9278-3de94c88cd32 -local_results = [result(run(device, program, shots=1000)) for program in programs] +local_results = [result(simulate(device, program, shots=1000)) for program in programs] # ╔═╡ 229b0550-6bd0-4f81-b37a-5a0b8e33a9b1 state_counts = local_results .|> get_counts diff --git a/examples/graph_coloring.jl b/examples/graph_coloring.jl index 2cf73065..bc64559f 100644 --- a/examples/graph_coloring.jl +++ b/examples/graph_coloring.jl @@ -6,7 +6,7 @@ using InteractiveUtils # ╔═╡ 5ba10044-c01a-486a-b6bd-bad198bf1960 # Braket imports -using Braket, PyBraket, SparseArrays, NLopt +using Braket, BraketSimulator, SparseArrays, NLopt # ╔═╡ ec25630f-2ca7-421a-8559-3046144dd236 using Graphs, GraphMakie, Colors, Cairo, Compose, LinearAlgebra @@ -346,7 +346,7 @@ DEPTH = 2 SHOTS = 1000 # ╔═╡ 27f74c2b-8f88-444c-a270-4e1c30cc9b70 -device = PyBraket.LocalSimulator() +device = LocalSimulator("braket_sv_v2") # ╔═╡ a20ffdbb-f006-408e-a8a1-fc4dc1c4c7b5 tracker = train(nv*k, J, device; depth=DEPTH, nshots=SHOTS) diff --git a/examples/qft.jl b/examples/qft.jl index e2477ebd..14b0a884 100644 --- a/examples/qft.jl +++ b/examples/qft.jl @@ -5,7 +5,7 @@ using Markdown using InteractiveUtils # ╔═╡ d928ee56-0f14-426c-b669-356627382f8f -using Braket, PyBraket +using Braket, BraketSimulator # ╔═╡ ab9771de-a268-4df8-811d-9310a12a7d79 using Plots @@ -202,7 +202,7 @@ With these routines defined, we can run QFT and its inverse on a simulator to de """ # ╔═╡ b3a750d1-7a2b-4de6-9e6c-166336ba6cec -device = PyBraket.LocalSimulator() +device = LocalSimulator("braket_sv_v2") # ╔═╡ 7127d624-fb0d-41b9-a8cd-6cae7d34d55f """ @@ -227,11 +227,11 @@ function run_and_plot_qft(c::Circuit) num_qubits = qubit_count(c) bitstring_keys = [prod(string.(digits(ii, base=2, pad=num_qubits))) for ii in 0:(2^num_qubits)-1] # specify desired result types - c(StateVector) + c(Braket.StateVector) c(Probability) # Run the task - task = run(device, c, shots=0) + task = simulate(device, c, shots=0) res = result(task) state_vector = res.values[1] probs_values = res.values[2] diff --git a/examples/shortest_path.jl b/examples/shortest_path.jl index f4a038cb..e960eb14 100644 --- a/examples/shortest_path.jl +++ b/examples/shortest_path.jl @@ -1,4 +1,4 @@ -using Braket, LinearAlgebra, SparseArrays, NLopt, Random +using Braket, BraketSimulator, LinearAlgebra, SparseArrays, NLopt, Random using Graphs, SimpleWeightedGraphs, GraphMakie nv = 5 @@ -171,7 +171,7 @@ SHOTS = 500 s, t = 1, 4 Q = build_hop_Q(s, t, nv, desired_hops, α, adj_mat) -device = LocalSimulator() +device = LocalSimulator("braket_sv_v2") tracker = train(nv*desired_hops, Q, device; depth=DEPTH, nshots=SHOTS) #s3_folder = (bucket, folder) if using managed simulator @show s, t diff --git a/examples/vqe_chemistry.jl b/examples/vqe_chemistry.jl index 9efb1d24..6109a083 100644 --- a/examples/vqe_chemistry.jl +++ b/examples/vqe_chemistry.jl @@ -5,7 +5,7 @@ using Markdown using InteractiveUtils # ╔═╡ 23aaba4e-3342-4581-a6bf-b039c390062e -using OrderedCollections, Braket, PyBraket, PyBraket.PythonCall, CondaPkg +using OrderedCollections, Braket, BraketSimulator, PyBraket, PyBraket.PythonCall, CondaPkg # ╔═╡ ff4fad96-1970-4fb9-a43a-df02cd5dc643 using Plots @@ -309,7 +309,7 @@ n_shots = 0 n_theta = 24 # ╔═╡ cbbd1b17-e9e5-4e3e-8cc1-fc0c26b8e66f -dev = LocalSimulator() +dev = LocalSimulator("braket_sv_v2") # ╔═╡ de771faa-96f7-44d0-801b-76fbb9dc8509 md""" diff --git a/src/local_simulator.jl b/src/local_simulator.jl index 6982f484..95d0eeaf 100644 --- a/src/local_simulator.jl +++ b/src/local_simulator.jl @@ -1,5 +1,5 @@ """ - LocalQuantumTask(id::String, result::GateModelQuantumTaskResult) + LocalQuantumTask(id::String, result::Union{GateModelQuantumTaskResult, AnalogHamiltonianSimulationQuantumTaskResult}) A quantum task which has been run *locally* using a [`LocalSimulator`](@ref). The `state` of a `LocalQuantumTask` is always `"COMPLETED"` as the task object @@ -7,7 +7,7 @@ is only created once the loca simulation has finished. """ struct LocalQuantumTask id::String - result::GateModelQuantumTaskResult + result::Union{GateModelQuantumTaskResult, AnalogHamiltonianSimulationQuantumTaskResult} end state(b::LocalQuantumTask) = "COMPLETED" id(b::LocalQuantumTask) = b.id @@ -59,7 +59,7 @@ the value of any [`FreeParameter`](@ref) in `task_spec` and will override the ex `inputs` field of an `OpenQasmProgram`. Other `kwargs` will be passed to the backend simulator. Returns a [`LocalQuantumTask`](@ref Braket.LocalQuantumTask). """ -function simulate(d::LocalSimulator, task_spec::Union{Circuit, AbstractProgram}, args...; shots::Int=0, inputs::Dict{String, Float64} = Dict{String, Float64}(), kwargs...) +function simulate(d::LocalSimulator, task_spec::Union{Circuit, AnalogHamiltonianSimulation, AbstractProgram}, args...; shots::Int=0, inputs::Dict{String, Float64} = Dict{String, Float64}(), kwargs...) sim = d._delegate @debug "Single task. Starting run..." stats = @timed _run_internal(sim, task_spec, args...; inputs=inputs, shots=shots, kwargs...) diff --git a/test/runtests.jl b/test/runtests.jl index 3ae9be22..9849f507 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -20,7 +20,7 @@ function set_aws_creds(test_type) end end -groups = GROUP == "All" ? ["Braket-integ", "Braket-unit", "PyBraket-integ", "PyBraket-unit", "Examples-unit", "Examples-integ"] : GROUP +groups = GROUP == "All" ? ["Braket-integ", "Braket-unit", "PyBraket-unit", "Examples-unit", "Examples-integ"] : GROUP groups = (groups isa String ? [groups] : groups) subpackage_path(subpackage::String) = joinpath(dirname(@__DIR__), subpackage)