From a2f005406a1d74d4aca6d31afa2d133e529be943 Mon Sep 17 00:00:00 2001 From: Katharine Hyatt <67932820+kshyatt-aws@users.noreply.github.com> Date: Tue, 21 Mar 2023 12:02:19 -0400 Subject: [PATCH] Fix integration tests, update gates and noises, and update deps (#53) * fix: bump integ test python versions * change: remove extraneous whitespace * fix: finalizer error * fix: fix dm1 integration test * change: schema update * fix: adjust to updates in AWS.jl * bump package versions --- Project.toml | 4 +- PyBraket/Project.toml | 4 +- PyBraket/src/py_type_conversion.jl | 84 ++ PyBraket/src/pyschema.jl | 242 ++---- src/ahs.jl | 2 - src/aws_jobs.jl | 6 +- src/gates.jl | 60 +- src/local_jobs.jl | 18 +- src/noises.jl | 35 +- src/raw_schema.jl | 820 +++++++++---------- test/circuits.jl | 5 +- test/integ_tests/create_local_quantum_job.jl | 14 +- test/integ_tests/create_quantum_job.jl | 4 +- test/integ_tests/simulator_quantum_task.jl | 8 +- 14 files changed, 624 insertions(+), 682 deletions(-) create mode 100644 PyBraket/src/py_type_conversion.jl diff --git a/Project.toml b/Project.toml index 53309b7e..686b075a 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Braket" uuid = "19504a0f-b47d-4348-9127-acc6cc69ef67" authors = ["Katharine Hyatt "] -version = "0.6.0" +version = "0.7.0" [deps] AWS = "fbe9abb3-538b-5e4e-ba9e-bc94f4f92ebc" @@ -30,7 +30,7 @@ Tar = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" [compat] -AWS = "=1.81.0" +AWS = "=1.82.0" AWSS3 = "=0.10.3" Aqua = "=0.6" AxisArrays = "=0.4.6" diff --git a/PyBraket/Project.toml b/PyBraket/Project.toml index 380e0906..80260202 100644 --- a/PyBraket/Project.toml +++ b/PyBraket/Project.toml @@ -1,7 +1,7 @@ name = "PyBraket" uuid = "e85266a6-1825-490b-a80e-9b9469c53660" authors = ["Katharine Hyatt "] -version = "0.6.0" +version = "0.7.0" [deps] Braket = "19504a0f-b47d-4348-9127-acc6cc69ef67" @@ -14,7 +14,7 @@ StructTypes = "856f2bd8-1eba-4b0a-8007-ebc267875bd4" [compat] Aqua = "=0.6" -Braket = "=0.6.0" +Braket = "=0.7.0" CondaPkg = "=0.2.17" DataStructures = "=0.18.13" PythonCall = "=0.9.12" diff --git a/PyBraket/src/py_type_conversion.jl b/PyBraket/src/py_type_conversion.jl new file mode 100644 index 00000000..7d10fa19 --- /dev/null +++ b/PyBraket/src/py_type_conversion.jl @@ -0,0 +1,84 @@ +using PythonCall, Braket, Braket.IR +import Braket.IR: IRObservable, AbstractProgramResult, AbstractProgram, AbstractIR +import Braket: ResultTypeValue + +function union_convert(::Type{IRObservable}, x) + PythonCall.pyisinstance(x, PythonCall.pybuiltins.str) && return pyconvert(String, x) + x_vec = Union{String, Vector{Vector{Vector{Float64}}}}[PythonCall.pyisinstance(x_, PythonCall.pybuiltins.str) ? pyconvert(String, x_) : pyconvert(Vector{Vector{Vector{Float64}}}, x_) for x_ in x] + return x_vec +end + +function union_convert(union_type, x) + union_ts = union_type isa Union ? Type[] : [union_type] + union_t = union_type + while union_t isa Union + union_t.a != Nothing && push!(union_ts, union_t.a) + !(union_t.b isa Union) && push!(union_ts, union_t.b) + union_t = union_t.b + end + arg = nothing + for t_ in union_ts + try + if pyisinstance(x, PythonCall.pybuiltins.list) && t_ <: Vector + return [union_convert(Union{eltype(t_)}, attr_) for attr_ in x] + elseif pyisinstance(x, pybuiltins.str) && t_ <: Integer + return tryparse(t_, pyconvert(String, x)) + elseif t_ == ResultTypeValue + if pyhasattr(x, "value") + typ = jl_convert(AbstractProgramResult, pygetattr(x, "type")) + val = union_convert(Union{Dict{String, ComplexF64}, Float64, Vector}, pygetattr(x, "value")) + return PythonCall.pyconvert_return(ResultTypeValue(typ, val)) + else + rt = jl_convert(AbstractProgramResult, x) + return PythonCall.pyconvert_return(ResultTypeValue(rt, 0.0)) + end + else + return pyconvert(t_, x) + end + catch e + end + end + arg isa Vector{Nothing} && (arg = nothing) + return arg +end + +function jl_convert_attr(n, t, attr) + if !(t isa Union) + if pyisinstance(attr, PythonCall.pybuiltins.list) + if eltype(t) isa Union + return [union_convert(eltype(t), attr_) for attr_ in attr] + else + return [pyconvert(eltype(t), attr_) for attr_ in attr] + end + else + return pyconvert(t, attr) + end + else + PythonCall.pyisnone(attr) && return nothing + return union_convert(t, attr) + end +end + +function jl_convert(::Type{T}, x::Py) where {T} + fts = fieldtypes(T) + fns = fieldnames(T) + args = Any[] + for (n, t) in zip(fns, fts) + attr = pygetattr(x, string(n)) + arg = jl_convert_attr(n, t, attr) + push!(args, arg) + end + PythonCall.pyconvert_return(T(args...)) +end + +function jl_convert(::Type{T}, x::Py) where {T<:AbstractIR} + fts = fieldtypes(T)[1:end-1] + fns = fieldnames(T)[1:end-1] + args = Any[] + for (n, t) in zip(fns, fts) + attr = pygetattr(x, string(n)) + arg = jl_convert_attr(n, t, attr) + push!(args, arg) + end + PythonCall.pyconvert_return(T(args..., pyconvert(String, pygetattr(x, "type")))) +end diff --git a/PyBraket/src/pyschema.jl b/PyBraket/src/pyschema.jl index c7918222..d98b5fb8 100644 --- a/PyBraket/src/pyschema.jl +++ b/PyBraket/src/pyschema.jl @@ -1,17 +1,17 @@ module PySchema -using PythonCall, Braket, Braket.IR -import Braket: DwaveTiming, GateModelQpuParadigmProperties, ResultTypeValue, OqcDeviceCapabilities, GateFidelity2Q, OneQubitProperties, AdditionalMetadata, DwaveAdvantageDeviceLevelParameters, IonqDeviceCapabilities, TwoQubitProperties, IonqDeviceParameters, NativeQuilMetadata, QueraDeviceCapabilities, ExecutionDay, StandardizedGateModelQpuDeviceProperties, XanaduDeviceCapabilities, DeviceExecutionWindow, DwaveDeviceParameters, CoherenceTime, DwaveMetadata, Frame, DeviceCost, Dwave2000QDeviceLevelParameters, FidelityType, QueraMetadata, OqcProviderProperties, DeviceServiceProperties, XanaduDeviceParameters, BlackbirdProgram, Geometry, Fidelity1Q, AnnealingTaskResult, AnalogHamiltonianSimulationShotResult, RigettiDeviceCapabilities, DwaveProviderProperties, DeviceActionProperties, DwaveProviderLevelParameters, JaqcdDeviceActionProperties, Direction, PulseDeviceActionProperties, BlackbirdDeviceActionProperties, PerformanceLattice, PerformanceRydberg, DeviceActionType, IonqProviderProperties, PersistedJobDataFormat, PhotonicModelTaskResult, DeviceDocumentation, XanaduProviderProperties, QubitDirection, ContinuousVariableQpuParadigmProperties, PulseFunctionArgument, DwaveAdvantageDeviceParameters, RigettiDeviceParameters, AnalogHamiltonianSimulationTaskResult, TaskMetadata, GateModelSimulatorParadigmProperties, GateModelTaskResult, RigettiProviderProperties, OqcDeviceParameters, DeviceConnectivity, PulseFunction, Rydberg, PerformanceRydbergGlobal, RydbergGlobal, GateModelSimulatorDeviceCapabilities, XanaduMetadata, GateModelParameters, Performance, GateModelSimulatorDeviceParameters, AnalogHamiltonianSimulationShotMeasurement, OqcMetadata, QueraAhsParadigmProperties, Lattice, PersistedJobData, DwaveDeviceCapabilities, 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, DensityMatrix, CPhaseShift00, ECR, CompilerDirective, CCNot, Unitary, BitFlip, Y, Swap, CZ, EndVerbatimBox, Program, CNot, AdjointGradient, CSwap, Ry, I, Si, AmplitudeDamping, StateVector, ISwap, H, XY, YY, T, TwoQubitDephasing, X, Ti, CV, StartVerbatimBox, PauliChannel, PSwap, Expectation, Probability, PhaseShift, V, CPhaseShift, S, Rx, Kraus, Amplitude, CPhaseShift10, MultiQubitPauliChannel, CY, Setup, Hamiltonian, ShiftingField, AtomArrangement, TimeSeries, PhysicalField, AHSProgram, DrivingField, AbstractProgramResult, IRObservable +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, DeviceCapabilities, 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 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 oqc_device_capabilities_v1 = PythonCall.pynew() -const standardized_gate_model_qpu_device_properties_v1 = 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() @@ -29,24 +29,25 @@ 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 annealing_task_result_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 atom_arrangement = PythonCall.pynew() -const dwave_provider_properties_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 driving_field = PythonCall.pynew() -const jaqcd_device_action_properties = 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 xanadu_provider_properties_v1 = 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() @@ -60,8 +61,8 @@ 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 oqc_metadata_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() @@ -71,108 +72,16 @@ const shared_models = PythonCall.pynew() const schema_header = PythonCall.pynew() const openqasm_device_action_properties = PythonCall.pynew() -function union_convert(::Type{IRObservable}, x) - PythonCall.pyisinstance(x, PythonCall.pybuiltins.str) && return pyconvert(String, x) - x_vec = Union{String, Vector{Vector{Vector{Float64}}}}[PythonCall.pyisinstance(x_, PythonCall.pybuiltins.str) ? pyconvert(String, x_) : pyconvert(Vector{Vector{Vector{Float64}}}, x_) for x_ in x] - return x_vec -end - -function union_convert(union_type, x) - union_ts = union_type isa Union ? Type[] : [union_type] - union_t = union_type - while union_t isa Union - union_t.a != Nothing && push!(union_ts, union_t.a) - !(union_t.b isa Union) && push!(union_ts, union_t.b) - union_t = union_t.b - end - arg = nothing - for t_ in union_ts - try - if pyisinstance(x, PythonCall.pybuiltins.list) && t_ <: Vector - return [union_convert(Union{eltype(t_)}, attr_) for attr_ in x] - elseif pyisinstance(x, pybuiltins.str) && t_ <: Integer - return tryparse(t_, pyconvert(String, x)) - elseif t_ == ResultTypeValue - if pyhasattr(x, "value") - typ = jl_convert(AbstractProgramResult, pygetattr(x, "type")) - val = union_convert(Union{Dict{String, ComplexF64}, Float64, Vector}, pygetattr(x, "value")) - return PythonCall.pyconvert_return(ResultTypeValue(typ, val)) - else - rt = jl_convert(AbstractProgramResult, x) - return PythonCall.pyconvert_return(ResultTypeValue(rt, 0.0)) - end - else - return pyconvert(t_, x) - end - catch e - end - end - arg isa Vector{Nothing} && (arg = nothing) - return arg -end - -function jl_convert_attr(n, t, attr) - if !(t isa Union) - if pyisinstance(attr, PythonCall.pybuiltins.list) - if eltype(t) isa Union - return [union_convert(eltype(t), attr_) for attr_ in attr] - else - return [pyconvert(eltype(t), attr_) for attr_ in attr] - end - else - return pyconvert(t, attr) - end - else - PythonCall.pyisnone(attr) && return nothing - return union_convert(t, attr) - end -end - -function jl_convert(::Type{T}, x::Py) where {T} - fts = fieldtypes(T) - fns = fieldnames(T) - args = Any[] - for (n, t) in zip(fns, fts) - attr = pygetattr(x, string(n)) - arg = jl_convert_attr(n, t, attr) - push!(args, arg) - end - PythonCall.pyconvert_return(T(args...)) +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 -function jl_convert(::Type{T}, x::Py) where {T<:AbstractIR} - fts = fieldtypes(T)[1:end-1] - fns = fieldnames(T)[1:end-1] - args = Any[] - for (n, t) in zip(fns, fts) - attr = pygetattr(x, string(n)) - arg = jl_convert_attr(n, t, attr) - push!(args, arg) - end - PythonCall.pyconvert_return(T(args..., pyconvert(String, pygetattr(x, "type")))) -end 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 jl_convert(::Type{AbstractProgramResult}, x::Py) - T_ = pyconvert(String, x.type) - T = Dict("adjoint_gradient"=>AdjointGradient, "expectation"=>Expectation, "variance"=>Variance, "statevector"=>StateVector, "densitymatrix"=>DensityMatrix, "sample"=>Sample, "amplitude"=>Amplitude, "probability"=>Probability) - return PythonCall.pyconvert_return(pyconvert(T[T_], x)) -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)), - (:(Braket.IR.AdjointGradient), :(pyjaqcd.AdjointGradient))) - @eval begin - Py(o::$irT) = $pyT(;arg_gen(o, fieldnames($irT))...) - end -end -=# + function __init__() PythonCall.pycopy!(instructions, pyimport("braket.ir.jaqcd.instructions")) @@ -180,9 +89,9 @@ function __init__() 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!(oqc_device_capabilities_v1, pyimport("braket.device_schema.oqc.oqc_device_capabilities_v1")) - PythonCall.pycopy!(standardized_gate_model_qpu_device_properties_v1, pyimport("braket.device_schema.standardized_gate_model_qpu_device_properties_v1")) 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")) @@ -200,29 +109,30 @@ function __init__() 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!(annealing_task_result_v1, pyimport("braket.task_result.annealing_task_result_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!(atom_arrangement, pyimport("braket.ir.ahs.atom_arrangement")) - PythonCall.pycopy!(dwave_provider_properties_v1, pyimport("braket.device_schema.dwave.dwave_provider_properties_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!(driving_field, pyimport("braket.ir.ahs.driving_field")) - PythonCall.pycopy!(jaqcd_device_action_properties, pyimport("braket.device_schema.jaqcd_device_action_properties")) 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!(xanadu_provider_properties_v1, pyimport("braket.device_schema.xanadu.xanadu_provider_properties_v1")) 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.jaqcd.program_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")) @@ -233,8 +143,8 @@ function __init__() 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!(oqc_metadata_v1, pyimport("braket.task_result.oqc_metadata_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")) @@ -244,20 +154,19 @@ function __init__() 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.device_schema.oqc.oqc_device_capabilities_v1:OqcDeviceCapabilities", OqcDeviceCapabilities, 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.task_result.additional_metadata:AdditionalMetadata", AdditionalMetadata, 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.ir.jaqcd.instructions:CPhaseShift01", CPhaseShift01, 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) @@ -265,89 +174,90 @@ function __init__() 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.ir.jaqcd.results:Expectation", Expectation, 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.ir.jaqcd.instructions:Rz", Rz, 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.task_result.dwave_metadata_v1:DwaveMetadata", DwaveMetadata, 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.ir.jaqcd.results:Probability", Probability, 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.ir.jaqcd.instructions:PhaseShift", PhaseShift, jl_convert) PythonCall.pyconvert_add_rule("braket.device_schema.xanadu.xanadu_device_parameters_v1:XanaduDeviceParameters", XanaduDeviceParameters, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:V", V, jl_convert) PythonCall.pyconvert_add_rule("braket.ir.blackbird.program_v1:BlackbirdProgram", BlackbirdProgram, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:XX", XX, 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.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.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.ir.ahs.atom_arrangement:AtomArrangement", AtomArrangement, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:ISwap", ISwap, jl_convert) - PythonCall.pyconvert_add_rule("braket.device_schema.dwave.dwave_provider_properties_v1:DwaveProviderProperties", DwaveProviderProperties, 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.ahs.driving_field:DrivingField", DrivingField, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:PhaseFlip", PhaseFlip, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:Vi", Vi, 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: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:XY", XY, 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.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: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:Depolarizing", Depolarizing, jl_convert) PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:CZ", CZ, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:EndVerbatimBox", EndVerbatimBox, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.ahs.time_series:TimeSeries", TimeSeries, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:YY", YY, jl_convert) PythonCall.pyconvert_add_rule("braket.device_schema.device_service_properties_v1:DeviceDocumentation", DeviceDocumentation, 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.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:TwoQubitDepolarizing", TwoQubitDepolarizing, jl_convert) PythonCall.pyconvert_add_rule("braket.ir.jaqcd.instructions:CNot", CNot, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.ahs.program_v1:AHSProgram", AHSProgram, jl_convert) - PythonCall.pyconvert_add_rule("braket.task_result.task_metadata_v1:TaskMetadata", TaskMetadata, 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.ir.jaqcd.results:DensityMatrix", DensityMatrix, 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) @@ -370,11 +280,11 @@ function __init__() 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.task_result.oqc_metadata_v1:OqcMetadata", OqcMetadata, 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.device_schema.dwave.dwave_device_capabilities_v1:DwaveDeviceCapabilities", DwaveDeviceCapabilities, 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) @@ -388,8 +298,8 @@ function __init__() 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.ir.jaqcd.shared_models:CompilerDirective", CompilerDirective, 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) @@ -397,18 +307,9 @@ function __init__() 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:Unitary", Unitary, 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.program_v1:Program", Program, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.program_v1:Program", AbstractProgram, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.jaqcd.program_v1:Program", AbstractProgram, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.openqasm.program_v1:OpenQasmProgram", AbstractProgram, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.openqasm.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.blackbird.program_v1:Program", AbstractProgram, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.ahs.program_v1:AHSProgram", AbstractProgram, jl_convert) - PythonCall.pyconvert_add_rule("braket.ir.ahs.program_v1:Program", AbstractProgram, 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) @@ -417,7 +318,16 @@ function __init__() 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/src/ahs.jl b/src/ahs.jl index f99a1639..9602a075 100644 --- a/src/ahs.jl +++ b/src/ahs.jl @@ -1,7 +1,5 @@ import StructTypes - - export AtomArrangementItem, AtomArrangement, TimeSeriesItem, TimeSeries, Field, DrivingField export ShiftingField, Hamiltonian, AnalogHamiltonianSimulation, Pattern, vacant, filled, SiteType, discretize diff --git a/src/aws_jobs.jl b/src/aws_jobs.jl index 45a14b7f..c5776573 100644 --- a/src/aws_jobs.jl +++ b/src/aws_jobs.jl @@ -29,10 +29,10 @@ Cancels the job `j`. cancel(j::AwsQuantumJob) = (r = BRAKET.cancel_job(HTTP.escapeuri(arn(j))); return nothing) function describe_log_streams(log_group::String, stream_prefix::String, limit::Int=-1, next_token::String="") - args = Dict{String, Any}("logStreamNamePrefix"=>stream_prefix, "orderBy"=>"LogStreamName") + args = Dict{String, Any}("logGroupName"=>log_group, "logStreamNamePrefix"=>stream_prefix, "orderBy"=>"LogStreamName") limit > 0 && (args["limit"] = limit) !isempty(next_token) && (args["nextToken"] = next_token) - return CLOUDWATCH_LOGS.describe_log_streams(log_group, args) + return CLOUDWATCH_LOGS.describe_log_streams(args) end """ @@ -55,7 +55,7 @@ function log_stream(ch::Channel, log_group::String, stream_name::String, start_t next_token = nothing event_count = 1 while event_count > 0 - response = CLOUDWATCH_LOGS.get_log_events(log_group, stream_name, Dict("startTime"=>start_time, "nextToken"=>next_token, "startFromHead"=>true)) + response = CLOUDWATCH_LOGS.get_log_events(stream_name, Dict("logGroupName"=>log_group, "startTime"=>start_time, "nextToken"=>next_token, "startFromHead"=>true)) next_token = response["nextForwardToken"] events = response["events"] event_count = length(events) diff --git a/src/gates.jl b/src/gates.jl index ba1714a0..84b754d3 100644 --- a/src/gates.jl +++ b/src/gates.jl @@ -5,31 +5,28 @@ export Gate,AngledGate,DoubleAngledGate,H,I,X,Y,Z,S,Si,T,Ti,V,Vi,CNot,Swap,ISwap Abstract type representing a quantum gate. """ abstract type Gate <: QuantumOperator end - StructTypes.StructType(::Type{Gate}) = StructTypes.AbstractType() - StructTypes.subtypes(::Type{Gate}) = (angledgate=AngledGate, doubleangledgate=DoubleAngledGate, h=H, i=I, x=X, y=Y, z=Z, s=S, si=Si, t=T, ti=Ti, v=V, vi=Vi, cnot=CNot, swap=Swap, iswap=ISwap, cv=CV, cy=CY, cz=CZ, ecr=ECR, ccnot=CCNot, cswap=CSwap, unitary=Unitary, rx=Rx, ry=Ry, rz=Rz, phaseshift=PhaseShift, pswap=PSwap, xy=XY, cphaseshift=CPhaseShift, cphaseshift00=CPhaseShift00, cphaseshift01=CPhaseShift01, cphaseshift10=CPhaseShift10, xx=XX, yy=YY, zz=ZZ, gpi=GPi, gpi2=GPi2, ms=MS) + """ AngledGate <: Gate Abstract type representing a quantum gate with an `angle` parameter. """ abstract type AngledGate <: Gate end - StructTypes.StructType(::Type{AngledGate}) = StructTypes.AbstractType() - StructTypes.subtypes(::Type{AngledGate}) = (rx=Rx, ry=Ry, rz=Rz, phaseshift=PhaseShift, pswap=PSwap, xy=XY, cphaseshift=CPhaseShift, cphaseshift00=CPhaseShift00, cphaseshift01=CPhaseShift01, cphaseshift10=CPhaseShift10, xx=XX, yy=YY, zz=ZZ, gpi=GPi, gpi2=GPi2) + """ DoubleAngledGate <: Gate Abstract type representing a quantum gate with two `angle` parameters. """ abstract type DoubleAngledGate <: Gate end - StructTypes.StructType(::Type{DoubleAngledGate}) = StructTypes.AbstractType() - -StructTypes.subtypes(::Type{DoubleAngledGate}) = (ms=MS,) -for (G, IRG, label, qc) in zip((:Rx, :Ry, :Rz, :PhaseShift, :PSwap, :XY, :CPhaseShift, :CPhaseShift00, :CPhaseShift01, :CPhaseShift10, :XX, :YY, :ZZ, :GPi, :GPi2), (:(IR.Rx), :(IR.Ry), :(IR.Rz), :(IR.PhaseShift), :(IR.PSwap), :(IR.XY), :(IR.CPhaseShift), :(IR.CPhaseShift00), :(IR.CPhaseShift01), :(IR.CPhaseShift10), :(IR.XX), :(IR.YY), :(IR.ZZ), :(IR.GPi), :(IR.GPi2)), ("rx", "ry", "rz", "phaseshift", "pswap", "xy", "cphaseshift", "cphaseshift00", "cphaseshift01", "cphaseshift10", "xx", "yy", "zz", "gpi", "gpi2"), (:1, :1, :1, :1, :2, :2, :2, :2, :2, :2, :2, :2, :2, :1, :1)) +StructTypes.subtypes(::Type{DoubleAngledGate}) = (ms=MS) + +for (G, IRG, label, qc, c) in zip((:Rx, :Ry, :Rz, :PhaseShift, :PSwap, :XY, :CPhaseShift, :CPhaseShift00, :CPhaseShift01, :CPhaseShift10, :XX, :YY, :ZZ, :GPi, :GPi2), (:(IR.Rx), :(IR.Ry), :(IR.Rz), :(IR.PhaseShift), :(IR.PSwap), :(IR.XY), :(IR.CPhaseShift), :(IR.CPhaseShift00), :(IR.CPhaseShift01), :(IR.CPhaseShift10), :(IR.XX), :(IR.YY), :(IR.ZZ), :(IR.GPi), :(IR.GPi2)), ("rx", "ry", "rz", "phaseshift", "pswap", "xy", "cphaseshift", "cphaseshift00", "cphaseshift01", "cphaseshift10", "xx", "yy", "zz", "gpi", "gpi2"), (:1, :1, :1, :1, :2, :2, :2, :2, :2, :2, :2, :2, :2, :1, :1), (["Rx(ang)"], ["Ry(ang)"], ["Rz(ang)"], ["PHASE(ang)"], ["PSWAP(ang)", "PSWAP(ang)"], ["XY(ang)", "XY(ang)"], ["C", "PHASE(ang)"], ["C", "PHASE00(ang)"], ["C", "PHASE01(ang)"], ["C", "PHASE10(ang)"], ["XX(ang)", "XX(ang)"], ["YY(ang)", "YY(ang)"], ["ZZ(ang)", "ZZ(ang)"], ["GPi(ang)"], ["GPi2(ang)"])) @eval begin @doc """ $($G) <: AngledGate @@ -40,6 +37,7 @@ for (G, IRG, label, qc) in zip((:Rx, :Ry, :Rz, :PhaseShift, :PSwap, :XY, :CPhase struct $G <: AngledGate angle::Union{Float64, FreeParameter} end + chars(g::$G) = map(char->replace(string(char), "ang"=>string(g.angle)), $c) qubit_count(g::$G) = $qc qubit_count(::Type{$G}) = $qc function ir(g::$G, target::QubitSet, ::Val{:JAQCD}; kwargs...) @@ -53,7 +51,7 @@ for (G, IRG, label, qc) in zip((:Rx, :Ry, :Rz, :PhaseShift, :PSwap, :XY, :CPhase end end end -for (G, IRG, label, qc) in zip((:MS,), (:(IR.MS),), ("ms",), (:2,)) +for (G, IRG, label, qc, c) in zip((:MS,), (:(IR.MS),), ("ms",), (:2,), (["MS(ang1, ang2)", "MS(ang1, ang2)"],)) @eval begin @doc """ $($G) <: DoubleAngledGate @@ -65,6 +63,7 @@ for (G, IRG, label, qc) in zip((:MS,), (:(IR.MS),), ("ms",), (:2,)) angle1::Union{Float64, FreeParameter} angle2::Union{Float64, FreeParameter} end + chars(g::$G) = map(char->replace(string(char), "ang1"=>string(g.angle1), "ang2"=>string(g.angle2)), $c) qubit_count(g::$G) = $qc qubit_count(::Type{$G}) = $qc function ir(g::$G, target::QubitSet, ::Val{:JAQCD}; kwargs...) @@ -78,7 +77,7 @@ for (G, IRG, label, qc) in zip((:MS,), (:(IR.MS),), ("ms",), (:2,)) end end end -for (G, IRG, label, qc) in zip((:H, :I, :X, :Y, :Z, :S, :Si, :T, :Ti, :V, :Vi, :CNot, :Swap, :ISwap, :CV, :CY, :CZ, :ECR, :CCNot, :CSwap), (:(IR.H), :(IR.I), :(IR.X), :(IR.Y), :(IR.Z), :(IR.S), :(IR.Si), :(IR.T), :(IR.Ti), :(IR.V), :(IR.Vi), :(IR.CNot), :(IR.Swap), :(IR.ISwap), :(IR.CV), :(IR.CY), :(IR.CZ), :(IR.ECR), :(IR.CCNot), :(IR.CSwap)), ("h", "i", "x", "y", "z", "s", "si", "t", "ti", "v", "vi", "cnot", "swap", "iswap", "cv", "cy", "cz", "ecr", "ccnot", "cswap"), (:1, :1, :1, :1, :1, :1, :1, :1, :1, :1, :1, :2, :2, :2, :2, :2, :2, :2, :3, :3)) +for (G, IRG, label, qc, c) in zip((:H, :I, :X, :Y, :Z, :S, :Si, :T, :Ti, :V, :Vi, :CNot, :Swap, :ISwap, :CV, :CY, :CZ, :ECR, :CCNot, :CSwap), (:(IR.H), :(IR.I), :(IR.X), :(IR.Y), :(IR.Z), :(IR.S), :(IR.Si), :(IR.T), :(IR.Ti), :(IR.V), :(IR.Vi), :(IR.CNot), :(IR.Swap), :(IR.ISwap), :(IR.CV), :(IR.CY), :(IR.CZ), :(IR.ECR), :(IR.CCNot), :(IR.CSwap)), ("h", "i", "x", "y", "z", "s", "si", "t", "ti", "v", "vi", "cnot", "swap", "iswap", "cv", "cy", "cz", "ecr", "ccnot", "cswap"), (:1, :1, :1, :1, :1, :1, :1, :1, :1, :1, :1, :2, :2, :2, :2, :2, :2, :2, :3, :3), (["H"], ["I"], ["X"], ["Y"], ["Z"], ["S"], ["Si"], ["T"], ["Ti"], ["V"], ["Vi"], ["C", "X"], ["SWAP", "SWAP"], ["ISWAP", "ISWAP"], ["C", "V"], ["C", "Y"], ["C", "Z"], ["ECR", "ECR"], ["C", "C", "X"], ["C", "SWAP", "SWAP"])) @eval begin @doc """ $($G) <: Gate @@ -87,6 +86,7 @@ for (G, IRG, label, qc) in zip((:H, :I, :X, :Y, :Z, :S, :Si, :T, :Ti, :V, :Vi, : $($G) gate. """ struct $G <: Gate end + chars(g::$G) = $c qubit_count(g::$G) = $qc qubit_count(::Type{$G}) = $qc function ir(g::$G, target::QubitSet, ::Val{:JAQCD}; kwargs...) @@ -110,9 +110,9 @@ struct Unitary <: Gate matrix::Matrix{ComplexF64} end Unitary(mat::Vector{Vector{Vector{Float64}}}) = Unitary(complex_matrix_from_ir(mat)) -Base.:(==)(u1::Unitary, u2::Unitary) = u1.matrix ≈ u2.matrix +Base.:(==)(u1::Unitary, u2::Unitary) = u1.matrix == u2.matrix qubit_count(g::Unitary) = convert(Int, log2(size(g.matrix, 1))) - +chars(g::Unitary) = ntuple(i->"U", qubit_count(g)) function ir(g::Unitary, target::QubitSet, ::Val{:JAQCD}; kwargs...) mat = complex_matrix_to_ir(g.matrix) t_c = target[1:convert(Int, log2(size(g.matrix, 1)))] @@ -154,39 +154,3 @@ function bind_value!(::Parametrized, g::G, params::Dict{Symbol, Number}) where { end ir(g::Gate, target::Int, args...) = ir(g, QubitSet(target), args...) Base.copy(g::G) where {G<:Gate} = G((copy(getproperty(g, fn)) for fn in fieldnames(G))...) - -for (G, c) in zip((:H, :I, :X, :Y, :Z, :S, :Si, :T, :Ti, :V, :Vi), ("H", "I", "X", "Y", "Z", "S", "Si", "T", "Ti", "V", "Vi")) - @eval begin - chars(g::$G) = ($c,) - end -end - -for (G, c) in zip((:PhaseShift, :Rx, :Ry, :Rz), ("Phase", "Rx", "Ry", "Rz")) - @eval begin - chars(g::$G) = ($c * "(" * string(g.angle) * ")",) - end -end - -for (G, cs) in zip((:CNot, :Swap, :ECR, :ISwap, :CV, :CY, :CZ), (("C", "X"), ("SWAP", "SWAP"), ("ECR", "ECR"), ("iSWAP", "iSWAP"), ("C", "V"), ("C", "Y"), ("C", "Z"))) - @eval begin - chars(g::$G) = $cs - end -end - -for (G, cs) in zip((:CCNot, :CSwap), (("C", "C", "X"), ("C", "SWAP", "SWAP"))) - @eval begin - chars(g::$G) = $cs - end -end - -for (G, c) in zip((:CPhaseShift, :CPhaseShift00, :CPhaseShift01, :CPhaseShift10), ("Phase", "Phase00", "Phase01", "Phase10")) - @eval begin - chars(g::$G) = ("C", $c * "(" * string(g.angle) * ")",) - end -end - -for (G, c) in zip((:XX, :YY, :ZZ, :PSwap), ("X", "Y", "Z", "PSwap")) - @eval begin - chars(g::$G) = ($c * "(" * string(g.angle) * ")",$c * "(" * string(g.angle) * ")") - end -end diff --git a/src/local_jobs.jl b/src/local_jobs.jl index f1f7317e..47c82408 100644 --- a/src/local_jobs.jl +++ b/src/local_jobs.jl @@ -8,7 +8,13 @@ mutable struct LocalJobContainer function LocalJobContainer(image_uri::String, create_job_args; config::AWSConfig=global_aws_config(), container_name::String="", container_code_path::String="/opt/ml/code", force_update::Bool=false) c = new(image_uri, container_name, container_code_path, Dict{String, String}(), "", config) c = start_container!(c, force_update) - finalizer(stop_container!, c) + finalizer(c) do c + # check that the container is still running + c_list = read(`docker container ls -q`, String) + stop_flag = occursin(first(c.container_name, 10), c_list) + stop_flag && read(Cmd(["docker", "stop", c.container_name]), String) + return + end return setup_container!(c, create_job_args) end end @@ -126,8 +132,8 @@ function run_local_job!(c::LocalJobContainer) entry_point_cmd = `docker exec $c_name printenv SAGEMAKER_PROGRAM` entry_program, err, code = capture_docker_cmd(entry_point_cmd) (isnothing(entry_program) || isempty(entry_program)) && throw(ErrorException("Start program not found. The specified container is not setup to run Braket Jobs. Please see setup instructions for creating your own containers.")) - env_list = reduce(vcat, ["-e", k*"="*v] for (k,v) in c.env) - cmd = Cmd(["docker", "exec", "-w", code_path, env_list..., c_name, "python", entry_program]) + env_list = String.(reduce(vcat, ["-e", k*"="*v] for (k,v) in c.env)) + cmd = Cmd(["docker", "exec", "-w", String(code_path), env_list..., String(c_name), "python", String(entry_program)]) proc_out, proc_err, code = capture_docker_cmd(cmd) if code == 0 c.run_log *= proc_out @@ -193,12 +199,6 @@ function start_container!(c::LocalJobContainer, force_update::Bool) return c end -function stop_container!(c::LocalJobContainer) - c_name = name(c) - proc_out, proc_err, code = capture_docker_cmd(`docker stop $c_name`) - return -end - function copy_from_container!(c::LocalJobContainer, src::String, dst::String) c_name = c.container_name cmd = `docker cp $c_name:$src $dst` diff --git a/src/noises.jl b/src/noises.jl index d1dce15d..ca86ce22 100644 --- a/src/noises.jl +++ b/src/noises.jl @@ -5,10 +5,9 @@ export Noise, Kraus, BitFlip, PhaseFlip, PauliChannel, AmplitudeDamping, PhaseDa Abstract type representing a quantum noise operation. """ abstract type Noise <: QuantumOperator end - StructTypes.StructType(::Type{Noise}) = StructTypes.AbstractType() - StructTypes.subtypes(::Type{Noise}) = (noise=Noise, kraus=Kraus, bit_flip=BitFlip, phase_flip=PhaseFlip, pauli_channel=PauliChannel, amplitude_damping=AmplitudeDamping, phase_damping=PhaseDamping, depolarizing=Depolarizing, two_qubit_dephasing=TwoQubitDephasing, two_qubit_depolarizing=TwoQubitDepolarizing, generalized_amplitude_damping=GeneralizedAmplitudeDamping, multi_qubit_pauli_channel=MultiQubitPauliChannel) + """ Kraus <: Noise @@ -19,7 +18,7 @@ struct Kraus <: Noise end Kraus(mats::Vector{Vector{Vector{Vector{Float64}}}}) = Kraus(complex_matrix_from_ir.(mats)) -Base.:(==)(k1::Kraus, k2::Kraus) = all(m1 ≈ m2 for (m1, m2) in zip(k1.matrices, k2.matrices)) +Base.:(==)(k1::Kraus, k2::Kraus) = k1.matrices == k2.matrices function ir(g::Kraus, target::QubitSet, ::Val{:JAQCD}; kwargs...) mats = complex_matrix_to_ir.(g.matrices) t_c = collect(target[1:convert(Int, log2(size(g.matrices[1], 1)))]) @@ -32,7 +31,7 @@ function ir(g::Kraus, target::QubitSet, ::Val{:OpenQASM}; serialization_properti return "#pragma braket noise kraus($ms) $t" end qubit_count(g::Kraus) = convert(Int, log2(size(g.matrices[1], 1))) -chars(g::Kraus) = ntuple(i->"KR", qubit_count(g)) +chars(n::Kraus) = ntuple(i->"KR", qubit_count(n)) """ BitFlip <: Noise @@ -45,7 +44,7 @@ end Parametrizable(g::BitFlip) = Parametrized() qubit_count(g::BitFlip) = 1 -chars(g::BitFlip) = ("BF(" * string(g.probability) * ")",) +chars(n::BitFlip) = map(char->replace(string(char), "prob"=>string(n.probability)), ("BF(prob)",)) """ PhaseFlip <: Noise @@ -58,8 +57,7 @@ end Parametrizable(g::PhaseFlip) = Parametrized() qubit_count(g::PhaseFlip) = 1 -chars(g::PhaseFlip) = ("PF(" * string(g.probability) * ")",) - +chars(n::PhaseFlip) = map(char->replace(string(char), "prob"=>string(n.probability)), ("PF(prob)",)) """ PauliChannel <: Noise @@ -74,7 +72,7 @@ end Parametrizable(g::PauliChannel) = Parametrized() qubit_count(g::PauliChannel) = 1 -chars(g::PauliChannel) = ("PC(" * join(string.([g.probX, g.probY, g.probZ]), ", ") * ")",) +chars(n::PauliChannel) = map(char->replace(string(char), "prob"=>join([string(n.probX), string(n.probY), string(n.probX)], ", ")), ("PC(prob)",)) """ AmplitudeDamping <: Noise @@ -87,8 +85,7 @@ end Parametrizable(g::AmplitudeDamping) = Parametrized() qubit_count(g::AmplitudeDamping) = 1 -chars(g::AmplitudeDamping) = ("AD(" * string(g.gamma) * ")",) - +chars(n::AmplitudeDamping) = map(char->replace(string(char), "prob"=>string(n.gamma)), ("AD(prob)",)) """ PhaseDamping <: Noise @@ -101,8 +98,7 @@ end Parametrizable(g::PhaseDamping) = Parametrized() qubit_count(g::PhaseDamping) = 1 -chars(g::PhaseDamping) = ("PD(" * string(g.gamma) * ")",) - +chars(n::PhaseDamping) = map(char->replace(string(char), "prob"=>string(n.gamma)), ("PD(prob)",)) """ Depolarizing <: Noise @@ -115,8 +111,7 @@ end Parametrizable(g::Depolarizing) = Parametrized() qubit_count(g::Depolarizing) = 1 -chars(g::Depolarizing) = ("DEPO(" * string(g.probability) * ")",) - +chars(n::Depolarizing) = map(char->replace(string(char), "prob"=>string(n.probability)), ("DEPO(prob)",)) """ TwoQubitDephasing <: Noise @@ -129,8 +124,7 @@ end Parametrizable(g::TwoQubitDephasing) = Parametrized() qubit_count(g::TwoQubitDephasing) = 2 -chars(g::TwoQubitDephasing) = ("DEPH(" * string(g.probability) * ")","DEPH(" * string(g.probability) * ")") - +chars(n::TwoQubitDephasing) = map(char->replace(string(char), "prob"=>string(n.probability)), ("DEPH(prob)", "DEPH(prob)")) """ TwoQubitDepolarizing <: Noise @@ -143,8 +137,7 @@ end Parametrizable(g::TwoQubitDepolarizing) = Parametrized() qubit_count(g::TwoQubitDepolarizing) = 2 -chars(g::TwoQubitDepolarizing) = ("DEPO(" * string(g.probability) * ")","DEPO(" * string(g.probability) * ")") - +chars(n::TwoQubitDepolarizing) = map(char->replace(string(char), "prob"=>string(n.probability)), ("DEPO(prob)", "DEPO(prob)")) """ GeneralizedAmplitudeDamping <: Noise @@ -158,8 +151,7 @@ end Parametrizable(g::GeneralizedAmplitudeDamping) = Parametrized() qubit_count(g::GeneralizedAmplitudeDamping) = 1 -chars(g::GeneralizedAmplitudeDamping) = ("GAD(" * string(g.probability) * ", " * string(g.gamma) * ")",) - +chars(n::GeneralizedAmplitudeDamping) = map(char->replace(string(char), "prob"=>join([string(n.gamma), string(n.probability)], ", ")), ("GAD(prob)",)) """ MultiQubitPauliChannel{N} <: Noise @@ -186,8 +178,7 @@ function MultiQubitPauliChannel(probabilities::Dict{String, <:Union{Float64, Fre return MultiQubitPauliChannel{N}(probabilities) end Base.:(==)(c1::MultiQubitPauliChannel{N}, c2::MultiQubitPauliChannel{M}) where {N,M} = N == M && c1.probabilities == c2.probabilities -chars(g::MultiQubitPauliChannel{N}) where {N} = ntuple(i->"PC_$N", N) - +chars(n::TwoQubitPauliChannel) = ("PC2", "PC2") for (N, IRN, label) in zip((:BitFlip, :PhaseFlip, :PauliChannel, :AmplitudeDamping, :PhaseDamping, :Depolarizing, :TwoQubitDephasing, :TwoQubitDepolarizing, :GeneralizedAmplitudeDamping), (:(IR.BitFlip), :(IR.PhaseFlip), :(IR.PauliChannel), :(IR.AmplitudeDamping), :(IR.PhaseDamping), :(IR.Depolarizing), :(IR.TwoQubitDephasing), :(IR.TwoQubitDepolarizing), :(IR.GeneralizedAmplitudeDamping)), ("bit_flip", "phase_flip", "pauli_channel", "amplitude_damping", "phase_damping", "depolarizing", "two_qubit_dephasing", "two_qubit_depolarizing", "generalized_amplitude_damping")) @eval begin function ir(n::$N, target::QubitSet, ::Val{:JAQCD}; kwargs...) diff --git a/src/raw_schema.jl b/src/raw_schema.jl index 6fd09665..39b11f59 100644 --- a/src/raw_schema.jl +++ b/src/raw_schema.jl @@ -1,16 +1,28 @@ using Dates, NamedTupleTools import StructTypes +const GateFidelityType = Dict{String, Union{String, Float64}} +const OneQubitType = Union{Float64, Vector{GateFidelityType}} +const TwoQubitType = Dict{String, Union{Float64, Dict{String, Int}}} +const QubitType = Dict{String, Union{OneQubitType, TwoQubitType}} + + StructTypes.StructType(::Type{Dec128}) = StructTypes.CustomStruct() StructTypes.lower(d::Dec128) = string(d) StructTypes.lowertype(::Type{Dec128}) = String StructTypes.constructfrom(::Type{Dec128}, x::Number) = Dec128(string(x)) StructTypes.constructfrom(s::StructTypes.CustomStruct, ::Type{Dec128}, x::String) = Dec128(x) abstract type BraketSchemaBase end - StructTypes.StructType(::Type{BraketSchemaBase}) = StructTypes.AbstractType() -StructTypes.subtypekey(::Type{BraketSchemaBase}) = :braketSchemaHeader +function bsh_f(raw_sym::Symbol) + raw = String(raw_sym) + v = eval(Meta.parse(raw)) + bsh = v["name"] * "_v" * v["version"] + return type_dict[bsh] +end +StructTypes.subtypes(::Type{BraketSchemaBase}) = StructTypes.SubTypeClosure(bsh_f) +StructTypes.subtypekey(::Type{BraketSchemaBase}) = :braketSchemaHeader struct braketSchemaHeader name::String @@ -35,6 +47,15 @@ struct DwaveTiming end StructTypes.StructType(::Type{DwaveTiming}) = StructTypes.UnorderedStruct() +@enum ProblemType qubo ising +ProblemTypeDict = Dict(string(inst)=>inst for inst in instances(ProblemType)) +Base.:(==)(x::ProblemType, y::String) = string(x) == y +Base.:(==)(x::String, y::ProblemType) = string(y) == x +abstract type AbstractProgram <: BraketSchemaBase end +StructTypes.StructType(::Type{AbstractProgram}) = StructTypes.AbstractType() +StructTypes.subtypes(::Type{AbstractProgram}) = StructTypes.SubTypeClosure(bsh_f) +StructTypes.subtypekey(::Type{AbstractProgram}) = :braketSchemaHeader + struct NativeQuilMetadata finalRewiring::Vector{Int} gateDepth::Int @@ -52,91 +73,80 @@ struct XanaduMetadata <: BraketSchemaBase compiledProgram::String end StructTypes.StructType(::Type{XanaduMetadata}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{XanaduMetadata}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.task_result.xanadu_metadata", "1")) + struct OqcMetadata <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader compiledProgram::String end StructTypes.StructType(::Type{OqcMetadata}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{OqcMetadata}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.task_result.oqc_metadata", "1")) + struct SimulatorMetadata <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader executionDuration::Int end StructTypes.StructType(::Type{SimulatorMetadata}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{SimulatorMetadata}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.task_result.simulator_metadata", "1")) + struct DwaveMetadata <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader activeVariables::Vector{Int} timing::DwaveTiming end StructTypes.StructType(::Type{DwaveMetadata}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{DwaveMetadata}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.task_result.dwave_metadata", "1")) + struct RigettiMetadata <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader nativeQuilMetadata::Union{Nothing, NativeQuilMetadata} compiledProgram::String end StructTypes.StructType(::Type{RigettiMetadata}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{RigettiMetadata}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.task_result.rigetti_metadata", "1")) + struct QueraMetadata <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader numSuccessfulShots::Int end StructTypes.StructType(::Type{QueraMetadata}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{QueraMetadata}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.task_result.quera_metadata", "1")) -abstract type AbstractProgram <: BraketSchemaBase end -StructTypes.StructType(::Type{AbstractProgram}) = StructTypes.AbstractType() -StructTypes.subtypekey(::Type{AbstractProgram}) = :braketSchemaHeader - -function abstract_program_f(raw_sym::Symbol) +abstract type DeviceActionProperties <: BraketSchemaBase end +StructTypes.StructType(::Type{DeviceActionProperties}) = StructTypes.AbstractType() +function dap_f(raw_sym::Symbol) raw = String(raw_sym) - v = eval(Meta.parse(raw)) - bsh = v["name"] * "_v" * v["version"] - return type_dict[bsh] + occursin("jaqcd", raw) && return JaqcdDeviceActionProperties + occursin("openqasm", raw) && return OpenQASMDeviceActionProperties + occursin("blackbird", raw) && return BlackbirdDeviceActionProperties + return GenericDeviceActionProperties end -StructTypes.subtypes(::Type{AbstractProgram}) = StructTypes.SubTypeClosure(abstract_program_f) - -const GateFidelityType = Dict{String, Union{String, Float64}} -const OneQubitType = Union{Float64, Vector{GateFidelityType}} -const TwoQubitType = Dict{String, Union{Float64, Dict{String, Int}}} -const QubitType = Dict{String, Union{OneQubitType, TwoQubitType}} - +StructTypes.subtypes(::Type{DeviceActionProperties}) = StructTypes.SubTypeClosure(dap_f) +StructTypes.subtypekey(::Type{DeviceActionProperties}) = :actionType module IR -import ..Braket: AbstractProgram, braketSchemaHeader, BraketSchemaBase +import ..Braket: AbstractProgram, braketSchemaHeader, ProblemType, BraketSchemaBase using DecFP, StructTypes export Program, AHSProgram, AbstractIR, AbstractProgramResult, CompilerDirective, IRObservable abstract type AbstractIR end StructTypes.StructType(::Type{AbstractIR}) = StructTypes.AbstractType() -StructTypes.subtypekey(::Type{AbstractIR}) = :type -StructTypes.subtypes(::Type{AbstractIR}) = (z=Z, sample=Sample, cphaseshift01=CPhaseShift01, phase_damping=PhaseDamping, rz=Rz, generalized_amplitude_damping=GeneralizedAmplitudeDamping, xx=XX, zz=ZZ, phase_flip=PhaseFlip, vi=Vi, depolarizing=Depolarizing, variance=Variance, two_qubit_depolarizing=TwoQubitDepolarizing, densitymatrix=DensityMatrix, cphaseshift00=CPhaseShift00, ecr=ECR, compilerdirective=CompilerDirective, ccnot=CCNot, unitary=Unitary, bit_flip=BitFlip, y=Y, swap=Swap, cz=CZ, cnot=CNot, adjoint_gradient=AdjointGradient, cswap=CSwap, ry=Ry, i=I, si=Si, amplitude_damping=AmplitudeDamping, statevector=StateVector, iswap=ISwap, h=H, xy=XY, yy=YY, t=T, two_qubit_dephasing=TwoQubitDephasing, x=X, ti=Ti, cv=CV, pauli_channel=PauliChannel, pswap=PSwap, ms=MS, gpi=GPi, gpi2=GPi2, expectation=Expectation, probability=Probability, phaseshift=PhaseShift, v=V, cphaseshift=CPhaseShift, s=S, rx=Rx, kraus=Kraus, amplitude=Amplitude, cphaseshift10=CPhaseShift10, multi_qubit_pauli_channel=MultiQubitPauliChannel, cy=CY, setup=Setup, hamiltonian=Hamiltonian, shiftingfield=ShiftingField, atomarrangement=AtomArrangement, timeseries=TimeSeries, physicalfield=PhysicalField, ahsprogram=AHSProgram, drivingfield=DrivingField, abstractprogramresult=AbstractProgramResult) +StructTypes.subtypes(::Type{AbstractIR}) = (z=Z, sample=Sample, cphaseshift01=CPhaseShift01, phase_damping=PhaseDamping, rz=Rz, generalized_amplitude_damping=GeneralizedAmplitudeDamping, xx=XX, zz=ZZ, phase_flip=PhaseFlip, vi=Vi, depolarizing=Depolarizing, variance=Variance, two_qubit_depolarizing=TwoQubitDepolarizing, densitymatrix=DensityMatrix, cphaseshift00=CPhaseShift00, ecr=ECR, ccnot=CCNot, unitary=Unitary, bit_flip=BitFlip, y=Y, swap=Swap, cz=CZ, cnot=CNot, adjoint_gradient=AdjointGradient, cswap=CSwap, ry=Ry, i=I, si=Si, amplitude_damping=AmplitudeDamping, statevector=StateVector, iswap=ISwap, h=H, xy=XY, yy=YY, t=T, ahsprogram=AHSProgram, two_qubit_dephasing=TwoQubitDephasing, x=X, ti=Ti, cv=CV, pauli_channel=PauliChannel, pswap=PSwap, expectation=Expectation, probability=Probability, phaseshift=PhaseShift, v=V, cphaseshift=CPhaseShift, s=S, rx=Rx, kraus=Kraus, amplitude=Amplitude, cphaseshift10=CPhaseShift10, multi_qubit_pauli_channel=MultiQubitPauliChannel, cy=CY, ms=MS, gpi=GPi, gpi2=GPi2) const IRObservable = Union{Vector{Union{String, Vector{Vector{Vector{Float64}}}}}, String} Base.convert(::Type{IRObservable}, v::Vector{String}) = convert(Vector{Union{String, Vector{Vector{Vector{Float64}}}}}, v) Base.convert(::Type{IRObservable}, s::String) = s Base.convert(::Type{IRObservable}, v::Vector{Vector{Vector{Vector{Float64}}}}) = convert(Vector{Union{String, Vector{Vector{Vector{Float64}}}}}, v) - abstract type CompilerDirective <: AbstractIR end - StructTypes.StructType(::Type{CompilerDirective}) = StructTypes.AbstractType() - -StructTypes.subtypes(::Type{CompilerDirective}) = (start_verbatim_box=StartVerbatimBox, end_verbatim_box=EndVerbatimBox) -abstract type AbstractProgramResult <: AbstractIR end +StructTypes.subtypes(::Type{CompilerDirective}) = (end_verbatim_box=EndVerbatimBox, start_verbatim_box=StartVerbatimBox) +abstract type AbstractProgramResult <: AbstractIR end StructTypes.StructType(::Type{AbstractProgramResult}) = StructTypes.AbstractType() - StructTypes.subtypes(::Type{AbstractProgramResult}) = (amplitude=Amplitude, expectation=Expectation, probability=Probability, sample=Sample, statevector=StateVector, densitymatrix=DensityMatrix, variance=Variance, adjoint_gradient=AdjointGradient) + struct AtomArrangement <: AbstractIR sites::Vector{Vector{Dec128}} filling::Vector{Int} @@ -178,23 +188,76 @@ struct Hamiltonian <: AbstractIR end StructTypes.StructType(::Type{Hamiltonian}) = StructTypes.UnorderedStruct() - - struct Z <: AbstractIR target::Int type::String end StructTypes.StructType(::Type{Z}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{Z}) = Dict{Symbol, Any}(:type => "z") + +struct Si <: AbstractIR + target::Int + type::String +end +StructTypes.StructType(::Type{Si}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{Si}) = Dict{Symbol, Any}(:type => "si") + +struct T <: AbstractIR + target::Int + type::String +end +StructTypes.StructType(::Type{T}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{T}) = Dict{Symbol, Any}(:type => "t") + +struct Program <: AbstractProgram + braketSchemaHeader::braketSchemaHeader + instructions::Vector{Any} + results::Union{Nothing, Vector{AbstractProgramResult}} + basis_rotation_instructions::Union{Nothing, Vector{Any}} +end +StructTypes.StructType(::Type{Program}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{Program}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.ir.jaqcd.program", "1")) + +struct AHSProgram <: AbstractProgram + braketSchemaHeader::braketSchemaHeader + setup::Setup + hamiltonian::Hamiltonian +end +StructTypes.StructType(::Type{AHSProgram}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{AHSProgram}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.ir.ahs.program", "1")) + +struct TwoQubitDepolarizing <: AbstractIR + probability::Float64 + targets::Vector{Int} + type::String +end +StructTypes.StructType(::Type{TwoQubitDepolarizing}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{TwoQubitDepolarizing}) = Dict{Symbol, Any}(:type => "two_qubit_depolarizing") + +struct CNot <: AbstractIR + control::Int + target::Int + type::String +end +StructTypes.StructType(::Type{CNot}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{CNot}) = Dict{Symbol, Any}(:type => "cnot") + struct Sample <: AbstractProgramResult - observable::IRObservable + observable::Union{Vector{Union{String, Vector{Vector{Vector{Float64}}}}}, String} targets::Union{Nothing, Vector{Int}} type::String end StructTypes.StructType(::Type{Sample}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{Sample}) = Dict{Symbol, Any}(:type => "sample") + +struct Kraus <: AbstractIR + targets::Vector{Int} + matrices::Vector{Vector{Vector{Vector{Float64}}}} + type::String +end +StructTypes.StructType(::Type{Kraus}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{Kraus}) = Dict{Symbol, Any}(:type => "kraus") + struct CPhaseShift01 <: AbstractIR angle::Float64 control::Int @@ -202,95 +265,102 @@ struct CPhaseShift01 <: AbstractIR type::String end StructTypes.StructType(::Type{CPhaseShift01}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{CPhaseShift01}) = Dict{Symbol, Any}(:type => "cphaseshift01") -struct PhaseDamping <: AbstractIR - gamma::Float64 - target::Int + +struct DensityMatrix <: AbstractProgramResult + targets::Union{Nothing, Vector{Int}} type::String end -StructTypes.StructType(::Type{PhaseDamping}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{DensityMatrix}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{DensityMatrix}) = Dict{Symbol, Any}(:type => "densitymatrix") -StructTypes.defaults(::Type{PhaseDamping}) = Dict{Symbol, Any}(:type => "phase_damping") -struct Rz <: AbstractIR +struct PSwap <: AbstractIR angle::Float64 - target::Int + targets::Vector{Int} type::String end -StructTypes.StructType(::Type{Rz}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{PSwap}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{PSwap}) = Dict{Symbol, Any}(:type => "pswap") -StructTypes.defaults(::Type{Rz}) = Dict{Symbol, Any}(:type => "rz") -struct GeneralizedAmplitudeDamping <: AbstractIR - probability::Float64 +struct GPi <: AbstractIR + angle::Float64 + target::Vector{Int} + type::String +end +StructTypes.StructType(::Type{GPi}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{GPi}) = Dict{Symbol, Any}(:type => "gpi") + +struct AmplitudeDamping <: AbstractIR gamma::Float64 target::Int type::String end -StructTypes.StructType(::Type{GeneralizedAmplitudeDamping}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{AmplitudeDamping}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{AmplitudeDamping}) = Dict{Symbol, Any}(:type => "amplitude_damping") -StructTypes.defaults(::Type{GeneralizedAmplitudeDamping}) = Dict{Symbol, Any}(:type => "generalized_amplitude_damping") -struct XX <: AbstractIR - angle::Float64 +struct TwoQubitDephasing <: AbstractIR + probability::Float64 targets::Vector{Int} type::String end -StructTypes.StructType(::Type{XX}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{TwoQubitDephasing}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{TwoQubitDephasing}) = Dict{Symbol, Any}(:type => "two_qubit_dephasing") -StructTypes.defaults(::Type{XX}) = Dict{Symbol, Any}(:type => "xx") -struct ZZ <: AbstractIR - angle::Float64 - targets::Vector{Int} +struct Expectation <: AbstractProgramResult + observable::Union{Vector{Union{String, Vector{Vector{Vector{Float64}}}}}, String} + targets::Union{Nothing, Vector{Int}} type::String end -StructTypes.StructType(::Type{ZZ}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{Expectation}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{Expectation}) = Dict{Symbol, Any}(:type => "expectation") -StructTypes.defaults(::Type{ZZ}) = Dict{Symbol, Any}(:type => "zz") -struct PhaseFlip <: AbstractIR - probability::Float64 - target::Int +struct GPi2 <: AbstractIR + angle::Float64 + target::Vector{Int} type::String end -StructTypes.StructType(::Type{PhaseFlip}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{GPi2}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{GPi2}) = Dict{Symbol, Any}(:type => "gpi2") -StructTypes.defaults(::Type{PhaseFlip}) = Dict{Symbol, Any}(:type => "phase_flip") -struct Vi <: AbstractIR +struct BitFlip <: AbstractIR + probability::Float64 target::Int type::String end -StructTypes.StructType(::Type{Vi}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{BitFlip}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{BitFlip}) = Dict{Symbol, Any}(:type => "bit_flip") -StructTypes.defaults(::Type{Vi}) = Dict{Symbol, Any}(:type => "vi") -struct Depolarizing <: AbstractIR - probability::Float64 - target::Int +struct Amplitude <: AbstractProgramResult + states::Vector{String} type::String end -StructTypes.StructType(::Type{Depolarizing}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{Amplitude}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{Amplitude}) = Dict{Symbol, Any}(:type => "amplitude") -StructTypes.defaults(::Type{Depolarizing}) = Dict{Symbol, Any}(:type => "depolarizing") -struct Variance <: AbstractProgramResult - observable::IRObservable - targets::Union{Nothing, Vector{Int}} +struct X <: AbstractIR + target::Int type::String end -StructTypes.StructType(::Type{Variance}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{X}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{X}) = Dict{Symbol, Any}(:type => "x") -StructTypes.defaults(::Type{Variance}) = Dict{Symbol, Any}(:type => "variance") -struct TwoQubitDepolarizing <: AbstractIR - probability::Float64 - targets::Vector{Int} +struct CPhaseShift10 <: AbstractIR + angle::Float64 + control::Int + target::Int type::String end -StructTypes.StructType(::Type{TwoQubitDepolarizing}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{CPhaseShift10}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{CPhaseShift10}) = Dict{Symbol, Any}(:type => "cphaseshift10") -StructTypes.defaults(::Type{TwoQubitDepolarizing}) = Dict{Symbol, Any}(:type => "two_qubit_depolarizing") -struct DensityMatrix <: AbstractProgramResult - targets::Union{Nothing, Vector{Int}} +struct PhaseDamping <: AbstractIR + gamma::Float64 + target::Int type::String end -StructTypes.StructType(::Type{DensityMatrix}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{PhaseDamping}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{PhaseDamping}) = Dict{Symbol, Any}(:type => "phase_damping") -StructTypes.defaults(::Type{DensityMatrix}) = Dict{Symbol, Any}(:type => "densitymatrix") struct CPhaseShift00 <: AbstractIR angle::Float64 control::Int @@ -298,358 +368,295 @@ struct CPhaseShift00 <: AbstractIR type::String end StructTypes.StructType(::Type{CPhaseShift00}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{CPhaseShift00}) = Dict{Symbol, Any}(:type => "cphaseshift00") -struct ECR <: AbstractIR - targets::Vector{Int} - type::String -end -StructTypes.StructType(::Type{ECR}) = StructTypes.UnorderedStruct() -StructTypes.defaults(::Type{ECR}) = Dict{Symbol, Any}(:type => "ecr") -struct CCNot <: AbstractIR - controls::Vector{Int} +struct Rz <: AbstractIR + angle::Float64 target::Int type::String end -StructTypes.StructType(::Type{CCNot}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{Rz}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{Rz}) = Dict{Symbol, Any}(:type => "rz") -StructTypes.defaults(::Type{CCNot}) = Dict{Symbol, Any}(:type => "ccnot") -struct Unitary <: AbstractIR +struct MultiQubitPauliChannel <: AbstractIR + probabilities::Dict{String, Float64} targets::Vector{Int} - matrix::Vector{Vector{Vector{Float64}}} type::String end -StructTypes.StructType(::Type{Unitary}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{MultiQubitPauliChannel}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{MultiQubitPauliChannel}) = Dict{Symbol, Any}(:type => "multi_qubit_pauli_channel") -StructTypes.defaults(::Type{Unitary}) = Dict{Symbol, Any}(:type => "unitary") -struct BitFlip <: AbstractIR - probability::Float64 +struct CV <: AbstractIR + control::Int target::Int type::String end -StructTypes.StructType(::Type{BitFlip}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{CV}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{CV}) = Dict{Symbol, Any}(:type => "cv") -StructTypes.defaults(::Type{BitFlip}) = Dict{Symbol, Any}(:type => "bit_flip") struct Y <: AbstractIR target::Int type::String end StructTypes.StructType(::Type{Y}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{Y}) = Dict{Symbol, Any}(:type => "y") -struct Swap <: AbstractIR - targets::Vector{Int} - type::String -end -StructTypes.StructType(::Type{Swap}) = StructTypes.UnorderedStruct() -StructTypes.defaults(::Type{Swap}) = Dict{Symbol, Any}(:type => "swap") -struct CZ <: AbstractIR - control::Int +struct Ti <: AbstractIR target::Int type::String end -StructTypes.StructType(::Type{CZ}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{Ti}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{Ti}) = Dict{Symbol, Any}(:type => "ti") -StructTypes.defaults(::Type{CZ}) = Dict{Symbol, Any}(:type => "cz") -struct EndVerbatimBox <: CompilerDirective +struct StartVerbatimBox <: CompilerDirective directive::String type::String end -StructTypes.StructType(::Type{EndVerbatimBox}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{StartVerbatimBox}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{StartVerbatimBox}) = Dict{Symbol, Any}(:directive => "StartVerbatimBox", :type => "start_verbatim_box") -StructTypes.defaults(::Type{EndVerbatimBox}) = Dict{Symbol, Any}(:directive => "EndVerbatimBox", :type => "end_verbatim_box") -struct Program <: AbstractProgram - braketSchemaHeader::braketSchemaHeader - instructions::Vector{Any} - results::Union{Nothing, Vector{AbstractProgramResult}} - basis_rotation_instructions::Union{Nothing, Vector{Any}} +struct Probability <: AbstractProgramResult + targets::Union{Nothing, Vector{Int}} + type::String end -StructTypes.StructType(::Type{Program}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{Probability}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{Probability}) = Dict{Symbol, Any}(:type => "probability") -StructTypes.defaults(::Type{Program}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.ir.jaqcd.program", "1")) -struct CNot <: AbstractIR - control::Int +struct GeneralizedAmplitudeDamping <: AbstractIR + probability::Float64 + gamma::Float64 target::Int type::String end -StructTypes.StructType(::Type{CNot}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{GeneralizedAmplitudeDamping}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{GeneralizedAmplitudeDamping}) = Dict{Symbol, Any}(:type => "generalized_amplitude_damping") -StructTypes.defaults(::Type{CNot}) = Dict{Symbol, Any}(:type => "cnot") -struct AdjointGradient <: AbstractProgramResult - parameters::Union{Nothing, Vector{String}} - observable::IRObservable - targets::Union{Nothing, Vector{Vector{Int}}} +struct MS <: AbstractIR + angle1::Float64 + angle2::Float64 + targets::Vector{Int} type::String end -StructTypes.StructType(::Type{AdjointGradient}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{MS}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{MS}) = Dict{Symbol, Any}(:type => "ms") -StructTypes.defaults(::Type{AdjointGradient}) = Dict{Symbol, Any}(:type => "adjoint_gradient") -struct CSwap <: AbstractIR - control::Int +struct ECR <: AbstractIR targets::Vector{Int} type::String end -StructTypes.StructType(::Type{CSwap}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{ECR}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{ECR}) = Dict{Symbol, Any}(:type => "ecr") -StructTypes.defaults(::Type{CSwap}) = Dict{Symbol, Any}(:type => "cswap") -struct Ry <: AbstractIR +struct PhaseShift <: AbstractIR angle::Float64 target::Int type::String end -StructTypes.StructType(::Type{Ry}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{PhaseShift}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{PhaseShift}) = Dict{Symbol, Any}(:type => "phaseshift") -StructTypes.defaults(::Type{Ry}) = Dict{Symbol, Any}(:type => "ry") -struct I <: AbstractIR +struct V <: AbstractIR target::Int type::String end -StructTypes.StructType(::Type{I}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{V}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{V}) = Dict{Symbol, Any}(:type => "v") -StructTypes.defaults(::Type{I}) = Dict{Symbol, Any}(:type => "i") -struct Si <: AbstractIR - target::Int +struct AdjointGradient <: AbstractProgramResult + parameters::Union{Nothing, Vector{String}} + observable::Union{Vector{Union{String, Vector{Vector{Vector{Float64}}}}}, String} + targets::Union{Nothing, Vector{Vector{Int}}} type::String end -StructTypes.StructType(::Type{Si}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{AdjointGradient}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{AdjointGradient}) = Dict{Symbol, Any}(:type => "adjoint_gradient") -StructTypes.defaults(::Type{Si}) = Dict{Symbol, Any}(:type => "si") -struct AmplitudeDamping <: AbstractIR - gamma::Float64 - target::Int +struct XX <: AbstractIR + angle::Float64 + targets::Vector{Int} type::String end -StructTypes.StructType(::Type{AmplitudeDamping}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{XX}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{XX}) = Dict{Symbol, Any}(:type => "xx") -StructTypes.defaults(::Type{AmplitudeDamping}) = Dict{Symbol, Any}(:type => "amplitude_damping") struct StateVector <: AbstractProgramResult type::String end StructTypes.StructType(::Type{StateVector}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{StateVector}) = Dict{Symbol, Any}(:type => "statevector") -struct ISwap <: AbstractIR - targets::Vector{Int} - type::String -end -StructTypes.StructType(::Type{ISwap}) = StructTypes.UnorderedStruct() - -StructTypes.defaults(::Type{ISwap}) = Dict{Symbol, Any}(:type => "iswap") -struct H <: AbstractIR - target::Int - type::String -end -StructTypes.StructType(::Type{H}) = StructTypes.UnorderedStruct() -StructTypes.defaults(::Type{H}) = Dict{Symbol, Any}(:type => "h") -struct XY <: AbstractIR +struct ZZ <: AbstractIR angle::Float64 targets::Vector{Int} type::String end -StructTypes.StructType(::Type{XY}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{ZZ}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{ZZ}) = Dict{Symbol, Any}(:type => "zz") -StructTypes.defaults(::Type{XY}) = Dict{Symbol, Any}(:type => "xy") -struct YY <: AbstractIR - angle::Float64 +struct Swap <: AbstractIR targets::Vector{Int} type::String end -StructTypes.StructType(::Type{YY}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{Swap}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{Swap}) = Dict{Symbol, Any}(:type => "swap") -StructTypes.defaults(::Type{YY}) = Dict{Symbol, Any}(:type => "yy") -struct T <: AbstractIR - target::Int +struct ISwap <: AbstractIR + targets::Vector{Int} type::String end -StructTypes.StructType(::Type{T}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{ISwap}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{ISwap}) = Dict{Symbol, Any}(:type => "iswap") -StructTypes.defaults(::Type{T}) = Dict{Symbol, Any}(:type => "t") -struct TwoQubitDephasing <: AbstractIR - probability::Float64 +struct CSwap <: AbstractIR + control::Int targets::Vector{Int} type::String end -StructTypes.StructType(::Type{TwoQubitDephasing}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{CSwap}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{CSwap}) = Dict{Symbol, Any}(:type => "cswap") -StructTypes.defaults(::Type{TwoQubitDephasing}) = Dict{Symbol, Any}(:type => "two_qubit_dephasing") -struct X <: AbstractIR +struct PhaseFlip <: AbstractIR + probability::Float64 target::Int type::String end -StructTypes.StructType(::Type{X}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{PhaseFlip}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{PhaseFlip}) = Dict{Symbol, Any}(:type => "phase_flip") -StructTypes.defaults(::Type{X}) = Dict{Symbol, Any}(:type => "x") -struct Ti <: AbstractIR +struct Vi <: AbstractIR target::Int type::String end -StructTypes.StructType(::Type{Ti}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{Vi}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{Vi}) = Dict{Symbol, Any}(:type => "vi") -StructTypes.defaults(::Type{Ti}) = Dict{Symbol, Any}(:type => "ti") -struct CV <: AbstractIR - control::Int +struct H <: AbstractIR target::Int type::String end -StructTypes.StructType(::Type{CV}) = StructTypes.UnorderedStruct() - -StructTypes.defaults(::Type{CV}) = Dict{Symbol, Any}(:type => "cv") -struct StartVerbatimBox <: CompilerDirective - directive::String - type::String -end -StructTypes.StructType(::Type{StartVerbatimBox}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{H}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{H}) = Dict{Symbol, Any}(:type => "h") -StructTypes.defaults(::Type{StartVerbatimBox}) = Dict{Symbol, Any}(:directive => "StartVerbatimBox", :type => "start_verbatim_box") -struct PauliChannel <: AbstractIR - probX::Float64 - probY::Float64 - probZ::Float64 +struct CPhaseShift <: AbstractIR + angle::Float64 + control::Int target::Int type::String end -StructTypes.StructType(::Type{PauliChannel}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{CPhaseShift}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{CPhaseShift}) = Dict{Symbol, Any}(:type => "cphaseshift") -StructTypes.defaults(::Type{PauliChannel}) = Dict{Symbol, Any}(:type => "pauli_channel") -struct PSwap <: AbstractIR +struct XY <: AbstractIR angle::Float64 targets::Vector{Int} type::String end -StructTypes.StructType(::Type{PSwap}) = StructTypes.UnorderedStruct() - -StructTypes.defaults(::Type{PSwap}) = Dict{Symbol, Any}(:type => "pswap") - -struct MS <: AbstractIR - angle1::Float64 - angle2::Float64 - targets::Vector{Int} - type::String -end -StructTypes.StructType(::Type{MS}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{XY}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{XY}) = Dict{Symbol, Any}(:type => "xy") -struct GPi <: AbstractIR - angle::Float64 +struct CY <: AbstractIR + control::Int target::Int type::String end -StructTypes.StructType(::Type{GPi}) = StructTypes.UnorderedStruct() - -StructTypes.defaults(::Type{GPi}) = Dict{Symbol, Any}(:type => "gpi") +StructTypes.StructType(::Type{CY}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{CY}) = Dict{Symbol, Any}(:type => "cy") -struct GPi2 <: AbstractIR +struct Ry <: AbstractIR angle::Float64 target::Int type::String end -StructTypes.StructType(::Type{GPi2}) = StructTypes.UnorderedStruct() - -StructTypes.defaults(::Type{GPi2}) = Dict{Symbol, Any}(:type => "gpi2") -struct Expectation <: AbstractProgramResult - observable::IRObservable - targets::Union{Nothing, Vector{Int}} - type::String -end -StructTypes.StructType(::Type{Expectation}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{Ry}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{Ry}) = Dict{Symbol, Any}(:type => "ry") -StructTypes.defaults(::Type{Expectation}) = Dict{Symbol, Any}(:type => "expectation") -struct Probability <: AbstractProgramResult - targets::Union{Nothing, Vector{Int}} +struct CCNot <: AbstractIR + controls::Vector{Int} + target::Int type::String end -StructTypes.StructType(::Type{Probability}) = StructTypes.UnorderedStruct() - -StructTypes.defaults(::Type{Probability}) = Dict{Symbol, Any}(:type => "probability") -struct PhaseShift <: AbstractIR - angle::Float64 +StructTypes.StructType(::Type{CCNot}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{CCNot}) = Dict{Symbol, Any}(:type => "ccnot") + +struct PauliChannel <: AbstractIR + probX::Float64 + probY::Float64 + probZ::Float64 target::Int type::String end -StructTypes.StructType(::Type{PhaseShift}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{PauliChannel}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{PauliChannel}) = Dict{Symbol, Any}(:type => "pauli_channel") -StructTypes.defaults(::Type{PhaseShift}) = Dict{Symbol, Any}(:type => "phaseshift") -struct V <: AbstractIR - target::Int +struct Unitary <: AbstractIR + targets::Vector{Int} + matrix::Vector{Vector{Vector{Float64}}} type::String end -StructTypes.StructType(::Type{V}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{Unitary}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{Unitary}) = Dict{Symbol, Any}(:type => "unitary") -StructTypes.defaults(::Type{V}) = Dict{Symbol, Any}(:type => "v") -struct CPhaseShift <: AbstractIR - angle::Float64 - control::Int +struct I <: AbstractIR target::Int type::String end -StructTypes.StructType(::Type{CPhaseShift}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{I}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{I}) = Dict{Symbol, Any}(:type => "i") -StructTypes.defaults(::Type{CPhaseShift}) = Dict{Symbol, Any}(:type => "cphaseshift") struct S <: AbstractIR target::Int type::String end StructTypes.StructType(::Type{S}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{S}) = Dict{Symbol, Any}(:type => "s") -struct Rx <: AbstractIR - angle::Float64 + +struct Depolarizing <: AbstractIR + probability::Float64 target::Int type::String end -StructTypes.StructType(::Type{Rx}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{Depolarizing}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{Depolarizing}) = Dict{Symbol, Any}(:type => "depolarizing") -StructTypes.defaults(::Type{Rx}) = Dict{Symbol, Any}(:type => "rx") -struct Kraus <: AbstractIR - targets::Vector{Int} - matrices::Vector{Vector{Vector{Vector{Float64}}}} +struct CZ <: AbstractIR + control::Int + target::Int type::String end -StructTypes.StructType(::Type{Kraus}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{CZ}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{CZ}) = Dict{Symbol, Any}(:type => "cz") -StructTypes.defaults(::Type{Kraus}) = Dict{Symbol, Any}(:type => "kraus") -struct Amplitude <: AbstractProgramResult - states::Vector{String} +struct EndVerbatimBox <: CompilerDirective + directive::String type::String end -StructTypes.StructType(::Type{Amplitude}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{EndVerbatimBox}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{EndVerbatimBox}) = Dict{Symbol, Any}(:directive => "EndVerbatimBox", :type => "end_verbatim_box") -StructTypes.defaults(::Type{Amplitude}) = Dict{Symbol, Any}(:type => "amplitude") -struct CPhaseShift10 <: AbstractIR +struct YY <: AbstractIR angle::Float64 - control::Int - target::Int - type::String -end -StructTypes.StructType(::Type{CPhaseShift10}) = StructTypes.UnorderedStruct() - -StructTypes.defaults(::Type{CPhaseShift10}) = Dict{Symbol, Any}(:type => "cphaseshift10") -struct MultiQubitPauliChannel <: AbstractIR - probabilities::Dict{String, Float64} targets::Vector{Int} type::String end -StructTypes.StructType(::Type{MultiQubitPauliChannel}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{YY}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{YY}) = Dict{Symbol, Any}(:type => "yy") -StructTypes.defaults(::Type{MultiQubitPauliChannel}) = Dict{Symbol, Any}(:type => "multi_qubit_pauli_channel") -struct CY <: AbstractIR - control::Int +struct Rx <: AbstractIR + angle::Float64 target::Int type::String end -StructTypes.StructType(::Type{CY}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{Rx}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{Rx}) = Dict{Symbol, Any}(:type => "rx") -StructTypes.defaults(::Type{CY}) = Dict{Symbol, Any}(:type => "cy") -struct AHSProgram <: AbstractProgram - braketSchemaHeader::braketSchemaHeader - setup::Setup - hamiltonian::Hamiltonian +struct Variance <: AbstractProgramResult + observable::Union{Vector{Union{String, Vector{Vector{Vector{Float64}}}}}, String} + targets::Union{Nothing, Vector{Int}} + type::String end -StructTypes.StructType(::Type{AHSProgram}) = StructTypes.UnorderedStruct() +StructTypes.StructType(::Type{Variance}) = StructTypes.UnorderedStruct() +StructTypes.defaults(::Type{Variance}) = Dict{Symbol, Any}(:type => "variance") -StructTypes.defaults(::Type{AHSProgram}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.ir.ahs.program", "1")) abstract type Control end @@ -665,17 +672,19 @@ for g in [:CCNot] Control(::Type{$g}) = DoubleControl() end end +struct NoControl <: Control end +Control(::Type{G}) where {G<:AbstractIR} = NoControl() abstract type Target end -struct SingleTarget <: Target end -for g in [:H, :I, :X, :Y, :Z, :Rx, :Ry, :Rz, :S, :T, :Si, :Ti, :PhaseShift, :CPhaseShift, :CPhaseShift00, :CPhaseShift01, :CPhaseShift10, :CNot, :CCNot, :CV, :CY, :CZ, :V, :Vi, :GPi, :GPi2, :BitFlip, :PhaseFlip, :PauliChannel, :Depolarizing, :AmplitudeDamping, :GeneralizedAmplitudeDamping, :PhaseDamping] +struct DoubleTarget <: Target end +for g in [:Swap, :CSwap, :ISwap, :PSwap, :XY, :ECR, :XX, :YY, :ZZ, :TwoQubitDepolarizing, :TwoQubitDephasing, :MS] @eval begin - Target(::Type{$g}) = SingleTarget() + Target(::Type{$g}) = DoubleTarget() end end -struct OptionalMultiTarget <: Target end -for g in [:Expectation, :Sample, :Variance, :DensityMatrix, :Probability] +struct SingleTarget <: Target end +for g in [:H, :I, :X, :Y, :Z, :Rx, :Ry, :Rz, :S, :T, :Si, :Ti, :PhaseShift, :CPhaseShift, :CPhaseShift00, :CPhaseShift01, :CPhaseShift10, :CNot, :CCNot, :CV, :CY, :CZ, :V, :Vi, :BitFlip, :PhaseFlip, :PauliChannel, :Depolarizing, :AmplitudeDamping, :GeneralizedAmplitudeDamping, :PhaseDamping, :GPi, :GPi2] @eval begin - Target(::Type{$g}) = OptionalMultiTarget() + Target(::Type{$g}) = SingleTarget() end end struct OptionalNestedMultiTarget <: Target end @@ -684,10 +693,10 @@ for g in [:AdjointGradient] Target(::Type{$g}) = OptionalNestedMultiTarget() end end -struct DoubleTarget <: Target end -for g in [:Swap, :CSwap, :ISwap, :PSwap, :XY, :ECR, :XX, :YY, :ZZ, :MS, :TwoQubitDepolarizing, :TwoQubitDephasing] +struct OptionalMultiTarget <: Target end +for g in [:Expectation, :Sample, :Variance, :DensityMatrix, :Probability] @eval begin - Target(::Type{$g}) = DoubleTarget() + Target(::Type{$g}) = OptionalMultiTarget() end end struct MultiTarget <: Target end @@ -696,45 +705,53 @@ for g in [:Unitary, :MultiQubitPauliChannel, :Kraus] Target(::Type{$g}) = MultiTarget() end end -struct NoControl <: Control end - -Control(T) = NoControl() -ControlAndTarget(T) = (Control(T), Target(T)) -_generate_control_and_target(::NoControl, ::SingleTarget, q) = q[1] -_generate_control_and_target(::NoControl, ::DoubleTarget, q) = ([q[1], q[2]],) -_generate_control_and_target(::NoControl, ::MultiTarget, q) = (q,) -_generate_control_and_target(::SingleControl, ::SingleTarget, q) = (q[1], q[2]) -_generate_control_and_target(::SingleControl, ::DoubleTarget, q) = (q[1], [q[2], q[3]]) -_generate_control_and_target(::DoubleControl, ::SingleTarget, q) = ([q[1], q[2]], q[3]) abstract type Angle end -struct DoubleAngled <: Angle end struct Angled <: Angle end -struct NonAngled <: Angle end for g in [:Rx, :Ry, :Rz, :PhaseShift, :CPhaseShift, :CPhaseShift00, :CPhaseShift01, :CPhaseShift10, :PSwap, :XY, :XX, :YY, :ZZ, :GPi, :GPi2] @eval begin Angle(::Type{$g}) = Angled() end end +struct DoubleAngled <: Angle end for g in [:MS] @eval begin Angle(::Type{$g}) = DoubleAngled() end end +struct NonAngled <: Angle end Angle(::Type{G}) where {G<:AbstractIR} = NonAngled() abstract type ProbabilityCount end -struct SingleProbability <: ProbabilityCount end -struct DoubleProbability <: ProbabilityCount end struct TripleProbability <: ProbabilityCount end +for g in [:PauliChannel] + @eval begin + ProbabilityCount(::Type{$g}) = TripleProbability() + end +end struct MultiProbability <: ProbabilityCount end -for g in [:BitFlip, :PhaseFlip, :Depolarizing, :TwoQubitDephasing, :TwoQubitDepolarizing, :PhaseDamping, :AmplitudeDamping] +for g in [:MultiQubitPauliChannel, :Kraus] + @eval begin + ProbabilityCount(::Type{$g}) = MultiProbability() + end +end +struct DoubleProbability <: ProbabilityCount end +for g in [:GeneralizedAmplitudeDamping] + @eval begin + ProbabilityCount(::Type{$g}) = DoubleProbability() + end +end +struct SingleProbability <: ProbabilityCount end +for g in [:BitFlip, :PhaseFlip, :Depolarizing, :TwoQubitDephasing, :TwoQubitDepolarizing, :AmplitudeDamping] @eval begin ProbabilityCount(::Type{$g}) = SingleProbability() end end -ProbabilityCount(::Type{GeneralizedAmplitudeDamping}) = DoubleProbability() -ProbabilityCount(::Type{PauliChannel}) = TripleProbability() -ProbabilityCount(::Type{MultiQubitPauliChannel}) = MultiProbability() -ProbabilityCount(::Type{Kraus}) = MultiProbability() +ControlAndTarget(T) = (Control(T), Target(T)) +_generate_control_and_target(::NoControl, ::SingleTarget, q) = q[1] +_generate_control_and_target(::NoControl, ::DoubleTarget, q) = ([q[1], q[2]],) +_generate_control_and_target(::NoControl, ::MultiTarget, q) = (q,) +_generate_control_and_target(::SingleControl, ::SingleTarget, q) = (q[1], q[2]) +_generate_control_and_target(::SingleControl, ::DoubleTarget, q) = (q[1], [q[2], q[3]]) +_generate_control_and_target(::DoubleControl, ::SingleTarget, q) = ([q[1], q[2]], q[3]) Base.:(==)(o1::T, o2::T) where {T<:AbstractIR} = all(getproperty(o1, fn) == getproperty(o2, fn) for fn in fieldnames(T)) @@ -742,7 +759,14 @@ Base.:(==)(o1::T, o2::T) where {T<:AbstractIR} = all(getproperty(o1, fn) == getp end # module using .IR - +@enum _CopyMode always if_needed never +_CopyModeDict = Dict(string(inst)=>inst for inst in instances(_CopyMode)) +Base.:(==)(x::_CopyMode, y::String) = string(x) == y +Base.:(==)(x::String, y::_CopyMode) = string(y) == x +@enum Extra allow ignore forbid +ExtraDict = Dict(string(inst)=>inst for inst in instances(Extra)) +Base.:(==)(x::Extra, y::String) = string(x) == y +Base.:(==)(x::String, y::Extra) = string(y) == x @enum SafeUUID safe unsafe unknown SafeUUIDDict = Dict(string(inst)=>inst for inst in instances(SafeUUID)) Base.:(==)(x::SafeUUID, y::String) = string(x) == y @@ -751,10 +775,6 @@ Base.:(==)(x::String, y::SafeUUID) = string(y) == x PaymentCardBrandDict = Dict(string(inst)=>inst for inst in instances(PaymentCardBrand)) Base.:(==)(x::PaymentCardBrand, y::String) = string(x) == y Base.:(==)(x::String, y::PaymentCardBrand) = string(y) == x -@enum Extra allow ignore forbid -ExtraDict = Dict(string(inst)=>inst for inst in instances(Extra)) -Base.:(==)(x::Extra, y::String) = string(x) == y -Base.:(==)(x::String, y::Extra) = string(y) == x @enum Protocol json pickle ProtocolDict = Dict(string(inst)=>inst for inst in instances(Protocol)) Base.:(==)(x::Protocol, y::String) = string(x) == y @@ -783,28 +803,10 @@ Base.:(==)(x::String, y::ResultFormat) = string(y) == x DirectionDict = Dict(string(inst)=>inst for inst in instances(Direction)) Base.:(==)(x::Direction, y::String) = string(x) == y Base.:(==)(x::String, y::Direction) = string(y) == x -@enum ProblemType qubo ising -ProblemTypeDict = Dict(string(inst)=>inst for inst in instances(ProblemType)) -Base.:(==)(x::ProblemType, y::String) = string(x) == y -Base.:(==)(x::String, y::ProblemType) = string(y) == x @enum PersistedJobDataFormat plaintext pickled_v4 PersistedJobDataFormatDict = Dict(string(inst)=>inst for inst in instances(PersistedJobDataFormat)) Base.:(==)(x::PersistedJobDataFormat, y::String) = string(x) == y Base.:(==)(x::String, y::PersistedJobDataFormat) = string(y) == x -abstract type DeviceActionProperties end - -StructTypes.StructType(::Type{DeviceActionProperties}) = StructTypes.AbstractType() -StructTypes.subtypekey(::Type{DeviceActionProperties}) = :actionType - -function dap_f(raw_sym::Symbol) - raw = String(raw_sym) - occursin("jaqcd", raw) && return JaqcdDeviceActionProperties - occursin("openqasm", raw) && return OpenQASMDeviceActionProperties - occursin("blackbird", raw) && return BlackbirdDeviceActionProperties - return GenericDeviceActionProperties -end -StructTypes.subtypes(::Type{DeviceActionProperties}) = StructTypes.SubTypeClosure(dap_f) - struct ResultType name::String observables::Union{Nothing, Vector{String}} @@ -910,8 +912,8 @@ struct PulseFunctionArgument description::Union{Nothing, String} end StructTypes.StructType(::Type{PulseFunctionArgument}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{PulseFunctionArgument}) = Dict{Symbol, Any}(:optional => false) + struct PulseFunction functionName::String arguments::Vector{PulseFunctionArgument} @@ -1019,7 +1021,7 @@ StructTypes.StructType(::Type{ResultTypeValue}) = StructTypes.UnorderedStruct() struct BlackbirdDeviceActionProperties <: DeviceActionProperties version::Vector{String} actionType::String - supportedOperations::Vector{String} + supportedOperations::Union{Nothing, Vector{String}} supportedResultTypes::Vector{ResultType} end StructTypes.StructType(::Type{BlackbirdDeviceActionProperties}) = StructTypes.UnorderedStruct() @@ -1051,8 +1053,8 @@ struct OpenQASMDeviceActionProperties <: DeviceActionProperties supportedResultTypes::Union{Nothing, Vector{ResultType}} end StructTypes.StructType(::Type{OpenQASMDeviceActionProperties}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{OpenQASMDeviceActionProperties}) = Dict{Symbol, Any}(:supportsUnassignedMeasurements => true, :requiresAllQubitsMeasurement => false, :supportedPragmas => Any[], :supportPhysicalQubits => false, :supportsPartialVerbatimBox => true, :forbiddenPragmas => Any[], :requiresContiguousQubitIndices => false, :disabledQubitRewiringSupported => false, :forbiddenArrayOperations => Any[]) + struct ContinuousVariableQpuParadigmProperties <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader modes::Dict{String, Float64} @@ -1065,8 +1067,8 @@ struct ContinuousVariableQpuParadigmProperties <: BraketSchemaBase target::String end StructTypes.StructType(::Type{ContinuousVariableQpuParadigmProperties}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{ContinuousVariableQpuParadigmProperties}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.continuous_variable_qpu_paradigm_properties", "1")) + struct DeviceServiceProperties <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader executionWindows::Vector{DeviceExecutionWindow} @@ -1078,16 +1080,16 @@ struct DeviceServiceProperties <: BraketSchemaBase getTaskPollIntervalMillis::Union{Nothing, Int} end StructTypes.StructType(::Type{DeviceServiceProperties}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{DeviceServiceProperties}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.device_service_properties", "1")) + struct GateModelParameters <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader qubitCount::Int disableQubitRewiring::Bool end StructTypes.StructType(::Type{GateModelParameters}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{GateModelParameters}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.gate_model_parameters", "1"), :disableQubitRewiring => false) + struct GateModelQpuParadigmProperties <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader connectivity::DeviceConnectivity @@ -1095,16 +1097,16 @@ struct GateModelQpuParadigmProperties <: BraketSchemaBase nativeGateSet::Vector{String} end StructTypes.StructType(::Type{GateModelQpuParadigmProperties}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{GateModelQpuParadigmProperties}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.gate_model_qpu_paradigm_properties", "1")) + struct StandardizedGateModelQpuDeviceProperties <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader oneQubitProperties::Dict{String, OneQubitProperties} twoQubitProperties::Dict{String, TwoQubitProperties} end StructTypes.StructType(::Type{StandardizedGateModelQpuDeviceProperties}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{StandardizedGateModelQpuDeviceProperties}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.standardized_gate_model_qpu_device_properties", "1")) + struct DwaveProviderLevelParameters <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader annealingOffsets::Union{Nothing, Vector{Float64}} @@ -1126,8 +1128,8 @@ struct DwaveProviderLevelParameters <: BraketSchemaBase spinReversalTransformCount::Union{Nothing, Int} end StructTypes.StructType(::Type{DwaveProviderLevelParameters}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{DwaveProviderLevelParameters}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.dwave.dwave_provider_level_parameters", "1")) + struct Dwave2000QDeviceLevelParameters <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader annealingOffsets::Union{Nothing, Vector{Float64}} @@ -1149,15 +1151,15 @@ struct Dwave2000QDeviceLevelParameters <: BraketSchemaBase spinReversalTransformCount::Union{Nothing, Int} end StructTypes.StructType(::Type{Dwave2000QDeviceLevelParameters}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{Dwave2000QDeviceLevelParameters}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.dwave.dwave_2000Q_device_level_parameters", "1")) + struct Dwave2000QDeviceParameters <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader deviceLevelParameters::Dwave2000QDeviceLevelParameters end StructTypes.StructType(::Type{Dwave2000QDeviceParameters}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{Dwave2000QDeviceParameters}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.dwave.dwave_2000Q_device_parameters", "1")) + struct DwaveAdvantageDeviceLevelParameters <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader annealingOffsets::Union{Nothing, Vector{Float64}} @@ -1176,15 +1178,15 @@ struct DwaveAdvantageDeviceLevelParameters <: BraketSchemaBase spinReversalTransformCount::Union{Nothing, Int} end StructTypes.StructType(::Type{DwaveAdvantageDeviceLevelParameters}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{DwaveAdvantageDeviceLevelParameters}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.dwave.dwave_advantage_device_level_parameters", "1")) + struct DwaveAdvantageDeviceParameters <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader deviceLevelParameters::DwaveAdvantageDeviceLevelParameters end StructTypes.StructType(::Type{DwaveAdvantageDeviceParameters}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{DwaveAdvantageDeviceParameters}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.dwave.dwave_advantage_device_parameters", "1")) + struct DwaveProviderProperties <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader annealingOffsetStep::Float64 @@ -1211,8 +1213,8 @@ struct DwaveProviderProperties <: BraketSchemaBase topology::Dict end StructTypes.StructType(::Type{DwaveProviderProperties}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{DwaveProviderProperties}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.dwave.dwave_provider_properties", "1")) + struct DwaveDeviceCapabilities <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader service::DeviceServiceProperties @@ -1221,24 +1223,24 @@ struct DwaveDeviceCapabilities <: BraketSchemaBase provider::DwaveProviderProperties end StructTypes.StructType(::Type{DwaveDeviceCapabilities}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{DwaveDeviceCapabilities}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.dwave.dwave_device_capabilities", "1")) + struct DwaveDeviceParameters <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader providerLevelParameters::Union{Nothing, DwaveProviderLevelParameters} deviceLevelParameters::Union{Nothing, Union{DwaveAdvantageDeviceLevelParameters, Dwave2000QDeviceLevelParameters, Nothing}} end StructTypes.StructType(::Type{DwaveDeviceParameters}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{DwaveDeviceParameters}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.dwave.dwave_device_parameters", "1")) + struct IonqProviderProperties <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader fidelity::Dict{String, Dict{String, Float64}} timing::Dict{String, Float64} end StructTypes.StructType(::Type{IonqProviderProperties}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{IonqProviderProperties}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.ionq.ionq_provider_properties", "1")) + struct IonqDeviceCapabilities <: BraketSchemaBase service::DeviceServiceProperties action::Dict{Union{DeviceActionType, String}, Union{OpenQASMDeviceActionProperties, JaqcdDeviceActionProperties}} @@ -1248,23 +1250,23 @@ struct IonqDeviceCapabilities <: BraketSchemaBase provider::Union{Nothing, IonqProviderProperties} end StructTypes.StructType(::Type{IonqDeviceCapabilities}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{IonqDeviceCapabilities}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.ionq.ionq_device_capabilities", "1")) + struct IonqDeviceParameters <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader paradigmParameters::GateModelParameters end StructTypes.StructType(::Type{IonqDeviceParameters}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{IonqDeviceParameters}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.ionq.ionq_device_parameters", "1")) + struct OqcProviderProperties <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader properties::Dict{String, Dict{String, QubitType}} end StructTypes.StructType(::Type{OqcProviderProperties}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{OqcProviderProperties}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.oqc.oqc_provider_properties", "1")) -struct PulseDeviceActionProperties <: BraketSchemaBase + +struct PulseDeviceActionProperties <: DeviceActionProperties braketSchemaHeader::braketSchemaHeader supportedQhpTemplateWaveforms::Dict{String, PulseFunction} ports::Dict{String, Port} @@ -1276,8 +1278,8 @@ struct PulseDeviceActionProperties <: BraketSchemaBase validationParameters::Union{Nothing, Dict{String, Float64}} end StructTypes.StructType(::Type{PulseDeviceActionProperties}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{PulseDeviceActionProperties}) = Dict{Symbol, Any}(:supportsNonNativeGatesWithPulses => false, :braketSchemaHeader => braketSchemaHeader("braket.device_schema.pulse.pulse_device_action_properties", "1"), :supportsDynamicFrames => true, :supportsLocalPulseElements => true) + struct OqcDeviceCapabilities <: BraketSchemaBase service::DeviceServiceProperties action::Dict{Union{DeviceActionType, String}, Union{OpenQASMDeviceActionProperties, JaqcdDeviceActionProperties}} @@ -1289,15 +1291,15 @@ struct OqcDeviceCapabilities <: BraketSchemaBase pulse::Union{Nothing, PulseDeviceActionProperties} end StructTypes.StructType(::Type{OqcDeviceCapabilities}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{OqcDeviceCapabilities}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.oqc.oqc_device_capabilities", "1")) + struct OqcDeviceParameters <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader paradigmParameters::GateModelParameters end StructTypes.StructType(::Type{OqcDeviceParameters}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{OqcDeviceParameters}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.oqc.oqc_device_parameters", "1")) + struct QueraAhsParadigmProperties <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader qubitCount::Int @@ -1306,8 +1308,8 @@ struct QueraAhsParadigmProperties <: BraketSchemaBase performance::Performance end StructTypes.StructType(::Type{QueraAhsParadigmProperties}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{QueraAhsParadigmProperties}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.quera.quera_ahs_paradigm_properties", "1")) + struct QueraDeviceCapabilities <: BraketSchemaBase service::DeviceServiceProperties action::Dict{Union{DeviceActionType, String}, DeviceActionProperties} @@ -1316,15 +1318,15 @@ struct QueraDeviceCapabilities <: BraketSchemaBase paradigm::QueraAhsParadigmProperties end StructTypes.StructType(::Type{QueraDeviceCapabilities}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{QueraDeviceCapabilities}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.quera.quera_device_capabilities", "1")) + struct RigettiProviderProperties <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader specs::Dict{String, Dict{String, Dict{String, Float64}}} end StructTypes.StructType(::Type{RigettiProviderProperties}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{RigettiProviderProperties}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.rigetti.rigetti_provider_properties", "1")) + struct RigettiDeviceCapabilities <: BraketSchemaBase service::DeviceServiceProperties action::Dict{Union{DeviceActionType, String}, Union{OpenQASMDeviceActionProperties, JaqcdDeviceActionProperties}} @@ -1336,22 +1338,22 @@ struct RigettiDeviceCapabilities <: BraketSchemaBase pulse::Union{Nothing, PulseDeviceActionProperties} end StructTypes.StructType(::Type{RigettiDeviceCapabilities}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{RigettiDeviceCapabilities}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.rigetti.rigetti_device_capabilities", "1")) + struct RigettiDeviceParameters <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader paradigmParameters::GateModelParameters end StructTypes.StructType(::Type{RigettiDeviceParameters}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{RigettiDeviceParameters}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.rigetti.rigetti_device_parameters", "1")) + struct GateModelSimulatorParadigmProperties <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader qubitCount::Int end StructTypes.StructType(::Type{GateModelSimulatorParadigmProperties}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{GateModelSimulatorParadigmProperties}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.simulators.gate_model_simulator_paradigm_properties", "1")) + struct GateModelSimulatorDeviceCapabilities <: BraketSchemaBase service::DeviceServiceProperties action::Dict{Union{DeviceActionType, String}, Union{OpenQASMDeviceActionProperties, JaqcdDeviceActionProperties}} @@ -1360,15 +1362,15 @@ struct GateModelSimulatorDeviceCapabilities <: BraketSchemaBase paradigm::GateModelSimulatorParadigmProperties end StructTypes.StructType(::Type{GateModelSimulatorDeviceCapabilities}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{GateModelSimulatorDeviceCapabilities}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.simulators.gate_model_simulator_device_capabilities", "1")) + struct GateModelSimulatorDeviceParameters <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader paradigmParameters::GateModelParameters end StructTypes.StructType(::Type{GateModelSimulatorDeviceParameters}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{GateModelSimulatorDeviceParameters}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.simulators.gate_model_simulator_device_parameters", "1")) + struct XanaduProviderProperties <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader loopPhases::Vector{Float64} @@ -1379,8 +1381,8 @@ struct XanaduProviderProperties <: BraketSchemaBase loopEfficiencies::Vector{Float64} end StructTypes.StructType(::Type{XanaduProviderProperties}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{XanaduProviderProperties}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.xanadu.xanadu_provider_properties", "1")) + struct XanaduDeviceCapabilities <: BraketSchemaBase service::DeviceServiceProperties action::Dict{Union{DeviceActionType, String}, BlackbirdDeviceActionProperties} @@ -1390,14 +1392,14 @@ struct XanaduDeviceCapabilities <: BraketSchemaBase provider::Union{Nothing, XanaduProviderProperties} end StructTypes.StructType(::Type{XanaduDeviceCapabilities}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{XanaduDeviceCapabilities}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.xanadu.xanadu_device_capabilities", "1")) + struct XanaduDeviceParameters <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader end StructTypes.StructType(::Type{XanaduDeviceParameters}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{XanaduDeviceParameters}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.device_schema.xanadu.xanadu_device_parameters", "1")) + struct Problem <: AbstractProgram braketSchemaHeader::braketSchemaHeader type::Union{ProblemType, String} @@ -1405,31 +1407,31 @@ struct Problem <: AbstractProgram quadratic::Dict{String, Float64} end StructTypes.StructType(::Type{Problem}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{Problem}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.ir.annealing.problem", "1")) + struct BlackbirdProgram <: AbstractProgram braketSchemaHeader::braketSchemaHeader source::String end StructTypes.StructType(::Type{BlackbirdProgram}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{BlackbirdProgram}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.ir.blackbird.program", "1")) + struct OpenQasmProgram <: AbstractProgram braketSchemaHeader::braketSchemaHeader source::String inputs::Union{Nothing, Dict{String, Union{String, Float64, Int, Vector{Union{String, Float64, Int}}}}} end StructTypes.StructType(::Type{OpenQasmProgram}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{OpenQasmProgram}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.ir.openqasm.program", "1")) + struct PersistedJobData <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader dataDictionary::Dict{String, Any} dataFormat::Union{PersistedJobDataFormat, String} end StructTypes.StructType(::Type{PersistedJobData}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{PersistedJobData}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.jobs_data.persisted_job_data", "1")) + struct TaskMetadata <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader id::String @@ -1442,8 +1444,8 @@ struct TaskMetadata <: BraketSchemaBase failureReason::Union{Nothing, String} end StructTypes.StructType(::Type{TaskMetadata}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{TaskMetadata}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.task_result.task_metadata", "1")) + struct AnalogHamiltonianSimulationTaskResult <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader taskMetadata::TaskMetadata @@ -1451,8 +1453,8 @@ struct AnalogHamiltonianSimulationTaskResult <: BraketSchemaBase additionalMetadata::Union{Nothing, AdditionalMetadata} end StructTypes.StructType(::Type{AnalogHamiltonianSimulationTaskResult}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{AnalogHamiltonianSimulationTaskResult}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.task_result.analog_hamiltonian_simulation_task_result", "1")) + struct AnnealingTaskResult <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader solutions::Union{Nothing, Vector{Vector{Int}}} @@ -1463,8 +1465,8 @@ struct AnnealingTaskResult <: BraketSchemaBase additionalMetadata::AdditionalMetadata end StructTypes.StructType(::Type{AnnealingTaskResult}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{AnnealingTaskResult}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.task_result.annealing_task_result", "1")) + struct GateModelTaskResult <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader measurements::Union{Nothing, Vector{Vector{Int}}} @@ -1475,8 +1477,8 @@ struct GateModelTaskResult <: BraketSchemaBase additionalMetadata::AdditionalMetadata end StructTypes.StructType(::Type{GateModelTaskResult}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{GateModelTaskResult}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.task_result.gate_model_task_result", "1")) + struct PhotonicModelTaskResult <: BraketSchemaBase braketSchemaHeader::braketSchemaHeader measurements::Union{Nothing, Vector{Vector{Vector{Int}}}} @@ -1484,65 +1486,43 @@ struct PhotonicModelTaskResult <: BraketSchemaBase additionalMetadata::AdditionalMetadata end StructTypes.StructType(::Type{PhotonicModelTaskResult}) = StructTypes.UnorderedStruct() - StructTypes.defaults(::Type{PhotonicModelTaskResult}) = Dict{Symbol, Any}(:braketSchemaHeader => braketSchemaHeader("braket.task_result.photonic_model_task_result", "1")) + struct GenericDeviceActionProperties <: DeviceActionProperties version::Vector{String} actionType::Union{DeviceActionType, String} end StructTypes.StructType(::Type{GenericDeviceActionProperties}) = StructTypes.UnorderedStruct() -const type_dict = Dict{String, DataType}("braket.device_schema.gate_model_qpu_paradigm_properties_v1"=>GateModelQpuParadigmProperties, "braket.device_schema.oqc.oqc_device_capabilities_v1"=>OqcDeviceCapabilities, "braket.device_schema.dwave.dwave_advantage_device_level_parameters_v1"=>DwaveAdvantageDeviceLevelParameters, "braket.device_schema.ionq.ionq_device_capabilities_v1"=>IonqDeviceCapabilities, "braket.device_schema.ionq.ionq_device_parameters_v1"=>IonqDeviceParameters, "braket.device_schema.quera.quera_device_capabilities_v1"=>QueraDeviceCapabilities, "braket.device_schema.standardized_gate_model_qpu_device_properties_v1"=>StandardizedGateModelQpuDeviceProperties, "braket.device_schema.xanadu.xanadu_device_capabilities_v1"=>XanaduDeviceCapabilities, "braket.device_schema.dwave.dwave_device_parameters_v1"=>DwaveDeviceParameters, "braket.task_result.dwave_metadata_v1"=>DwaveMetadata, "braket.device_schema.dwave.dwave_2000Q_device_level_parameters_v1"=>Dwave2000QDeviceLevelParameters, "braket.task_result.quera_metadata_v1"=>QueraMetadata, "braket.device_schema.oqc.oqc_provider_properties_v1"=>OqcProviderProperties, "braket.device_schema.device_service_properties_v1"=>DeviceServiceProperties, "braket.device_schema.xanadu.xanadu_device_parameters_v1"=>XanaduDeviceParameters, "braket.ir.blackbird.program_v1"=>BlackbirdProgram, "braket.device_schema.dwave.dwave_provider_properties_v1"=>DwaveProviderProperties, "braket.device_schema.rigetti.rigetti_device_capabilities_v1"=>RigettiDeviceCapabilities, "braket.task_result.annealing_task_result_v1"=>AnnealingTaskResult, "braket.device_schema.dwave.dwave_provider_level_parameters_v1"=>DwaveProviderLevelParameters, "braket.device_schema.pulse.pulse_device_action_properties_v1"=>PulseDeviceActionProperties, "braket.device_schema.ionq.ionq_provider_properties_v1"=>IonqProviderProperties, "braket.task_result.photonic_model_task_result_v1"=>PhotonicModelTaskResult, "braket.device_schema.continuous_variable_qpu_paradigm_properties_v1"=>ContinuousVariableQpuParadigmProperties, "braket.device_schema.xanadu.xanadu_provider_properties_v1"=>XanaduProviderProperties, "braket.device_schema.dwave.dwave_advantage_device_parameters_v1"=>DwaveAdvantageDeviceParameters, "braket.device_schema.rigetti.rigetti_device_parameters_v1"=>RigettiDeviceParameters, "braket.ir.ahs.program_v1"=>AHSProgram, "braket.ir.jaqcd.program_v1"=>Program, "braket.task_result.task_metadata_v1"=>TaskMetadata, "braket.task_result.analog_hamiltonian_simulation_task_result_v1"=>AnalogHamiltonianSimulationTaskResult, "braket.device_schema.simulators.gate_model_simulator_paradigm_properties_v1"=>GateModelSimulatorParadigmProperties, "braket.task_result.gate_model_task_result_v1"=>GateModelTaskResult, "braket.device_schema.rigetti.rigetti_provider_properties_v1"=>RigettiProviderProperties, "braket.device_schema.oqc.oqc_device_parameters_v1"=>OqcDeviceParameters, "braket.device_schema.simulators.gate_model_simulator_device_capabilities_v1"=>GateModelSimulatorDeviceCapabilities, "braket.task_result.xanadu_metadata_v1"=>XanaduMetadata, "braket.device_schema.gate_model_parameters_v1"=>GateModelParameters, "braket.device_schema.simulators.gate_model_simulator_device_parameters_v1"=>GateModelSimulatorDeviceParameters, "braket.task_result.oqc_metadata_v1"=>OqcMetadata, "braket.device_schema.dwave.dwave_device_capabilities_v1"=>DwaveDeviceCapabilities, "braket.device_schema.quera.quera_ahs_paradigm_properties_v1"=>QueraAhsParadigmProperties, "braket.jobs_data.persisted_job_data_v1"=>PersistedJobData, "braket.task_result.rigetti_metadata_v1"=>RigettiMetadata, "braket.task_result.simulator_metadata_v1"=>SimulatorMetadata, "braket.ir.annealing.problem_v1"=>Problem, "braket.device_schema.dwave.dwave_2000Q_device_parameters_v1"=>Dwave2000QDeviceParameters, "braket.ir.openqasm.program_v1"=>OpenQasmProgram) - +const type_dict = Dict{String, DataType}("braket.device_schema.gate_model_qpu_paradigm_properties_v1"=>GateModelQpuParadigmProperties, "braket.device_schema.oqc.oqc_device_capabilities_v1"=>OqcDeviceCapabilities, "braket.device_schema.dwave.dwave_advantage_device_level_parameters_v1"=>DwaveAdvantageDeviceLevelParameters, "braket.device_schema.ionq.ionq_device_capabilities_v1"=>IonqDeviceCapabilities, "braket.device_schema.ionq.ionq_device_parameters_v1"=>IonqDeviceParameters, "braket.device_schema.quera.quera_device_capabilities_v1"=>QueraDeviceCapabilities, "braket.device_schema.standardized_gate_model_qpu_device_properties_v1"=>StandardizedGateModelQpuDeviceProperties, "braket.device_schema.xanadu.xanadu_device_capabilities_v1"=>XanaduDeviceCapabilities, "braket.device_schema.dwave.dwave_device_parameters_v1"=>DwaveDeviceParameters, "braket.task_result.dwave_metadata_v1"=>DwaveMetadata, "braket.device_schema.dwave.dwave_2000Q_device_level_parameters_v1"=>Dwave2000QDeviceLevelParameters, "braket.task_result.quera_metadata_v1"=>QueraMetadata, "braket.device_schema.oqc.oqc_provider_properties_v1"=>OqcProviderProperties, "braket.device_schema.device_service_properties_v1"=>DeviceServiceProperties, "braket.device_schema.xanadu.xanadu_device_parameters_v1"=>XanaduDeviceParameters, "braket.ir.blackbird.program_v1"=>BlackbirdProgram, "braket.device_schema.dwave.dwave_provider_properties_v1"=>DwaveProviderProperties, "braket.device_schema.rigetti.rigetti_device_capabilities_v1"=>RigettiDeviceCapabilities, "braket.task_result.annealing_task_result_v1"=>AnnealingTaskResult, "braket.device_schema.dwave.dwave_provider_level_parameters_v1"=>DwaveProviderLevelParameters, "braket.device_schema.pulse.pulse_device_action_properties_v1"=>PulseDeviceActionProperties, "braket.device_schema.ionq.ionq_provider_properties_v1"=>IonqProviderProperties, "braket.task_result.photonic_model_task_result_v1"=>PhotonicModelTaskResult, "braket.device_schema.continuous_variable_qpu_paradigm_properties_v1"=>ContinuousVariableQpuParadigmProperties, "braket.device_schema.xanadu.xanadu_provider_properties_v1"=>XanaduProviderProperties, "braket.device_schema.dwave.dwave_advantage_device_parameters_v1"=>DwaveAdvantageDeviceParameters, "braket.device_schema.rigetti.rigetti_device_parameters_v1"=>RigettiDeviceParameters, "braket.ir.ahs.program_v1"=>AHSProgram, "braket.ir.jaqcd.program_v1"=>Program, "braket.task_result.task_metadata_v1"=>TaskMetadata, "braket.task_result.analog_hamiltonian_simulation_task_result_v1"=>AnalogHamiltonianSimulationTaskResult, "braket.device_schema.simulators.gate_model_simulator_paradigm_properties_v1"=>GateModelSimulatorParadigmProperties, "braket.task_result.gate_model_task_result_v1"=>GateModelTaskResult, "braket.device_schema.rigetti.rigetti_provider_properties_v1"=>RigettiProviderProperties, "braket.device_schema.oqc.oqc_device_parameters_v1"=>OqcDeviceParameters, "braket.device_schema.simulators.gate_model_simulator_device_capabilities_v1"=>GateModelSimulatorDeviceCapabilities, "braket.task_result.xanadu_metadata_v1"=>XanaduMetadata, "braket.device_schema.gate_model_parameters_v1"=>GateModelParameters, "braket.device_schema.simulators.gate_model_simulator_device_parameters_v1"=>GateModelSimulatorDeviceParameters, "braket.task_result.oqc_metadata_v1"=>OqcMetadata, "braket.device_schema.dwave.dwave_device_capabilities_v1"=>DwaveDeviceCapabilities, "braket.device_schema.quera.quera_ahs_paradigm_properties_v1"=>QueraAhsParadigmProperties, "braket.jobs_data.persisted_job_data_v1"=>PersistedJobData, "braket.task_result.rigetti_metadata_v1"=>RigettiMetadata, "braket.task_result.simulator_metadata_v1"=>SimulatorMetadata, "braket.ir.annealing.problem_v1"=>Problem, "braket.device_schema.dwave.dwave_2000Q_device_parameters_v1"=>Dwave2000QDeviceParameters, "braket.ir.openqasm.program_v1"=>OpenQasmProgram) const header_dict = Dict{DataType, braketSchemaHeader}(GateModelQpuParadigmProperties=>braketSchemaHeader("braket.device_schema.gate_model_qpu_paradigm_properties", "1"), OqcDeviceCapabilities=>braketSchemaHeader("braket.device_schema.oqc.oqc_device_capabilities", "1"), DwaveAdvantageDeviceLevelParameters=>braketSchemaHeader("braket.device_schema.dwave.dwave_advantage_device_level_parameters", "1"), IonqDeviceCapabilities=>braketSchemaHeader("braket.device_schema.ionq.ionq_device_capabilities", "1"), IonqDeviceParameters=>braketSchemaHeader("braket.device_schema.ionq.ionq_device_parameters", "1"), QueraDeviceCapabilities=>braketSchemaHeader("braket.device_schema.quera.quera_device_capabilities", "1"), StandardizedGateModelQpuDeviceProperties=>braketSchemaHeader("braket.device_schema.standardized_gate_model_qpu_device_properties", "1"), XanaduDeviceCapabilities=>braketSchemaHeader("braket.device_schema.xanadu.xanadu_device_capabilities", "1"), DwaveDeviceParameters=>braketSchemaHeader("braket.device_schema.dwave.dwave_device_parameters", "1"), DwaveMetadata=>braketSchemaHeader("braket.task_result.dwave_metadata", "1"), Dwave2000QDeviceLevelParameters=>braketSchemaHeader("braket.device_schema.dwave.dwave_2000Q_device_level_parameters", "1"), QueraMetadata=>braketSchemaHeader("braket.task_result.quera_metadata", "1"), OqcProviderProperties=>braketSchemaHeader("braket.device_schema.oqc.oqc_provider_properties", "1"), DeviceServiceProperties=>braketSchemaHeader("braket.device_schema.device_service_properties", "1"), XanaduDeviceParameters=>braketSchemaHeader("braket.device_schema.xanadu.xanadu_device_parameters", "1"), BlackbirdProgram=>braketSchemaHeader("braket.ir.blackbird.program", "1"), DwaveProviderProperties=>braketSchemaHeader("braket.device_schema.dwave.dwave_provider_properties", "1"), RigettiDeviceCapabilities=>braketSchemaHeader("braket.device_schema.rigetti.rigetti_device_capabilities", "1"), AnnealingTaskResult=>braketSchemaHeader("braket.task_result.annealing_task_result", "1"), DwaveProviderLevelParameters=>braketSchemaHeader("braket.device_schema.dwave.dwave_provider_level_parameters", "1"), PulseDeviceActionProperties=>braketSchemaHeader("braket.device_schema.pulse.pulse_device_action_properties", "1"), IonqProviderProperties=>braketSchemaHeader("braket.device_schema.ionq.ionq_provider_properties", "1"), PhotonicModelTaskResult=>braketSchemaHeader("braket.task_result.photonic_model_task_result", "1"), ContinuousVariableQpuParadigmProperties=>braketSchemaHeader("braket.device_schema.continuous_variable_qpu_paradigm_properties", "1"), XanaduProviderProperties=>braketSchemaHeader("braket.device_schema.xanadu.xanadu_provider_properties", "1"), DwaveAdvantageDeviceParameters=>braketSchemaHeader("braket.device_schema.dwave.dwave_advantage_device_parameters", "1"), RigettiDeviceParameters=>braketSchemaHeader("braket.device_schema.rigetti.rigetti_device_parameters", "1"), AHSProgram=>braketSchemaHeader("braket.ir.ahs.program", "1"), Program=>braketSchemaHeader("braket.ir.jaqcd.program", "1"), TaskMetadata=>braketSchemaHeader("braket.task_result.task_metadata", "1"), AnalogHamiltonianSimulationTaskResult=>braketSchemaHeader("braket.task_result.analog_hamiltonian_simulation_task_result", "1"), GateModelSimulatorParadigmProperties=>braketSchemaHeader("braket.device_schema.simulators.gate_model_simulator_paradigm_properties", "1"), GateModelTaskResult=>braketSchemaHeader("braket.task_result.gate_model_task_result", "1"), RigettiProviderProperties=>braketSchemaHeader("braket.device_schema.rigetti.rigetti_provider_properties", "1"), OqcDeviceParameters=>braketSchemaHeader("braket.device_schema.oqc.oqc_device_parameters", "1"), GateModelSimulatorDeviceCapabilities=>braketSchemaHeader("braket.device_schema.simulators.gate_model_simulator_device_capabilities", "1"), XanaduMetadata=>braketSchemaHeader("braket.task_result.xanadu_metadata", "1"), GateModelParameters=>braketSchemaHeader("braket.device_schema.gate_model_parameters", "1"), GateModelSimulatorDeviceParameters=>braketSchemaHeader("braket.device_schema.simulators.gate_model_simulator_device_parameters", "1"), OqcMetadata=>braketSchemaHeader("braket.task_result.oqc_metadata", "1"), DwaveDeviceCapabilities=>braketSchemaHeader("braket.device_schema.dwave.dwave_device_capabilities", "1"), QueraAhsParadigmProperties=>braketSchemaHeader("braket.device_schema.quera.quera_ahs_paradigm_properties", "1"), PersistedJobData=>braketSchemaHeader("braket.jobs_data.persisted_job_data", "1"), RigettiMetadata=>braketSchemaHeader("braket.task_result.rigetti_metadata", "1"), SimulatorMetadata=>braketSchemaHeader("braket.task_result.simulator_metadata", "1"), Problem=>braketSchemaHeader("braket.ir.annealing.problem", "1"), Dwave2000QDeviceParameters=>braketSchemaHeader("braket.device_schema.dwave.dwave_2000Q_device_parameters", "1"), OpenQasmProgram=>braketSchemaHeader("braket.ir.openqasm.program", "1")) -function lookup_type(header::braketSchemaHeader) - global type_dict - return type_dict[header.name * "_v" * header.version] -end +lookup_type(header::braketSchemaHeader) = type_dict[header.name * "_v" * header.version] function parse_raw_schema(x::String) obj = copy(JSON3.read(x)) - if haskey(obj, :braketSchemaHeader) - bSH = StructTypes.constructfrom(braketSchemaHeader, obj[:braketSchemaHeader]) - typ = lookup_type(bSH) - return StructTypes.constructfrom(typ, obj) - end - throw(ArgumentError("invalid schema!")) + !haskey(obj, :braketSchemaHeader) && throw(ArgumentError("invalid schema!")) + bSH = StructTypes.constructfrom(braketSchemaHeader, obj[:braketSchemaHeader]) + typ = lookup_type(bSH) + return StructTypes.constructfrom(typ, obj) end - -function bsb_f(raw_sym::Symbol) - raw = String(raw_sym) - v = eval(Meta.parse(raw)) - bsh = v["name"] * "_v" * v["version"] - return type_dict[bsh] -end -StructTypes.subtypes(::Type{BraketSchemaBase}) = StructTypes.SubTypeClosure(bsb_f) function StructTypes.constructfrom(::Type{DeviceActionProperties}, obj) sub_ts = StructTypes.subtypes(DeviceActionProperties) T = haskey(obj, :actionType) ? sub_ts[Symbol(obj[:actionType])] : GenericDeviceActionProperties return StructTypes.constructfrom(T, obj) end - function StructTypes.constructfrom(::Type{AbstractProgram}, obj) header = obj[:braketSchemaHeader] - if occursin("jaqcd", header[:name]) - return StructTypes.constructfrom(Program, obj) - elseif occursin("openqasm", header[:name]) - return StructTypes.constructfrom(OpenQasmProgram, obj) - elseif occursin("blackbird", header[:name]) - return StructTypes.constructfrom(BlackbirdProgram, obj) - elseif occursin("ahs", header[:name]) - return StructTypes.constructfrom(AHSProgram, obj) - elseif occursin("problem", header[:name]) - return StructTypes.constructfrom(Problem, obj) - else - throw(ErrorException("invalid program specification!")) - end -end + occursin("braket.ir.jaqcd", header[:name]) && return StructTypes.constructfrom(Program, obj) + occursin("braket.ir.blackbird", header[:name]) && return StructTypes.constructfrom(BlackbirdProgram, obj) + occursin("braket.ir.ahs", header[:name]) && return StructTypes.constructfrom(AHSProgram, obj) + occursin("braket.ir.openqasm", header[:name]) && return StructTypes.constructfrom(OpenQasmProgram, obj) + occursin("braket.ir.annealing", header[:name]) && return StructTypes.constructfrom(Problem, obj) + throw(ErrorException("invalid program specification!")) +end Base.:(==)(o1::T, o2::T) where {T<:BraketSchemaBase} = all(Base.getproperty(o1, fn) == Base.getproperty(o2, fn) for fn in fieldnames(T)) for T in (TaskMetadata, AdditionalMetadata) Base.:(==)(o1::T, o2::T) = all(Base.getproperty(o1, fn) == Base.getproperty(o2, fn) for fn in fieldnames(T)) diff --git a/test/circuits.jl b/test/circuits.jl index a37ee693..f7ee77e6 100644 --- a/test/circuits.jl +++ b/test/circuits.jl @@ -873,8 +873,11 @@ using Braket: Instruction, Result, VIRTUAL, PHYSICAL, OpenQASMSerializationPrope @testset "Circuit with 3 qubit gates" begin c = Circuit([(H, [0, 1, 2]), (CCNot, [0, 2, 1]), (CPhaseShift, 1, 0, 0.2), (XX, 0, 2, 0.1)]) s = sprint((io, x)->show(io, "text/plain", x), c) - known_s = "T : |0|1| 2 | 3 |Result Types|\n \nq0 : -H-C-Phase(0.2)-X(0.1)--------------\n | | | \nq1 : -H-X-C------------------------------\n | | \nq2 : -H-C------------X(0.1)--------------\n \nT : |0|1| 2 | 3 |Result Types|\n" + known_s = "T : |0|1| 2 | 3 |Result Types|\n \nq0 : -H-C-PHASE(0.2)-XX(0.1)--------------\n | | | \nq1 : -H-X-C-------------------------------\n | | \nq2 : -H-C------------XX(0.1)--------------\n \nT : |0|1| 2 | 3 |Result Types|\n" @test s == known_s + end + @testset "Circuit with Unitary and Kraus" begin + end @testset "chars fallback" begin @test Braket.chars('a') == ("a",) diff --git a/test/integ_tests/create_local_quantum_job.jl b/test/integ_tests/create_local_quantum_job.jl index 06f28dba..1c7fe52b 100644 --- a/test/integ_tests/create_local_quantum_job.jl +++ b/test/integ_tests/create_local_quantum_job.jl @@ -1,7 +1,10 @@ using Braket, Braket.JSON3, Test +num_containers() = length(split(read(`docker container ls`, String), "\n")) + @testset "Local Quantum Job" begin @testset "Completed" begin + initial_containers = num_containers() absolute_source_module = joinpath(@__DIR__, "job_test_script.py") current_dir = pwd() cd(mktempdir()) do @@ -74,8 +77,13 @@ using Braket, Braket.JSON3, Test end end end + # test the container was shut down + # invoke GC to make sure finalizer has run + GC.gc() + @test num_containers() == initial_containers end - @testset "failed" begin + @testset "Failed" begin + initial_containers = num_containers() absolute_source_module = joinpath(@__DIR__, "job_test_script.py") current_dir = pwd() cd(mktempdir()) do @@ -119,5 +127,9 @@ using Braket, Braket.JSON3, Test end end end + # test the container was shut down + # invoke GC to make sure finalizer has run + GC.gc() + @test num_containers() == initial_containers end end diff --git a/test/integ_tests/create_quantum_job.jl b/test/integ_tests/create_quantum_job.jl index 1e9bd5bc..3fd467f2 100644 --- a/test/integ_tests/create_quantum_job.jl +++ b/test/integ_tests/create_quantum_job.jl @@ -43,7 +43,7 @@ using AWS, AWSS3, Braket, JSON3, Test @test errors == "" logs_to_validate = [ "Invoking script with the following command:", - "/usr/local/bin/python3.7 braket_container.py", + "/usr/local/bin/python3.8 braket_container.py", "Running Code As Process", "Test job started!!!!!", "AssertionError", @@ -135,7 +135,7 @@ using AWS, AWSS3, Braket, JSON3, Test @test errors == "" logs_to_validate = [ "Invoking script with the following command:", - "/usr/local/bin/python3.7 braket_container.py", + "/usr/local/bin/python3.8 braket_container.py", "Running Code As Process", "Test job started!!!!!", "Test job completed!!!!!", diff --git a/test/integ_tests/simulator_quantum_task.jl b/test/integ_tests/simulator_quantum_task.jl index f6245ce1..6527f759 100644 --- a/test/integ_tests/simulator_quantum_task.jl +++ b/test/integ_tests/simulator_quantum_task.jl @@ -242,14 +242,14 @@ end 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)], (simulator_arn, shots) in ARNS_WITH_SHOTS + @testset for (simulator_arn, shots) in ARNS_WITH_SHOTS, (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 = AwsDevice(_arn=simulator_arn) circuit = three_qubit_circuit(θ, ϕ, φ, obs, obs_targets) shots > 0 && circuit(Sample, obs, obs_targets) tasks = (circuit, ir(circuit, Val(:OpenQASM))) - for task in tasks + @testset for task in tasks res = result(device(task, shots=shots, s3_destination_folder=s3_destination_folder)) variance_expectation_sample_result(res, shots, expected_var, expected_mean, expected_eigs) end