From 573dab7ed39c803ff2a43e6d1aad850b66033771 Mon Sep 17 00:00:00 2001 From: David McKay Date: Fri, 11 May 2018 09:37:43 -0400 Subject: [PATCH] Transferred over new schemas (#434) * Transferred over new schemas * Changed to fix pep8 on test_schemas.py * Put old schemas back in to pass test cases, we should slowly integrate the new schemas * Fixed test_schemas script. Consolidated some of the schemas to avoid file referencing * Updated the schemas to change things to snake case. Moved the test script and renamed * pep8 fix * changed FridgeTemperature to fridge_temperature * Changed old to deprecated for schemas --- qiskit/schemas/backend_config_schema.json | 228 +++++++++ qiskit/schemas/backend_props_schema.json | 118 +++++ qiskit/schemas/backend_status_schema.json | 25 + .../schemas/default_pulse_config_schema.json | 105 +++++ .../backends/backend_calibration_example.json | 0 .../backends/backend_calibration_schema.json | 0 .../backend_configuration_example_old.json | 0 .../backend_configuration_schema_old_py.json | 142 +++--- .../backends/backend_parameters_example.json | 0 .../backends/backend_parameters_schema.json | 0 .../backends/backend_status_example.json | 0 .../backends/backend_status_schema_py.json | 44 +- .../qobj/qobj_core_schema.json | 312 ++++++------ .../{ => deprecated}/qobj/qobj_example.json | 0 .../qobj/qobj_generic_schema.json | 264 +++++------ .../result/result_example.json | 0 .../result/result_schema.json | 188 ++++---- .../backend_config_example_openpulse.json | 56 +++ .../backend_config_example_openqasm.json | 30 ++ .../examples/backend_props_example.json | 30 ++ .../examples/backend_status_example.json | 5 + .../default_pulse_config_example.json | 17 + .../schemas/examples/job_status_example.json | 5 + .../examples/qobj_example_openpulse.json | 38 ++ .../examples/qobj_example_openqasm.json | 28 ++ .../result_example_openpulse_lev0.json | 43 ++ .../result_example_openpulse_lev1.json | 40 ++ .../examples/result_example_openqasm.json | 33 ++ .../examples/result_example_snapshots.json | 79 ++++ .../result_example_statevector_simulator.json | 25 + .../result_example_unitary_simulator.json | 28 ++ qiskit/schemas/job_status_schema.json | 25 + qiskit/schemas/qobj_schema.json | 446 ++++++++++++++++++ qiskit/schemas/result_schema.json | 172 +++++++ test/python/test_backends.py | 8 +- test/schemas/check_schemas.py | 95 ++++ 36 files changed, 2150 insertions(+), 479 deletions(-) create mode 100644 qiskit/schemas/backend_config_schema.json create mode 100644 qiskit/schemas/backend_props_schema.json create mode 100644 qiskit/schemas/backend_status_schema.json create mode 100644 qiskit/schemas/default_pulse_config_schema.json rename qiskit/schemas/{ => deprecated}/backends/backend_calibration_example.json (100%) rename qiskit/schemas/{ => deprecated}/backends/backend_calibration_schema.json (100%) rename qiskit/schemas/{ => deprecated}/backends/backend_configuration_example_old.json (100%) rename qiskit/schemas/{ => deprecated}/backends/backend_configuration_schema_old_py.json (96%) rename qiskit/schemas/{ => deprecated}/backends/backend_parameters_example.json (100%) rename qiskit/schemas/{ => deprecated}/backends/backend_parameters_schema.json (100%) rename qiskit/schemas/{ => deprecated}/backends/backend_status_example.json (100%) rename qiskit/schemas/{ => deprecated}/backends/backend_status_schema_py.json (95%) rename qiskit/schemas/{ => deprecated}/qobj/qobj_core_schema.json (97%) rename qiskit/schemas/{ => deprecated}/qobj/qobj_example.json (100%) rename qiskit/schemas/{ => deprecated}/qobj/qobj_generic_schema.json (97%) rename qiskit/schemas/{ => deprecated}/result/result_example.json (100%) rename qiskit/schemas/{ => deprecated}/result/result_schema.json (97%) create mode 100644 qiskit/schemas/examples/backend_config_example_openpulse.json create mode 100644 qiskit/schemas/examples/backend_config_example_openqasm.json create mode 100644 qiskit/schemas/examples/backend_props_example.json create mode 100644 qiskit/schemas/examples/backend_status_example.json create mode 100644 qiskit/schemas/examples/default_pulse_config_example.json create mode 100644 qiskit/schemas/examples/job_status_example.json create mode 100644 qiskit/schemas/examples/qobj_example_openpulse.json create mode 100644 qiskit/schemas/examples/qobj_example_openqasm.json create mode 100644 qiskit/schemas/examples/result_example_openpulse_lev0.json create mode 100644 qiskit/schemas/examples/result_example_openpulse_lev1.json create mode 100644 qiskit/schemas/examples/result_example_openqasm.json create mode 100644 qiskit/schemas/examples/result_example_snapshots.json create mode 100644 qiskit/schemas/examples/result_example_statevector_simulator.json create mode 100644 qiskit/schemas/examples/result_example_unitary_simulator.json create mode 100644 qiskit/schemas/job_status_schema.json create mode 100644 qiskit/schemas/qobj_schema.json create mode 100644 qiskit/schemas/result_schema.json create mode 100644 test/schemas/check_schemas.py diff --git a/qiskit/schemas/backend_config_schema.json b/qiskit/schemas/backend_config_schema.json new file mode 100644 index 00000000000..e5cd060d890 --- /dev/null +++ b/qiskit/schemas/backend_config_schema.json @@ -0,0 +1,228 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "http://www.qiskit.org/schemas/backend_config_schema.json", + "description": "QISKit device backend configuration", + "definitions": { + "coreconfig": { + "type": "object", + "required": ["backend_name", "backend_version", "n_qubits","basis_gates","gates","local","simulator"], + "properties": { + "backend_name": { + "type": "string", + "description": "Backend name" + }, + "sample_name": { + "type": "string", + "description": "Sample name" + }, + "backend_version": { + "type": "string", + "pattern": "[0-9]+.[0-9]+.[0-9]+$", + "description": "Backend version in the form X.X.X" + }, + "n_qubits": { + "type": "integer", + "description": "Number of qubits", + "minimum": 1, + "default": 1 + }, + "basis_gates": { + "type": "array", + "description": "List of basis gates names on the backend", + "minItems": 1, + "items": {"type": "string"} + }, + "coupling_map": { + "type": "array", + "minItems": 1, + "items": {"type": "array", "minItems": 1, "items": {"type": "integer"}}, + "description": "Array grouping qubits that are physically coupled together on the backend" + }, + "gates": { + "type": "array", + "description": "List of basis gate configuration data structures", + "minItems": 1, + "items": {"$ref": "#/definitions/gateconfig"} + }, + "gates": { + "type": "array", + "description": "List of basis gates on the backend", + "minItems": 1, + "items": {"$ref": "#/definitions/gateconfig"} + }, + "local": { + "type": "boolean", + "description": "Backend is local or remote (true/false)" + }, + "simulator": { + "type": "boolean", + "description": "Backend is a simulator (true/false)", + "default": false + }, + "credits_required": { + "type": "boolean", + "description": "Backend requires credits to run a job (true/false)", + "default": false + }, + "online_date": { + "type": "string", + "format": "date-time", + "description": "Date the backend went online" + }, + "display_name": { + "type": "string", + "description": "Alternate name field for the backend" + }, + "description": { + "type": "string", + "description": "Description of the backend" + }, + "tags": { + "type": "array", + "minItems": 0, + "uniqueItems": true, + "items": { + "type": "string", + "examples": ["credits_required"] + } + } + } + }, + "gateconfig": { + "type": "object", + "required": ["name","parameters","coupling_map","qasm_def"], + "properties": { + "name": { + "type": "string", + "description": "The gate name as it will be referred to in QASM" + }, + "parameters": { + "type": "array", + "minItems": 0, + "items": {"type": "string"}, + "description": "Variable names for the gate parameters (if any)" + }, + "coupling_map": { + "type": "array", + "minItems": 1, + "items": {"type": "array", "minItems": 1, "items": {"type": "integer"}}, + "description": "List of qubit groupings which are coupled by this gate" + }, + "qasm_def": { + "type": "string", + "description": "Definition of this gate in terms of QASM primitives U and CX" + }, + "description": { + "type": "string", + "description": "Description of the gate operation" + } + }}, + "complexnumber": { + "type": "array", + "minItems": 2, + "maxItems": 2, + "items": [{"type": "number"},{"type": "number"}]} + }, + "oneOf": [ + {"allOf": [{"$ref": "#/definitions/coreconfig"}, + { + "required": ["open_pulse","n_uchannels","hamiltonian","u_channel_lo", + "meas_levels","qubit_lo_range","meas_lo_range","dt","dtm","rep_rates", + "meas_kernels","discriminators"], + "properties": { + "open_pulse": { + "enum": [ true ], + "description": "The backend supports openPulse (true/false)"}, + "n_uchannels": { + "type": "integer", + "description": "Number of additional control channels", + "minimum": 0}, + "hamiltonian": { + "type": "object", + "description": "Hamiltonian of the backend", + "properties": { + "h_latex": { + "type": "string", + "description": "The Hamiltonian in latex form" + }, + "h_str": { + "type": "array", + "items": {"type": "string"}, + "description": "The Hamiltonian in machine readable form" + } + } + }, + "u_channel_lo": { + "type": "array", + "minItems": 0, + "description": "Relationship of the U Channel LO's in terms of the qubit LO's", + "items": { + "type": "array", + "minItems": 1, + "items": { + "type": "object", + "properties": { + "q": {"type": "integer"}, + "scale": {"$ref": "#/definitions/complexnumber"} + }} + } + }, + "meas_levels": { + "type": "array", + "minItems": 1, + "maxitems": 3, + "description": "Available measurement levels on the backend", + "items": {"type": "integer", "minimum": 0, "maximum": 2}}, + "qubit_lo_range": { + "type": "array", + "minItems": 1, + "description": "Frequency range for the qubit LO", + "items": {"type": "array", "minItems": 2, "maxItems": 2, "items": {"type": "number"}}}, + "meas_lo_range": { + "type": "array", + "minItems": 1, + "description": "Frequency range for the measurement LO", + "items": {"type": "array", "minItems": 2, "maxItems": 2, "items": {"type": "number"}}}, + "dt": { + "type": "number", + "description": "Time discretization for the drive and U channels", + "minimum": 0}, + "dtm": { + "type": "number", + "description": "Time discretization for the measurement channels", + "minimum": 0}, + "rep_rates": { + "type": "array", + "minItems": 1, + "description": "Available experiment repetition rates", + "items": {"type": "number", "minimum": 0}}, + "meas_map": { + "type": "array", + "minItems": 1, + "description": "Grouping of measurement which are multiplexed", + "items": {"type": "array", "minItems": 1, "items": {"type": "integer", "minimum": 0}}}, + "channel_bandwidth": { + "type": "array", + "minItems": 2, + "description": "Bandwidth of all channels (qubit,measurement and U)", + "items": {"type": "array", "minItems": 2, "maxItems": 2, "items": {"type": "number"}}}, + "meas_kernels": { + "type": "array", + "minItems": 1, + "description": "Available measurement kernels", + "items": {"type": "string"}}, + "discriminators": { + "type": "array", + "minItems": 1, + "description": "Available discriminators", + "items": {"type": "string"}} + }}]}, + {"allOf": [{"$ref": "#/definitions/coreconfig"}, + { + "required": ["open_pulse"], + "properties": { + "open_pulse": {"enum": [ false ]} + }}]} + ] +} + diff --git a/qiskit/schemas/backend_props_schema.json b/qiskit/schemas/backend_props_schema.json new file mode 100644 index 00000000000..e068506dd21 --- /dev/null +++ b/qiskit/schemas/backend_props_schema.json @@ -0,0 +1,118 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "http://www.qiskit.org/schemas/backend_props_schema.json", + "description": "OpenQuantum backend properties schema", + "definitions": { + "nduv": { + "description": "Recorded parameter as a name-date-unit-value", + "type": "object", + "required": [ + "name", + "date", + "unit", + "value" + ], + "properties": { + "name": { + "type": "string" + }, + "date": { + "type": "string", + "format": "date-time" + }, + "unit": { + "type": "string" + }, + "value": { + "type": "number" + } + } + } + }, + "type": "object", + "required": [ + "backend_name", + "backend_version", + "last_update_date", + "qubits", + "gates", + "general" + ], + "properties": { + "backend_name": { + "type": "string", + "description": "Backend name" + }, + "backend_version": { + "type": "string", + "pattern": "[0-9]+.[0-9]+.[0-9]+$", + "description": "Backend version in the form X.X.X" + }, + "last_update_date": { + "type": "string", + "format": "date-time", + "description": "Last date/time that a property was updated." + }, + "qubits": { + "description": "System qubit parameters", + "type": "array", + "minItems": 1, + "items": { + "type": "object", + "required": [ + "parameters" + ], + "properties": { + "parameters": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/nduv" + } + } + } + } + }, + "gates": { + "description": "System gate parameters", + "type": "array", + "minItems": 1, + "items": { + "type": "object", + "required": [ + "qubits", + "gate", + "parameters" + ], + "properties": { + "qubits": { + "type": "array", + "minItems": 1, + "items": { + "type": "number" + } + }, + "gate": { + "type": "string" + }, + "parameters": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/nduv" + } + } + } + } + }, + "general": { + "description": "General system parameters", + "type": "array", + "minItems": 0, + "items": { + "$ref": "#/definitions/nduv" + } + } + + } +} \ No newline at end of file diff --git a/qiskit/schemas/backend_status_schema.json b/qiskit/schemas/backend_status_schema.json new file mode 100644 index 00000000000..59eb6ce0798 --- /dev/null +++ b/qiskit/schemas/backend_status_schema.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "http://www.qiskit.org/schemas/backendstatus_schema.json", + "description": "OpenQuantum backend status schema", + "type": "object", + "required": [ + "available", + "pending_jobs", + "status_msg" + ], + "properties": { + "available": { + "type": "boolean", + "description": "Backend is available true/false" + }, + "pending_jobs": { + "type": "integer", "minimum": 0, + "description": "Number of pending jobs on the backend" + }, + "status_msg": { + "type": "string", + "description": "Status message" + } + } +} \ No newline at end of file diff --git a/qiskit/schemas/default_pulse_config_schema.json b/qiskit/schemas/default_pulse_config_schema.json new file mode 100644 index 00000000000..9cd822458e5 --- /dev/null +++ b/qiskit/schemas/default_pulse_config_schema.json @@ -0,0 +1,105 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "http://www.qiskit.org/schemas/default_pulse_config_schema.json", + "description": "Default OpenPulse backend configuration", + "definitions": { + "complex": { + "description": "JSON representation of a complex number", + "type": "array", + "minItems": 2, + "maxItems": 2, + "items": { + "type": "number" + } + }, + "complex_array": { + "description": "JSON representation of a complex vector", + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/complex" + } + }, + "complex_matrix": { + "description": "JSON representaiton of a complex matrix", + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/complex_array" + } + }, + "gate_def": { + "description": "OpenPulse gate definition schema. Defines QASM gates in terms of pulses.", + "type": "object", + "required": ["name"], + "properties": { + "name": { + "type": "string", + "description": "QASM pulse name" + }, + "qubits": { + "type": "array", + "minItems": 1, + "description": "Qubits to which this gate def applies", + "items": {"type": "integer", "minimum": 0} + }, + "sequence": { + "type": "array", + "description": "Sequence of pulse instructions", + "items": {"type": "object"} + } + } + } + }, + "type": "object", + "required": ["qubit_freq_est","meas_freq_est","pulse_library","meas_kernel","discriminator"], + "properties": { + "qubit_freq_est": { + "type": "array", + "description": "Backend calibrated qubit frequencies", + "minItems": 1, + "items": {"type": "number"}}, + "meas_freq_est": { + "type": "array", + "description": "Backend calibrated qubit frequencies", + "minItems": 1, + "items": {"type": "number"}}, + "gate_def": { + "type": "array", + "description": "Backend calibrated QASM to Pulse definitions", + "items": {"$ref": "#/definitions/gate_def"} + }, + "pulse_library": { + "type": "array", + "description": "Backend pulse library", + "items": { + "type": "object", + "required": ["name","samples"], + "properties": { + "name": { + "type": "string", + "description": "Pulse name"}, + "samples": {"$ref": "#/definitions/complex_array"} + } + } + }, + "meas_kernel": { + "type": "object", + "description": "Default measurement kernel", + "properties": { + "name": {"type": "string"}, + "params": {"type": "array"} + } + }, + "discriminator": { + "type": "object", + "description": "Default measurement kernel", + "properties": { + "name": {"type": "string"}, + "params": {"type": "array"} + } + } + + } +} + diff --git a/qiskit/schemas/backends/backend_calibration_example.json b/qiskit/schemas/deprecated/backends/backend_calibration_example.json similarity index 100% rename from qiskit/schemas/backends/backend_calibration_example.json rename to qiskit/schemas/deprecated/backends/backend_calibration_example.json diff --git a/qiskit/schemas/backends/backend_calibration_schema.json b/qiskit/schemas/deprecated/backends/backend_calibration_schema.json similarity index 100% rename from qiskit/schemas/backends/backend_calibration_schema.json rename to qiskit/schemas/deprecated/backends/backend_calibration_schema.json diff --git a/qiskit/schemas/backends/backend_configuration_example_old.json b/qiskit/schemas/deprecated/backends/backend_configuration_example_old.json similarity index 100% rename from qiskit/schemas/backends/backend_configuration_example_old.json rename to qiskit/schemas/deprecated/backends/backend_configuration_example_old.json diff --git a/qiskit/schemas/backends/backend_configuration_schema_old_py.json b/qiskit/schemas/deprecated/backends/backend_configuration_schema_old_py.json similarity index 96% rename from qiskit/schemas/backends/backend_configuration_schema_old_py.json rename to qiskit/schemas/deprecated/backends/backend_configuration_schema_old_py.json index 4b72109974e..7f2c0e1223f 100644 --- a/qiskit/schemas/backends/backend_configuration_schema_old_py.json +++ b/qiskit/schemas/deprecated/backends/backend_configuration_schema_old_py.json @@ -1,71 +1,71 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "id": "http://qiskit.org/backend/configuration-01/schema#", - "description": "QISKit device backend configuration", - "type": "object", - "required": [ - "name", - "coupling_map", - "basis_gates", - "simulator", - "local" - ], - "properties": { - "name": { - "type": "string" - }, - "version": { - "type": "string" - }, - "url": { - "type": "string", - "format": "uri" - }, - "simulator": { - "type": "boolean", - "default": false - }, - "local": { - "type": "boolean", - "default": false - }, - "description": { - "type": "string" - }, - "n_qubits": { - "type": "integer", - "minimum": 1 - }, - "coupling_map": { - "oneOf": [ - { - "type": "string", - "enum": [ - "all-to-all" - ] - }, - { - "type": "array", - "items": { - "type": "array", - "item": "integer", - "minItems": 2, - "maxItems": 2, - "uniqueItems": true - }, - "uniqueItems": true - } - ] - }, - "basis_gates": { - "type": "string" - }, - "online_date": { - "type": "string", - "format": "date" - }, - "chip_name": { - "type": "string" - } - } -} +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "http://qiskit.org/backend/configuration-01/schema#", + "description": "QISKit device backend configuration", + "type": "object", + "required": [ + "name", + "coupling_map", + "basis_gates", + "simulator", + "local" + ], + "properties": { + "name": { + "type": "string" + }, + "version": { + "type": "string" + }, + "url": { + "type": "string", + "format": "uri" + }, + "simulator": { + "type": "boolean", + "default": false + }, + "local": { + "type": "boolean", + "default": false + }, + "description": { + "type": "string" + }, + "n_qubits": { + "type": "integer", + "minimum": 1 + }, + "coupling_map": { + "oneOf": [ + { + "type": "string", + "enum": [ + "all-to-all" + ] + }, + { + "type": "array", + "items": { + "type": "array", + "item": "integer", + "minItems": 2, + "maxItems": 2, + "uniqueItems": true + }, + "uniqueItems": true + } + ] + }, + "basis_gates": { + "type": "string" + }, + "online_date": { + "type": "string", + "format": "date" + }, + "chip_name": { + "type": "string" + } + } +} diff --git a/qiskit/schemas/backends/backend_parameters_example.json b/qiskit/schemas/deprecated/backends/backend_parameters_example.json similarity index 100% rename from qiskit/schemas/backends/backend_parameters_example.json rename to qiskit/schemas/deprecated/backends/backend_parameters_example.json diff --git a/qiskit/schemas/backends/backend_parameters_schema.json b/qiskit/schemas/deprecated/backends/backend_parameters_schema.json similarity index 100% rename from qiskit/schemas/backends/backend_parameters_schema.json rename to qiskit/schemas/deprecated/backends/backend_parameters_schema.json diff --git a/qiskit/schemas/backends/backend_status_example.json b/qiskit/schemas/deprecated/backends/backend_status_example.json similarity index 100% rename from qiskit/schemas/backends/backend_status_example.json rename to qiskit/schemas/deprecated/backends/backend_status_example.json diff --git a/qiskit/schemas/backends/backend_status_schema_py.json b/qiskit/schemas/deprecated/backends/backend_status_schema_py.json similarity index 95% rename from qiskit/schemas/backends/backend_status_schema_py.json rename to qiskit/schemas/deprecated/backends/backend_status_schema_py.json index 9b4820936ab..a3477367b4c 100644 --- a/qiskit/schemas/backends/backend_status_schema_py.json +++ b/qiskit/schemas/deprecated/backends/backend_status_schema_py.json @@ -1,22 +1,22 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "id": "http://qiskit.org/backend/configuration-01/schema#", - "description": "QISKit backend states", - "type": "object", - "required": [ - "name", - "available" - ], - "properties": { - "name": { - "type": "string" - }, - "pending_jobs":{ - "type": "number" - }, - "available": { - "type": "boolean", - "default": true - } - } -} +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "http://qiskit.org/backend/configuration-01/schema#", + "description": "QISKit backend states", + "type": "object", + "required": [ + "name", + "available" + ], + "properties": { + "name": { + "type": "string" + }, + "pending_jobs":{ + "type": "number" + }, + "available": { + "type": "boolean", + "default": true + } + } +} diff --git a/qiskit/schemas/qobj/qobj_core_schema.json b/qiskit/schemas/deprecated/qobj/qobj_core_schema.json similarity index 97% rename from qiskit/schemas/qobj/qobj_core_schema.json rename to qiskit/schemas/deprecated/qobj/qobj_core_schema.json index b8c832763dc..3651c6cca23 100644 --- a/qiskit/schemas/qobj/qobj_core_schema.json +++ b/qiskit/schemas/deprecated/qobj/qobj_core_schema.json @@ -1,156 +1,156 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "id": "http://qiskit.org/qobj/core-01/schema#", - "type": "object", - "required": ["id", "experiments"], - "properties": { - "type": { - "type": "string", - "enum": ["QASM", "PULSE"] - }, - "id": {"type": "string"}, - "config": { - "title": "Qobj-level configuration", - "description": "Configuration options that apply to all experiments in this qobj. For options that may be set on a per-experiment basis, these are the defaults.", - "type": "object", - "properties": { - "backend": { - "type": "string", - "description": "The backend this qobj was generated for. It may also be able to execute on other backends." - }, - "max_credits": {"type": "integer", "default": 3}, - "seed": {"type": "integer"}, - "shots": {"type": "integer", "minimum": 1} - } - }, - "experiments": { - "title": "Experiments to run", - "type": "array", - "minItems": 1, - "items": { - "type": "object", - "required": ["header", "instructions"], - "properties": { - "name": {"type": "string"}, - "config": { - "title": "Experiment-level configuration", - "description": "Configuration options that apply to only this experiment. Overrides settings from the qobj-level config", - "type": "object", - "properties": { - "seed": {"type": "integer"}, - "shots": {"type": "integer", "minimum": 1} - } - }, - "header": { - "$ref": "#/definitions/header" - }, - "instructions": { - "$ref": "#/definitions/instructions" - } - } - } - } - }, - "definitions": { - "header": { - "description": "Header information about the experiment. Defines the classical and quantum bits", - "required": ["number_of_qubits", "number_of_clbits", "qubit_labels", "clbit_labels"], - "properties": { - "number_of_qubits": { - "type": "integer", - "minimum": 1 - }, - "number_of_clbits": { - "type": "integer", - "minimum": 0 - }, - "qubit_labels": { - "title": "Map physical qubits to qregs", - "description": "A list of length number_of_qubits, where each element is either [qreg_name, n] to identify the corresponding physical qubit as the n-th qubit of qreg qreg_name, or null to identify that the corresponding physical qubit has no corresponding qreg", - "examples": [ - [["q", 0], ["q", 1], ["r", 0], ["r", 1], ["r", 2]], - [["q", 2], null, ["q", 1], null, ["q", 0]] - ], - "type": "array", - "minItems": 1, - "items": { - "type": ["array", "null"], - "minItems": 2, - "maxItems": 2, - "items": [ - { - "title": "qreg", - "type": "string", - "minLength": 1 - }, - { - "title": "qubit number", - "description": "The qubit number within the qreg", - "type": "integer", - "minimum": 0 - }] - } - }, - "clbit_labels": { - "title": "Map physical clbits to clregs", - "description": "A list of pairs [clreg_name, size], to allocate the next size contiguous clbits to clreg clreg_name. The sum of the size-s should equal number_of_clbits", - "examples": [ - [["c", 2], ["d", 3]] - ], - "type": "array", - "minItems": 1, - "uniqueItems": true, - "items": [{ - "type": "array", - "minItems": 2, - "maxItems": 2, - "items": [{ - "title": "clreg", - "type": "string", - "minLength": 1 - }, { - "title": "size", - "description": "Size of the clreg", - "type": "integer", - "minimum": 1 - }] - }] - } - }, - "_constraints": "sum(x[1] for x in clbit_labels) == number_of_clbits" - }, - "instructions": { - "description": "The instructions that describe the quantum experiment", - "type": "array", - "items": { - "type": "object", - "required": ["name"], - "properties": { - "name": {"type": "string"}, - "qubits": { - "type": "array", - "uniqueItems": true, - "items": {"type": "integer", "minimum": 0} - }, - "params": {"type": "array", "items": {"type": "number"}}, - "texparams": {"type": "array", "items": {"type": "string"}}, - "clbits": { - "type": "array", - "uniqueItems": true, - "items": {"type": "integer", "minimum": 0}}, - "key": {"type": "string"}, - "conditional": { - "type": "object", - "required": ["type", "mask", "val"], - "properties": { - "type": {"type": "string"}, - "mask": {"$ref": "#/definitions/hexstring"}, - "val": {"$ref": "#/definitions/hexstring"} - } - } - } - } - }, - "hexstring": {"type": "string", "pattern": "^0x[0-9a-fA-F]+$"} - } -} +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "http://qiskit.org/qobj/core-01/schema#", + "type": "object", + "required": ["id", "experiments"], + "properties": { + "type": { + "type": "string", + "enum": ["QASM", "PULSE"] + }, + "id": {"type": "string"}, + "config": { + "title": "Qobj-level configuration", + "description": "Configuration options that apply to all experiments in this qobj. For options that may be set on a per-experiment basis, these are the defaults.", + "type": "object", + "properties": { + "backend": { + "type": "string", + "description": "The backend this qobj was generated for. It may also be able to execute on other backends." + }, + "max_credits": {"type": "integer", "default": 3}, + "seed": {"type": "integer"}, + "shots": {"type": "integer", "minimum": 1} + } + }, + "experiments": { + "title": "Experiments to run", + "type": "array", + "minItems": 1, + "items": { + "type": "object", + "required": ["header", "instructions"], + "properties": { + "name": {"type": "string"}, + "config": { + "title": "Experiment-level configuration", + "description": "Configuration options that apply to only this experiment. Overrides settings from the qobj-level config", + "type": "object", + "properties": { + "seed": {"type": "integer"}, + "shots": {"type": "integer", "minimum": 1} + } + }, + "header": { + "$ref": "#/definitions/header" + }, + "instructions": { + "$ref": "#/definitions/instructions" + } + } + } + } + }, + "definitions": { + "header": { + "description": "Header information about the experiment. Defines the classical and quantum bits", + "required": ["number_of_qubits", "number_of_clbits", "qubit_labels", "clbit_labels"], + "properties": { + "number_of_qubits": { + "type": "integer", + "minimum": 1 + }, + "number_of_clbits": { + "type": "integer", + "minimum": 0 + }, + "qubit_labels": { + "title": "Map physical qubits to qregs", + "description": "A list of length number_of_qubits, where each element is either [qreg_name, n] to identify the corresponding physical qubit as the n-th qubit of qreg qreg_name, or null to identify that the corresponding physical qubit has no corresponding qreg", + "examples": [ + [["q", 0], ["q", 1], ["r", 0], ["r", 1], ["r", 2]], + [["q", 2], null, ["q", 1], null, ["q", 0]] + ], + "type": "array", + "minItems": 1, + "items": { + "type": ["array", "null"], + "minItems": 2, + "maxItems": 2, + "items": [ + { + "title": "qreg", + "type": "string", + "minLength": 1 + }, + { + "title": "qubit number", + "description": "The qubit number within the qreg", + "type": "integer", + "minimum": 0 + }] + } + }, + "clbit_labels": { + "title": "Map physical clbits to clregs", + "description": "A list of pairs [clreg_name, size], to allocate the next size contiguous clbits to clreg clreg_name. The sum of the size-s should equal number_of_clbits", + "examples": [ + [["c", 2], ["d", 3]] + ], + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": [{ + "type": "array", + "minItems": 2, + "maxItems": 2, + "items": [{ + "title": "clreg", + "type": "string", + "minLength": 1 + }, { + "title": "size", + "description": "Size of the clreg", + "type": "integer", + "minimum": 1 + }] + }] + } + }, + "_constraints": "sum(x[1] for x in clbit_labels) == number_of_clbits" + }, + "instructions": { + "description": "The instructions that describe the quantum experiment", + "type": "array", + "items": { + "type": "object", + "required": ["name"], + "properties": { + "name": {"type": "string"}, + "qubits": { + "type": "array", + "uniqueItems": true, + "items": {"type": "integer", "minimum": 0} + }, + "params": {"type": "array", "items": {"type": "number"}}, + "texparams": {"type": "array", "items": {"type": "string"}}, + "clbits": { + "type": "array", + "uniqueItems": true, + "items": {"type": "integer", "minimum": 0}}, + "key": {"type": "string"}, + "conditional": { + "type": "object", + "required": ["type", "mask", "val"], + "properties": { + "type": {"type": "string"}, + "mask": {"$ref": "#/definitions/hexstring"}, + "val": {"$ref": "#/definitions/hexstring"} + } + } + } + } + }, + "hexstring": {"type": "string", "pattern": "^0x[0-9a-fA-F]+$"} + } +} diff --git a/qiskit/schemas/qobj/qobj_example.json b/qiskit/schemas/deprecated/qobj/qobj_example.json similarity index 100% rename from qiskit/schemas/qobj/qobj_example.json rename to qiskit/schemas/deprecated/qobj/qobj_example.json diff --git a/qiskit/schemas/qobj/qobj_generic_schema.json b/qiskit/schemas/deprecated/qobj/qobj_generic_schema.json similarity index 97% rename from qiskit/schemas/qobj/qobj_generic_schema.json rename to qiskit/schemas/deprecated/qobj/qobj_generic_schema.json index 4119fd93a94..de91a67756f 100644 --- a/qiskit/schemas/qobj/qobj_generic_schema.json +++ b/qiskit/schemas/deprecated/qobj/qobj_generic_schema.json @@ -1,132 +1,132 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "id": "http://qiskit.org/qobj/generic-01/schema#", - "properties": { - "experiments": { - "properties": { - "instructions": { - "$ref": "#/definitions/generic_instructions" - } - } - } - }, - "definitions": { - "generic_instructions": { - "anyOf": [{ - "title": "3-param 1Q op", - "required": ["qubits", "params"], - "properties": { - "name": {"enum": ["u3", "U"]}, - "qubits": {"maxItems": 1}, - "clbits": {"maxItems": 0}, - "params": {"minItems": 3, "maxItems": 3}, - "texparams": {"minItems": 3, "maxItems": 3} - } - }, { - "title": "fixed 1Q op", - "required": ["qubits"], - "properties": { - "name": {"enum": ["reset", "id", "h", "s", "sdg", "t", "tdg", "x", "y", "z"]}, - "qubits": {"maxItems": 1}, - "clbits": {"maxItems": 0}, - "params": {"maxItems": 0}, - "texparams": {"maxItems": 0} - } - }, { - "title": "1-param 1Q op", - "required": ["qubits", "params"], - "properties": { - "name": {"enum": ["u1", "rx", "ry", "rz"]}, - "qubits": {"maxItems": 1}, - "clbits": {"maxItems": 0}, - "params": {"minItems": 1, "maxItems": 1}, - "texparams": {"minItems": 1, "maxItems": 1} - } - }, { - "title": "2-param 1Q op", - "required": ["qubits", "params"], - "properties": { - "name": {"enum": ["u2"]}, - "qubits": {"maxItems": 1}, - "clbits": {"maxItems": 0}, - "params": {"minItems": 2, "maxItems": 2}, - "texparams": {"minItems": 2, "maxItems": 2} - } - }, { - "title": "fixed 2Q gate", - "required": ["qubits"], - "properties": { - "name": {"enum": ["cx", "CX", "cy", "cz", "ch", "swap"]}, - "qubits": {"description": "[control, target]", "minItems": 2, "maxItems": 2}, - "clbits": {"maxItems": 0}, - "params": {"maxItems": 0}, - "texparams": {"maxItems": 0} - } - }, { - "title": "1-param 2Q controlled gate", - "required": ["qubits", "params"], - "properties": { - "name": {"enum": ["cu1", "crz"]}, - "qubits": {"description": "[control, target]", "minItems": 2, "maxItems": 2}, - "clbits": {"maxItems": 0}, - "params": {"minItems": 1, "maxItems": 1}, - "texparams": {"minItems": 1, "maxItems": 1} - } - }, { - "title": "3-param 2Q controlled gate", - "required": ["qubits", "params"], - "properties": { - "name": {"enum": ["cu3"]}, - "qubits": {"description": "[control, target]", "minItems": 2, "maxItems": 2}, - "clbits": {"maxItems": 0}, - "params": {"minItems":3, "maxItems": 3}, - "texparams": {"minItems":3, "maxItems": 3} - } - }, { - "title": "fixed 3Q doubly controlled gate", - "required": ["qubits"], - "properties": { - "name": {"enum": ["ccx"]}, - "qubits": {"description": "[control, control, target]", "minItems": 3, "maxItems": 3}, - "clbits": {"maxItems": 0}, - "params": {"maxItems": 0}, - "texparams": {"maxItems": 0} - } - }, { - "title": "measurement", - "required": ["qubits", "clbits"], - "properties": { - "name": {"enum": ["measure"]}, - "qubits": {"maxItems": 1}, - "clbits": {"minItems": 1, "maxItems": 1}, - "params": {"maxItems": 0}, - "texparams": {"maxItems": 0} - } - }, { - "title": "barrier", - "required": ["qubits"], - "properties": { - "name": {"enum": ["barrier"]}, - "clbits": {"maxItems": 0}, - "params": {"maxItems": 0}, - "texparams": {"maxItems": 0} - } - }, { - "description": "Operations named with leading # are pragma-like (safe to ignore by backends that don't understand them).", - "properties": { - "name": { - "pattern": "^#.+" - } - } - }, { - "description": "Operations named with leading _ are non-generic (specific to certain backends) and not specified here. Not safe to ignore.", - "properties": { - "name": { - "pattern": "^_.+" - } - } - }] - } - } -} - +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "http://qiskit.org/qobj/generic-01/schema#", + "properties": { + "experiments": { + "properties": { + "instructions": { + "$ref": "#/definitions/generic_instructions" + } + } + } + }, + "definitions": { + "generic_instructions": { + "anyOf": [{ + "title": "3-param 1Q op", + "required": ["qubits", "params"], + "properties": { + "name": {"enum": ["u3", "U"]}, + "qubits": {"maxItems": 1}, + "clbits": {"maxItems": 0}, + "params": {"minItems": 3, "maxItems": 3}, + "texparams": {"minItems": 3, "maxItems": 3} + } + }, { + "title": "fixed 1Q op", + "required": ["qubits"], + "properties": { + "name": {"enum": ["reset", "id", "h", "s", "sdg", "t", "tdg", "x", "y", "z"]}, + "qubits": {"maxItems": 1}, + "clbits": {"maxItems": 0}, + "params": {"maxItems": 0}, + "texparams": {"maxItems": 0} + } + }, { + "title": "1-param 1Q op", + "required": ["qubits", "params"], + "properties": { + "name": {"enum": ["u1", "rx", "ry", "rz"]}, + "qubits": {"maxItems": 1}, + "clbits": {"maxItems": 0}, + "params": {"minItems": 1, "maxItems": 1}, + "texparams": {"minItems": 1, "maxItems": 1} + } + }, { + "title": "2-param 1Q op", + "required": ["qubits", "params"], + "properties": { + "name": {"enum": ["u2"]}, + "qubits": {"maxItems": 1}, + "clbits": {"maxItems": 0}, + "params": {"minItems": 2, "maxItems": 2}, + "texparams": {"minItems": 2, "maxItems": 2} + } + }, { + "title": "fixed 2Q gate", + "required": ["qubits"], + "properties": { + "name": {"enum": ["cx", "CX", "cy", "cz", "ch", "swap"]}, + "qubits": {"description": "[control, target]", "minItems": 2, "maxItems": 2}, + "clbits": {"maxItems": 0}, + "params": {"maxItems": 0}, + "texparams": {"maxItems": 0} + } + }, { + "title": "1-param 2Q controlled gate", + "required": ["qubits", "params"], + "properties": { + "name": {"enum": ["cu1", "crz"]}, + "qubits": {"description": "[control, target]", "minItems": 2, "maxItems": 2}, + "clbits": {"maxItems": 0}, + "params": {"minItems": 1, "maxItems": 1}, + "texparams": {"minItems": 1, "maxItems": 1} + } + }, { + "title": "3-param 2Q controlled gate", + "required": ["qubits", "params"], + "properties": { + "name": {"enum": ["cu3"]}, + "qubits": {"description": "[control, target]", "minItems": 2, "maxItems": 2}, + "clbits": {"maxItems": 0}, + "params": {"minItems":3, "maxItems": 3}, + "texparams": {"minItems":3, "maxItems": 3} + } + }, { + "title": "fixed 3Q doubly controlled gate", + "required": ["qubits"], + "properties": { + "name": {"enum": ["ccx"]}, + "qubits": {"description": "[control, control, target]", "minItems": 3, "maxItems": 3}, + "clbits": {"maxItems": 0}, + "params": {"maxItems": 0}, + "texparams": {"maxItems": 0} + } + }, { + "title": "measurement", + "required": ["qubits", "clbits"], + "properties": { + "name": {"enum": ["measure"]}, + "qubits": {"maxItems": 1}, + "clbits": {"minItems": 1, "maxItems": 1}, + "params": {"maxItems": 0}, + "texparams": {"maxItems": 0} + } + }, { + "title": "barrier", + "required": ["qubits"], + "properties": { + "name": {"enum": ["barrier"]}, + "clbits": {"maxItems": 0}, + "params": {"maxItems": 0}, + "texparams": {"maxItems": 0} + } + }, { + "description": "Operations named with leading # are pragma-like (safe to ignore by backends that don't understand them).", + "properties": { + "name": { + "pattern": "^#.+" + } + } + }, { + "description": "Operations named with leading _ are non-generic (specific to certain backends) and not specified here. Not safe to ignore.", + "properties": { + "name": { + "pattern": "^_.+" + } + } + }] + } + } +} + diff --git a/qiskit/schemas/result/result_example.json b/qiskit/schemas/deprecated/result/result_example.json similarity index 100% rename from qiskit/schemas/result/result_example.json rename to qiskit/schemas/deprecated/result/result_example.json diff --git a/qiskit/schemas/result/result_schema.json b/qiskit/schemas/deprecated/result/result_schema.json similarity index 97% rename from qiskit/schemas/result/result_schema.json rename to qiskit/schemas/deprecated/result/result_schema.json index a8cb6f0589f..7606fbbdf75 100644 --- a/qiskit/schemas/result/result_schema.json +++ b/qiskit/schemas/deprecated/result/result_schema.json @@ -1,94 +1,94 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "id": "http://qiskit.org/qobj/results-01/schema#", - "title": "qobj results", - "description": "The results of executing a qobj", - "type": "object", - "required": ["backend", "id", "status"], - "properties": { - "backend": { - "type": "string", - "description": "Backend who produced this result" - }, - "id": { - "type": "string", - "description": "Job id passed back from the input qobj" - }, - "execution_id": { - "type": "string", - "description": "Unique execution id. May be useful for matching with backend logfiles, etc" - }, - "date": { - "type": "string", - "format": "date-time", - "description": "Date/time of job execution" - }, - "result": { - "type": "array", - "description": "Corresponding results for array of experiments of the input qobj", - "items": { - "type": "object", - "required": ["status", "success"], - "properties": { - "success": { - "type": "boolean", - "description": "If true, we can trust results for this experiment." - }, - "status": { - "type": "string", - "description": "Human-readable description of status of this experiment" - }, - "name": { - "type": "string", - "description": "Experiment name" - }, - "seed": { - "type": "string", - "description": "Experiment-level random seed" - }, - "shots": { - "type": "string", - "description": "Experiment-level number of shots" - }, - "data": { - "type": "object", - "properties": { - "counts": { - "type": "object", - "description": "Histogram of results", - "example": {"01011": 10, "10001": 102}, - "additionalProperties": { - "type": "integer", - "minimum": 0 - } - }, - "snapshots": { - "type": "object", - "description": "Snapshot of simulator internal representation", - "example": { - "0": { - "statevector": [[0,0.707], [0,0], [0,0], [0.707,0]], - "probabilities": [0.5, 0, 0, 0.5] - } - }, - "properties": { - "type": "object", - "properties": { - } - } - } - } - } - } - } - } - }, - "success": { - "type": "boolean", - "description": "True if complete input qobj executed correctly. (Implies each experiment success)" - }, - "status": { - "type": "string", - "description": "Human-readable status of complete qobj execution" - } -} +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "http://qiskit.org/qobj/results-01/schema#", + "title": "qobj results", + "description": "The results of executing a qobj", + "type": "object", + "required": ["backend", "id", "status"], + "properties": { + "backend": { + "type": "string", + "description": "Backend who produced this result" + }, + "id": { + "type": "string", + "description": "Job id passed back from the input qobj" + }, + "execution_id": { + "type": "string", + "description": "Unique execution id. May be useful for matching with backend logfiles, etc" + }, + "date": { + "type": "string", + "format": "date-time", + "description": "Date/time of job execution" + }, + "result": { + "type": "array", + "description": "Corresponding results for array of experiments of the input qobj", + "items": { + "type": "object", + "required": ["status", "success"], + "properties": { + "success": { + "type": "boolean", + "description": "If true, we can trust results for this experiment." + }, + "status": { + "type": "string", + "description": "Human-readable description of status of this experiment" + }, + "name": { + "type": "string", + "description": "Experiment name" + }, + "seed": { + "type": "string", + "description": "Experiment-level random seed" + }, + "shots": { + "type": "string", + "description": "Experiment-level number of shots" + }, + "data": { + "type": "object", + "properties": { + "counts": { + "type": "object", + "description": "Histogram of results", + "example": {"01011": 10, "10001": 102}, + "additionalProperties": { + "type": "integer", + "minimum": 0 + } + }, + "snapshots": { + "type": "object", + "description": "Snapshot of simulator internal representation", + "example": { + "0": { + "statevector": [[0,0.707], [0,0], [0,0], [0.707,0]], + "probabilities": [0.5, 0, 0, 0.5] + } + }, + "properties": { + "type": "object", + "properties": { + } + } + } + } + } + } + } + } + }, + "success": { + "type": "boolean", + "description": "True if complete input qobj executed correctly. (Implies each experiment success)" + }, + "status": { + "type": "string", + "description": "Human-readable status of complete qobj execution" + } +} diff --git a/qiskit/schemas/examples/backend_config_example_openpulse.json b/qiskit/schemas/examples/backend_config_example_openpulse.json new file mode 100644 index 00000000000..94cb2858f5a --- /dev/null +++ b/qiskit/schemas/examples/backend_config_example_openpulse.json @@ -0,0 +1,56 @@ +{ + "backend_name": "quantumbackend1", + "sample_name": "sample1", + "backend_version": "1.1.1", + "n_qubits": 3, + "basis_gates": ["u1","u2","u3","cx"], + "coupling_map": [[0,1,2]], + "gates": [ + {"name": "u1", + "parameters": ["lambda"], + "coupling_map": [[0],[1],[2]], + "qasm_def": "gate u1(lambda) q { U(0,0,lambda) q; }"}, + {"name": "u2", + "parameters": ["phi","lambda"], + "coupling_map": [[0],[1],[2]], + "qasm_def": "gate u2(phi,lambda) q { U(pi/2,phi,lambda) q; }"}, + {"name": "u3", + "parameters": ["theta","phi","lambda"], + "coupling_map": [[0],[1],[2]], + "qasm_def": "u3(theta,phi,lambda) q { U(theta,phi,lambda) q; }"}, + {"name": "cx", + "parameters": [], + "coupling_map": [[0,1],[1,2]], + "qasm_def": "gate cx q1,q2 { CX q1,q2; }"} + ], + "local": false, + "simulator": false, + "open_pulse": true, + "tags": ["credits_required","readable_hamiltonian","all_meas"], + "n_uchannels": 2, + "hamiltonian": { + "type": "object", + "required": ["h_latex"], + "properties": { + "h_latex": "H = \\sum_{i}^{N} D_i(t) \\sigma_i^{X} +\\sum_{i}^{N} 2\\pi \\nu_i \\sigma_i^{+}\\sigma_i^{-}", + "h_str": ["__SUM[i,0,N,_X{i}_||_D{i}_]","__SUM[i,0,N,2*pi*_v{i}_*_O{i}_]"], + "vars": { + "type": "object", + "description": "Variables in the h_str"}, + "osc": { + "type": "object", + "description": "Number of levels for each oscillator mode"} + } + }, + "u_channel_lo": [[{"q": 0, "scale": [0,1]}],[{"q": 1, "scale": [1.0,0]}, {"q": 2, "scale": [-1.0,0]}]], + "meas_levels": [0,1,2], + "qubit_lo_range": [[5,6],[5,6],[5,6]], + "meas_lo_range": [[6.5,7.5],[6.5,7.5],[6.5,7.5]], + "dt": 1, + "dtm": 10, + "rep_rates": [1000,100,50], + "meas_map": [[0],[1],[2]], + "channel_bandwidth": [[-0.5,0.5],[-0.5,0.5],[-0.5,0.5],[-0.1,0.1],[-0.1,0.1],[-0.1,0.1],[-0.2,0.2],[-0.1,0.3]], + "meas_kernels": ["kern1","kern2"], + "discriminators": ["disc1","dis2"] +} diff --git a/qiskit/schemas/examples/backend_config_example_openqasm.json b/qiskit/schemas/examples/backend_config_example_openqasm.json new file mode 100644 index 00000000000..5b7f0b89c34 --- /dev/null +++ b/qiskit/schemas/examples/backend_config_example_openqasm.json @@ -0,0 +1,30 @@ +{ + "backend_name": "quantumbackend1", + "sample_name": "sample1", + "backend_version": "1.1.1", + "n_qubits": 3, + "basis_gates": ["u1","u2","u3","cx"], + "coupling_map": [[0,1,2]], + "gates": [ + {"name": "u1", + "parameters": ["lambda"], + "coupling_map": [[0],[1],[2]], + "qasm_def": "gate u1(lambda) q { U(0,0,lambda) q; }"}, + {"name": "u2", + "parameters": ["phi","lambda"], + "coupling_map": [[0],[1],[2]], + "qasm_def": "gate u2(phi,lambda) q { U(pi/2,phi,lambda) q; }"}, + {"name": "u3", + "parameters": ["theta","phi","lambda"], + "coupling_map": [[0],[1],[2]], + "qasm_def": "u3(theta,phi,lambda) q { U(theta,phi,lambda) q; }"}, + {"name": "cx", + "parameters": [], + "coupling_map": [[0,1],[1,2]], + "qasm_def": "gate cx q1,q2 { CX q1,q2; }"} + ], + "local": false, + "simulator": false, + "credits_required": false, + "open_pulse": false +} diff --git a/qiskit/schemas/examples/backend_props_example.json b/qiskit/schemas/examples/backend_props_example.json new file mode 100644 index 00000000000..d22899f7cf3 --- /dev/null +++ b/qiskit/schemas/examples/backend_props_example.json @@ -0,0 +1,30 @@ +{ + "backend_name": "ibmqx5", + "backend_version": "1.1.1", + "last_update_date": "2018-04-02 15:00:00Z", + "qubits": [ + { + "parameters": [ + {"name": "T1", "date": "2018-04-02 15:00:00Z", "unit": "us", "value": 60}, + {"name": "T2", "date": "2018-04-02 15:00:00Z", "unit": "us", "value": 60}, + {"name": "frequency", "date": "2018-04-02 15:00:00Z", "unit": "GHz", "value": 5.2} + ] + }, + { + "parameters": [ + {"name": "T1", "date": "2018-04-02 15:00:00Z", "unit": "us", "value": 60}, + {"name": "T2", "date": "2018-04-02 15:00:00Z", "unit": "us", "value": 60}, + {"name": "frequency", "date": "2018-04-02 15:00:00Z", "unit": "us", "value": 5.2}] + }], + "gates": [ + {"qubits": [0], "gate": "u2", "parameters": [ + {"name": "gateerr", "date": "2018-04-02 15:00:00Z", "unit": "None", "value": 0.002}] + }, + {"qubits": [1], "gate": "u2", "parameters": [ + {"name": "gateerr", "date": "2018-04-02 15:00:00Z", "unit": "None", "value": 0.002}] + }, + {"qubits": [0,1], "gate": "cx", "parameters": [ + {"name": "gateerr", "date": "2018-04-02 15:00:00Z", "unit": "None", "value": 0.02}] + }], + "general": [{"name": "fridge_temperature", "date": "2018-04-02 15:00:00Z", "unit": "mK", "value": 10}] +} \ No newline at end of file diff --git a/qiskit/schemas/examples/backend_status_example.json b/qiskit/schemas/examples/backend_status_example.json new file mode 100644 index 00000000000..9889d69b758 --- /dev/null +++ b/qiskit/schemas/examples/backend_status_example.json @@ -0,0 +1,5 @@ +{ + "available": false, + "pending_jobs": 10, + "status_msg": "Paused for recalibration" +} \ No newline at end of file diff --git a/qiskit/schemas/examples/default_pulse_config_example.json b/qiskit/schemas/examples/default_pulse_config_example.json new file mode 100644 index 00000000000..01c1946323f --- /dev/null +++ b/qiskit/schemas/examples/default_pulse_config_example.json @@ -0,0 +1,17 @@ +{ + "qubit_freq_est": [5.34221,5.24654,5.67543], + "meas_freq_est": [6.87,7.1,7.4], + "gate_def": [ + {"name": "u1", "qubits": [0], "sequence": [{}]}, + {"name": "u2", "qubits": [0], "sequence": [{}]}, + {"name": "u3", "qubits": [0], "sequence": [{}]} + ], + "pulse_library": [ + {"name": "90_0", "samples": [[0,0],[0,0],[0,0]]}, + {"name": "90_1", "samples": [[0,0],[0,0],[0,0]]}, + {"name": "90_2", "samples": [[0,0],[0,0],[0,0]]} + ], + "meas_kernel": {"name": "boxcar", "params": []}, + "discriminator": {"name": "max_1Q_fidelity", "params": []} +} + diff --git a/qiskit/schemas/examples/job_status_example.json b/qiskit/schemas/examples/job_status_example.json new file mode 100644 index 00000000000..5548274d05d --- /dev/null +++ b/qiskit/schemas/examples/job_status_example.json @@ -0,0 +1,5 @@ +{ + "job_id": "1x56222G", + "status": "RUNNING", + "status_msg": "Currently running, estimated time remaining: 45s" +} \ No newline at end of file diff --git a/qiskit/schemas/examples/qobj_example_openpulse.json b/qiskit/schemas/examples/qobj_example_openpulse.json new file mode 100644 index 00000000000..e658f7907da --- /dev/null +++ b/qiskit/schemas/examples/qobj_example_openpulse.json @@ -0,0 +1,38 @@ +{ + "id": "Set of Experiments 1", + "type": "PULSE", + "header": { + "backend_name": "pulse_simulator2", + "description": "Sample pulse experiment" + }, + "config": { + "pulse_prop": "test", + "shots": 1024, + "register_slots": 3, + "meas_return": "avg", + "meas_level": 2, + "register_slot_size": 1, + "rep_rate": 1000, + "qubit_lo_freq": [5.2,5.15,5.05], + "meas_lo_freq": [6.9,6.8,6.7], + "pulse_library": [ + {"name": "pulse1", "samples": [[0,0],[0,0],[0,0]]}, + {"name": "pulse2", "samples": [[0,0],[0,0],[0,0]]}, + {"name": "pulse3", "samples": [[0,0],[0,0],[0,0]]} + ] + }, + "experiments": [ + { + "header": {}, + "config": {"shots": 512}, + "instructions": [ + {"name": "pulse1", "ch": "d0", "t0": 0}, + {"name": "pv", "ch": "d0", "t0": 0, "val": [1,2]}, + {"name": "fc", "ch": "u0", "t0": 10, "phase": -0.1}, + {"name": "acquire", "t_start": 10, "t_end": 100, "qubits": [0,1,2], "register_slot": [0,1,2]} + ] + } + ] +} + + diff --git a/qiskit/schemas/examples/qobj_example_openqasm.json b/qiskit/schemas/examples/qobj_example_openqasm.json new file mode 100644 index 00000000000..8ca4421a7c3 --- /dev/null +++ b/qiskit/schemas/examples/qobj_example_openqasm.json @@ -0,0 +1,28 @@ +{ + "id": "Set of Experiments 1", + "type": "QASM", + "header": { + "backend_name": "ibmqx2", + "clbit_labels": [["c1", 1],["c2",2]], + "qubit_labels": [["q", 0],null,["q",1]]}, + "config": { + "shots": 1024, + "register_slots": 3 + }, + "experiments": [ + { + "header": {}, + "config": {}, + "instructions": [ + {"name": "u1", "qubits": [1], "params": [0.4]}, + {"name": "u2", "qubits": [1], "params": [0.4,0.2]}, + {"name": "u3", "qubits": [1], "params": [0.4,0.2,-0.3]}, + {"name": "#snapshot", "params": ["1", "statevector"]}, + {"name": "cx", "qubits": [1,2]}, + {"name": "barrier", "qubits": [1]}, + {"name": "measure", "qubits": [1], "register": [2]} + ] + } + ] +} + diff --git a/qiskit/schemas/examples/result_example_openpulse_lev0.json b/qiskit/schemas/examples/result_example_openpulse_lev0.json new file mode 100644 index 00000000000..0dee8b503fc --- /dev/null +++ b/qiskit/schemas/examples/result_example_openpulse_lev0.json @@ -0,0 +1,43 @@ +{ + "backend_name": "ibmqx2", + "backend_version": "1.1.11", + "job_id": "XC1323XG2", + "id": "Experiment1", + "date": "2018-04-02 15:00:00Z", + "status": "COMPLETED", + "success": true, + "header": {"description": "T1 with cals"}, + "results": [ + {"header": {"exp_descrip": "Ground state calibration"}, + "shots": 1024, + "status": "DONE", + "success": true, + "meas_return": "avg", + "data": { + "register": [[[0,0],[0.75,0],[1.0,0],[1.5,0],[1.5,0],[1.5,0]]] + } + }, + {"header": {"exp_descrip": "Excited state calibration"}, + "shots": 1024, + "status": "DONE", + "success": true, + "meas_return": "avg", + "data": { + "register": [[[0,0],[0.0,0.75],[0.0,1.0],[0,1.5],[0,1.5],[0,1.5]]] + } + }, + {"header": {"exp_descrip": "T1", "t1_time": 0}, + "shots": [1020,1024], + "status": "DONE", + "success": true, + "meas_return": "single", + "data": { + "register": [[[[0,0],[0.0,0.75],[0.0,1.0],[0,1.5],[0,1.5],[0,1.5]]], + [[[0,0],[0.0,0.75],[0.0,1.0],[0,1.5],[0,1.5],[0,1.5]]], + [[[0,0],[0.0,0.75],[0.0,1.0],[0,1.5],[0,1.5],[0,1.5]]], + [[[0,0],[0.0,0.75],[0.0,1.0],[0,1.5],[0,1.5],[0,1.5]]], + [[[0,0],[0.0,0.75],[0.0,1.0],[0,1.5],[0,1.5],[0,1.5]]]] + } + } + ] +} \ No newline at end of file diff --git a/qiskit/schemas/examples/result_example_openpulse_lev1.json b/qiskit/schemas/examples/result_example_openpulse_lev1.json new file mode 100644 index 00000000000..9b545fe7ce1 --- /dev/null +++ b/qiskit/schemas/examples/result_example_openpulse_lev1.json @@ -0,0 +1,40 @@ +{ + "backend_name": "ibmqx2", + "sample_name": "chip1", + "backend_version": "1.1.11", + "job_id": "XC1323XG2", + "id": "Experiment1", + "date": "2018-04-02 15:00:00Z", + "status": "COMPLETED", + "success": true, + "header": {"description": "T1 Experiment with Cals"}, + "results": [ + {"header": {"exp_descrip": "Ground state calibration"}, + "shots": 1024, + "status": "DONE", + "success": true, + "meas_return": "avg", + "data": { + "register": [[1.5,0]] + } + }, + {"header": {"exp_descrip": "Excited state calibration"}, + "shots": 1024, + "status": "DONE", + "success": true, + "meas_return": "avg", + "data": { + "register": [[0,1.5]] + } + }, + {"header": {"exp_descrip": "T1", "t1_time": 0}, + "shots": 5, + "status": "DONE", + "success": true, + "meas_return": "single", + "data": { + "register": [[[0.1,1.6]],[[-0.2,1.4]],[[0.2,1.3]],[[-0.1,1.6]],[[0,1.5]]] + } + } + ] +} diff --git a/qiskit/schemas/examples/result_example_openqasm.json b/qiskit/schemas/examples/result_example_openqasm.json new file mode 100644 index 00000000000..82b20a2ba8f --- /dev/null +++ b/qiskit/schemas/examples/result_example_openqasm.json @@ -0,0 +1,33 @@ +{ + "backend_name": "ibmqx2", + "sample_name": "sample1", + "backend_version": "1.1.1", + "job_id": "XC1323XG2", + "id": "Experiment1", + "date": "2018-04-02 15:00:00Z", + "status": "COMPLETED", + "success": true, + "header": {"description": "Bell state in ZZ and XY"}, + "results": [ + {"header": {"exp_descrip": "Bell state"}, + "shots": 1024, + "status": "DONE", + "success": true, + "data": { + "counts": { + "0x0": 480, "0x3": 490, "0x1": 20, "0x2": 34 + } + } + }, + {"header": {"exp_descrip": "Bell state XY"}, + "shots": 1024, + "status": "DONE", + "success": true, + "data": { + "counts": { + "0x0": 29, "0x3": 15, "0x1": 510, "0x2": 480 + } + } + } + ] +} diff --git a/qiskit/schemas/examples/result_example_snapshots.json b/qiskit/schemas/examples/result_example_snapshots.json new file mode 100644 index 00000000000..6e65a0102dc --- /dev/null +++ b/qiskit/schemas/examples/result_example_snapshots.json @@ -0,0 +1,79 @@ +{ + "backend_name": "local_qasm_simulator_cpp", + "backend_version": "1.5.1", + "job_id": "XC1323XG2", + "id": "Experiment1", + "date": "2018-04-02 15:00:00Z", + "status": "COMPLETED", + "success": true, + "header": {"description": "Bell state snapshot tests"}, + "results": [ + { + "header": { + "exp_descrip": "Bell state (sampling measurements from single shot)" + }, + "shots": 1000, + "status": "DONE", + "success": true, + "data": { + "counts": { + "0x0": 495, "0x3": 505 + }, + "snapshots": { + "initial_state": { + "statevector": [ + [[1.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]] + ] + }, + "pre_measurement_state": { + "statevector": [ + [[0.7071067811865475, 0.0], [0.0, 0.0], [0.0, 0.0], [0.7071067811865475, 0.0]] + ] + } + } + } + }, + { + "header": { + "exp_descrip": "Bell state (simulating all shots)" + }, + "shots": 5, + "status": "DONE", + "success": true, + "data": { + "counts": { + "0x0": 3, "0x3": 2 + }, + "snapshots": { + "initial_state": { + "statevector": [ + [[1.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]], + [[1.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]], + [[1.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]], + [[1.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]], + [[1.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]] + ] + }, + "pre_measurement_state": { + "statevector": [ + [[0.7071067811865475, 0.0], [0.0, 0.0], [0.0, 0.0], [0.7071067811865475, 0.0]], + [[0.7071067811865475, 0.0], [0.0, 0.0], [0.0, 0.0], [0.7071067811865475, 0.0]], + [[0.7071067811865475, 0.0], [0.0, 0.0], [0.0, 0.0], [0.7071067811865475, 0.0]], + [[0.7071067811865475, 0.0], [0.0, 0.0], [0.0, 0.0], [0.7071067811865475, 0.0]], + [[0.7071067811865475, 0.0], [0.0, 0.0], [0.0, 0.0], [0.7071067811865475, 0.0]] + ] + }, + "final_state": { + "statevector": [ + [[1.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]], + [[0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [1.0, 0.0]], + [[0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [1.0, 0.0]], + [[1.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]], + [[1.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]] + ] + } + } + } + } + ] +} diff --git a/qiskit/schemas/examples/result_example_statevector_simulator.json b/qiskit/schemas/examples/result_example_statevector_simulator.json new file mode 100644 index 00000000000..6b0f467a102 --- /dev/null +++ b/qiskit/schemas/examples/result_example_statevector_simulator.json @@ -0,0 +1,25 @@ +{ + "backend_name": "local_statevector_simulator", + "backend_version": "2.1.0", + "job_id": "XC1323XG2", + "id": "Experiment1", + "date": "2018-04-02 15:00:00Z", + "status": "COMPLETED", + "success": true, + "header": {"description": "Bell state statevector simulator test"}, + "results": [ + { + "header": { + "exp_descrip": "Bell state" + }, + "shots": 1, + "status": "DONE", + "success": true, + "data": { + "statevector": [ + [[0.7071067811865475, 0.0], [0.0, 0.0], [0.0, 0.0], [0.7071067811865475, 0.0]] + ] + } + } + ] +} diff --git a/qiskit/schemas/examples/result_example_unitary_simulator.json b/qiskit/schemas/examples/result_example_unitary_simulator.json new file mode 100644 index 00000000000..62d43842a6b --- /dev/null +++ b/qiskit/schemas/examples/result_example_unitary_simulator.json @@ -0,0 +1,28 @@ +{ + "backend_name": "local_qasm_simulator_cpp", + "backend_version": "1.0.3", + "job_id": "XC1323XG2", + "id": "Experiment1", + "date": "2018-04-02 15:00:00Z", + "status": "COMPLETED", + "success": true, + "header": {"description": "Bell state unitary simulator test"}, + "results": [ + { + "header": { + "exp_descrip": "Bell state circuit (h q[0]; cx q[0], q[1];)" + }, + "shots": 1, + "status": "DONE", + "success": true, + "data": { + "unitary": [ + [[[0.70710678, 0.0], [0.70710678, 0.0], [0.0, 0.0], [0.0, 0.0]], + [[0.0, 0.0], [0.0, 0.0], [0.70710678, 0.0], [-0.70710678, 0.0]], + [[0.0, 0.0], [0.0, 0.0], [0.70710678, 0.0], [0.70710678, 0.0]], + [[0.70710678, 0.0], [-0.70710678, 0.0], [0.0, 0.0], [0.0, 0.0]]] + ] + } + } + ] +} diff --git a/qiskit/schemas/job_status_schema.json b/qiskit/schemas/job_status_schema.json new file mode 100644 index 00000000000..6611e6c931c --- /dev/null +++ b/qiskit/schemas/job_status_schema.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "http://www.qiskit.org/schemas/job_status_schema.json", + "description": "OpenQuantum job status schema", + "type": "object", + "required": [ + "job_id", + "status", + "status_msg" + ], + "properties": { + "job_id": { + "type": "string", + "description": "Backend job_id" + }, + "status": { + "enum": ["DONE", "QUEUED", "CANCELLED", "RUNNING", "ERROR"], + "description": "Status of the job" + }, + "status_msg": { + "type": "string", + "description": "Status message" + } + } +} \ No newline at end of file diff --git a/qiskit/schemas/qobj_schema.json b/qiskit/schemas/qobj_schema.json new file mode 100644 index 00000000000..9e4991a6c2b --- /dev/null +++ b/qiskit/schemas/qobj_schema.json @@ -0,0 +1,446 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "http://www.qiskit.org/schemas/qobj_schema.json", + "description": "OpenQuantum quantum object data structure for running experiments", + "definitions": { + "conditional": { + "type": "object", + "required": ["mask","relation","val"], + "properties": { + "mask": {"type": "string"}, + "relation": {"type": "string"}, + "val": {"type": "string"} + } + }, + "complex": { + "description": "JSON representation of a complex number", + "type": "array", + "minItems": 2, + "maxItems": 2, + "items": { + "type": "number" + } + }, + "complex_array": { + "description": "JSON representation of a complex vector", + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/complex" + } + }, + "complex_matrix": { + "description": "JSON representaiton of a complex matrix", + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/complex_array" + } + }, + "qobjlevel0": { + "type": "object", + "required": ["id","type","experiments","config","header"], + "properties": { + "id": { + "type": "string", + "description": "User generated qobj ID" + }, + "type": { + "type": "string", + "enum": ["QASM","PULSE"], + "description": "Type of instruction set used for the experiment, QASM or PULSE" + }, + "experiments": { + "type": "array", + "description": "List of experiments to run", + "minItems": 1 + }, + "header": { + "type": "object", + "description": "QObj metadata that does not affect how the experiments are run on the backend. Carried through to the result.", + "properties": { + "backend_name": { + "type": "string", + "description": "The backend this set of experiments was generated for. It may also be able to execute on other backends." + }, + "backend_version": { + "type": "string", + "description": "The backend version this set of experiments was generated for. " + }, + "qubit_labels": { + "title": "Map physical qubits to qregs (for QASM)", + "description": "A list of length n_qubits (from backend.configuration), where each element is either [qreg_name, n] to identify the corresponding physical qubit as the n-th qubit of qreg qreg_name, or null to identify that the corresponding physical qubit has no corresponding qreg", + "examples": [ + [["q", 0], ["q", 1], ["r", 0], ["r", 1], ["r", 2]], + [["q", 2], null, ["q", 1], null, ["q", 0]] + ], + "type": "array", + "minItems": 1, + "items": { + "type": ["array", "null"], + "minItems": 2, + "maxItems": 2, + "items": [ + { + "title": "qreg", + "type": "string", + "minLength": 1 + }, + { + "title": "qubit number", + "description": "The qubit number within the qreg", + "type": "integer", + "minimum": 0 + }] + } + }, + "clbit_labels": { + "title": "Map physical clbits to register_slots (for QASM)", + "description": "A list of pairs [clreg_name, size], to allocate the next size contiguous clbits to clreg clreg_name. The sum of the size-s should equal register_slots", + "examples": [ + [["c", 2], ["d", 3]] + ], + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": [{ + "type": "array", + "minItems": 2, + "maxItems": 2, + "items": [{ + "title": "clreg", + "type": "string", + "minLength": 1 + }, { + "title": "size", + "description": "Size of the clreg", + "type": "integer", + "minimum": 1 + }] + }] + } + }, + "_constraints": "sum(x[1] for x in clbit_labels) == number_of_clbits" + + }, + "config": { + "title": "Qobj-level configuration", + "description": "Configuration options that apply to all experiments in this qobj. For options that may be set on a per-experiment basis, these are the defaults.", + "type": "object", + "required": ["shots","register_slots"], + "properties": { + "register_slots": { + "type": "integer", + "minimum": 0, + "description": "The number of measurement slots in the classical register on the backend."}, + "shots": { + "type": "integer", + "minimum": 1, + "description": "Number of repetitions of each experiment"}, + "max_credits": {"type": "integer", "default": 3}, + "seed": {"type": "integer", "default": 1} + } + } + } + }, + "qobjexp": { + "type": "object", + "description": "Quantum experiment", + "required": ["instructions"], + "properties": { + "header": { + "type": "object", + "description": "Experiment metadata that does not affect how the experiment is run on the backend. Carried through to the result.", + "properties": { + "name": { + "type": "string", + "description": "Experiment name." + } + } + }, + "config": { + "title": "Experiment level configuration", + "description": "Configuration options that apply to specific experiments in this qobj. Overwrites qobj level configuration.", + "type": "object", + "properties": {} + }, + "instructions": { + "type": "array", + "minItems": 1, + "description": "List of experiment instructions."} + } + }, + "openpulse_instructions": { + "type": "object", + "required": ["name"], + "properties": { + "name": {"type": "string"}, + "t0": {"type": "integer", "minimum": 0}, + "ch": {"type": "string"}, + "params": {"type": "array"}, + "conditional": {"$ref": "#/definitions/conditional"} + }, + "oneOf": [ + {"title": "Standard pulse", + "required": ["t0", "ch"], + "properties": { + "name": {"not": {"enum": ["pv","fc","acquire"]}}}}, + { + "title": "Persistent value pulse", + "required": ["val", "t0", "ch"], + "properties": { + "name": {"enum": ["pv"]}, + "val": { + "type": "array", + "minItems": 2, + "maxItems": 2, + "items": {"type": "number"}} + } + }, + { + "title": "Frame change pulse", + "required": ["phase", "t0", "ch"], + "properties": { + "name": {"enum": ["fc"]}, + "phase": {"type": "number"} + } + }, + { + "title": "Acquisition", + "required": ["t_start","t_end","qubits","register_slot"], + "properties": { + "name": {"enum": ["acquire"]}, + "t_start": {"type": "number"}, + "t_end": {"type": "number"}, + "qubits": {"type": "array", "minItems": 1, "items": {"type": "integer", "minimum": 0}}, + "register_slot": {"type": "array", "minItems": 1, "items": {"type": "integer", "minimum": 0}}, + "kernels": {"type": "array"}, + "discriminators": {"type": "array"} + } + }, + { + "title": "snapshot", + "required": ["t0"], + "properties": { + "name": {"enum": ["#snapshot"]}, + "register": {"maxItems": 0}, + "params": { + "minItems": 2, + "items": { + "type": "string" + } + }, + "texparams": {"maxItems": 0} + } + } + ] + }, + "openqasm_instructions": { + "type": "object", + "required": ["name"], + "properties": { + "qubits": {"type": "array"}, + "register": {"type": "array"}, + "name": {"type": "string"}, + "params": {"type": "array"}, + "conditional": {"$ref": "#definitions/conditional"} + }, + "oneOf": [{ + "title": "3-param 1Q op", + "required": ["qubits", "params"], + "properties": { + "name": {"enum": ["u3", "U"]}, + "qubits": {"maxItems": 1}, + "register": {"maxItems": 0}, + "params": {"minItems": 3, "maxItems": 3}, + "texparams": {"minItems": 3, "maxItems": 3} + } + }, { + "title": "fixed 1Q op", + "required": ["qubits"], + "properties": { + "name": {"enum": ["reset", "id", "h", "s", "sdg", "t", "tdg", "x", "y", "z"]}, + "qubits": {"minItems": 1, "maxItems": 1}, + "register": {"maxItems": 0}, + "params": {"maxItems": 0}, + "texparams": {"maxItems": 0} + } + }, { + "title": "1-param 1Q op", + "required": ["qubits", "params"], + "properties": { + "name": {"enum": ["u1", "rx", "ry", "rz"]}, + "qubits": {"minItems": 1, "maxItems": 1}, + "register": {"maxItems": 0}, + "params": {"minItems": 1, "maxItems": 1}, + "texparams": {"minItems": 1, "maxItems": 1} + } + }, { + "title": "2-param 1Q op", + "required": ["qubits", "params"], + "properties": { + "name": {"enum": ["u2"]}, + "qubits": {"minItems": 1, "maxItems": 1}, + "register": {"maxItems": 0}, + "params": {"minItems": 2, "maxItems": 2}, + "texparams": {"minItems": 2, "maxItems": 2} + } + }, { + "title": "fixed 2Q gate", + "required": ["qubits"], + "properties": { + "name": {"enum": ["cx", "CX", "cy", "cz", "ch", "swap"]}, + "qubits": {"description": "[control, target]", "minItems": 2, "maxItems": 2}, + "register": {"maxItems": 0}, + "params": {"maxItems": 0}, + "texparams": {"maxItems": 0} + } + }, { + "title": "1-param 2Q controlled gate", + "required": ["qubits", "params"], + "properties": { + "name": {"enum": ["cu1", "crz"]}, + "qubits": {"description": "[control, target]", "minItems": 2, "maxItems": 2}, + "register": {"maxItems": 0}, + "params": {"minItems": 1, "maxItems": 1}, + "texparams": {"minItems": 1, "maxItems": 1} + } + }, { + "title": "3-param 2Q controlled gate", + "required": ["qubits", "params"], + "properties": { + "name": {"enum": ["cu3"]}, + "qubits": {"description": "[control, target]", "minItems": 2, "maxItems": 2}, + "register": {"maxItems": 0}, + "params": {"minItems": 3, "maxItems": 3}, + "texparams": {"minItems":3, "maxItems": 3} + } + }, { + "title": "fixed 3Q doubly controlled gate", + "required": ["qubits"], + "properties": { + "name": {"enum": ["ccx"]}, + "qubits": {"description": "[control, control, target]", "minItems": 3, "maxItems": 3}, + "register": {"maxItems": 0}, + "params": {"maxItems": 0}, + "texparams": {"maxItems": 0} + } + }, { + "title": "measurement", + "required": ["qubits", "register"], + "properties": { + "name": {"enum": ["measure"]}, + "qubits": {"minItems": 1, "maxItems": 1}, + "register": {"minItems": 1, "maxItems": 1}, + "params": {"maxItems": 0}, + "texparams": {"maxItems": 0} + } + }, { + "title": "barrier", + "required": ["qubits"], + "properties": { + "name": {"enum": ["barrier"]}, + "qubits": {"minItems": 1}, + "register": {"maxItems": 0}, + "params": {"maxItems": 0}, + "texparams": {"maxItems": 0} + } + }, + { + "title": "snapshot", + "required": ["params"], + "properties": { + "name": {"enum": ["#snapshot"]}, + "register": {"maxItems": 0}, + "params": { + "minItems": 2, + "items": { + "type": "string" + } + }, + "texparams": {"maxItems": 0} + } + } + ] + } + }, + "oneOf": [ + {"allOf": [{"$ref": "#/definitions/qobjlevel0"}, + { + "properties": { + "type": { + "enum": [ "QASM" ]}, + "experiments": { + "items": { + "allOf": [ + {"$ref": "#/definitions/qobjexp"}, + {"properties": { + "instructions": { + "items": {"$ref": "#definitions/openqasm_instructions"} + } + } + }] + } + } + } + }]}, + {"allOf": [{"$ref": "#/definitions/qobjlevel0"}, + { + "properties": { + "type": { + "enum": [ "PULSE" ]}, + "config": { + "required": ["meas_level", "pulse_library", "register_slot_size", "meas_return", "qubit_lo_freq", "meas_lo_freq", "rep_rate"], + "properties": { + "meas_level": {"enum": [0,1,2]}, + "pulse_library": { + "type": "array", + "description": "Pulse library for the backend to use", + "items": { + "type": "object", + "required": ["name","samples"], + "properties": { + "name": { + "type": "string", + "description": "Pulse name"}, + "samples": {"$ref": "#/definitions/complex_array"} + }} + }, + "register_slot_size": { + "type": "integer", + "minimum": 0, + "default": 1, + "description": "Size of each register slot. For measurement level 0 (raw) this sets the length of each measurement acquisition" + }, + "meas_return": { + "enum": ["single","avg"], + "description": "Return each shot of data or average over the shots"}, + "qubit_lo_freq": { + "type": "array", + "description": "Qubit drive LO frequencies", + "minItems": 1, + "items": {"type": "number", "minimum": 0}}, + "meas_lo_freq": { + "type": "array", + "description": "Measurement LO frequencies", + "minItems": 1, + "items": {"type": "number", "minimum": 0}}, + "rep_rate": {"type": "integer", "minimum": 1} + } + }, + "experiments": { + "items": { + "allOf": [ + {"$ref": "#/definitions/qobjexp"}, + {"properties": { + "instructions": { + "items": {"$ref": "#/definitions/openpulse_instructions"} + } + } + }] + } + } + }}]} + ] +} + diff --git a/qiskit/schemas/result_schema.json b/qiskit/schemas/result_schema.json new file mode 100644 index 00000000000..f0607f9ae63 --- /dev/null +++ b/qiskit/schemas/result_schema.json @@ -0,0 +1,172 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "http://www.qiskit.org/schemas/result_schema.json", + "title": "qobj results", + "description": "The results of executing a qobj", + "definitions": { + "complex": { + "description": "JSON representation of a complex number", + "type": "array", + "minItems": 2, + "maxItems": 2, + "items": { + "type": "number" + } + }, + "complex_array": { + "description": "JSON representation of a complex vector", + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/complex" + } + }, + "complex_matrix": { + "description": "JSON representaiton of a complex matrix", + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/complex_array" + } + }, + "snapshot": { + "type": "object", + "description": "Snapshot of simulator internal representation", + "properties": { + "statevector": { + "description": "A list of complex state vectors for each shot", + "type": "array", + "items": { + "$ref": "#/definitions/complex_array" + } + }, + "unitary": { + "description": "A list of circuit unitary matrices for each shot", + "type": "array", + "items": { + "$ref": "#/definitions/complex_matrix" + } + } + } + }, + "register": { + "type": "array", + "minItems": 1, + "description": "Output of the registers"}, + "resultobj": { + "type": "object", + "required": ["success", "shots", "data"], + "properties": { + "shots": { + "oneOf": [{ + "type": "array", + "minItems": 2, "maxItems": 2, + "items": {"type": "integer", "minimum": 1}}, + {"type": "integer"}], + "description": "The starting and ending shot for this data. If there is only one shot to the experiment this is [1,1]" + }, + "success": { + "type": "boolean", + "description": "If true, we can trust results for this experiment." + }, + "status": { + "type": "string", + "description": "Human-readable description of status of this experiment" + }, + "seed": { + "type": "string", + "description": "Experiment-level random seed" + }, + "meas_return": { + "type": "string", + "enum": ["single","avg"], + "description": "Is the data in the register/snapshot averaged or from each shot" + }, + "header": { + "type": "object", + "properties": {}, + "description": "Header passed through from the qobj with experiment metadata"}, + "data": { + "type": "object", + "properties": { + "counts": { + "type": "object", + "description": "Histogram of the registers over the indicated shots", + "example": {"01011": 10, "10001": 102}, + "patternProperties": { + "^0x([0-9A-F])+$": {"type": "integer", + "minimum": 0 } + }, + "additionalProperties": false + }, + "snapshots": { + "description": "collection of all snapshots of simulator state", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/snapshot" + } + }, + "register": { + "$ref": "#/definitions/register" + }, + "statevector": { + "type": "array", + "items": { + "$ref": "#/definitions/complex_array" + } + }, + "unitary": { + "type": "array", + "items": { + "$ref": "#/definitions/complex_matrix" + } + } + } + } + } + } + }, + "type": "object", + "required": ["backend_name", "backend_version", "id", "job_id", "success", "results"], + "properties": { + "backend_name": { + "type": "string", + "description": "Backend name" + }, + "backend_version": { + "type": "string", + "pattern": "[0-9]+.[0-9]+.[0-9]+$", + "description": "Backend version in the form X.X.X" + }, + "id": { + "type": "string", + "description": "User generated id" + }, + "job_id": { + "type": "string", + "description": "Unique execution id from the backend" + }, + "date": { + "type": "string", + "format": "date-time", + "description": "Date/time of job execution" + }, + "success": { + "type": "boolean", + "description": "True if complete input qobj executed correctly. (Implies each experiment success)" + }, + "status": { + "type": "string", + "description": "Human-readable status of complete qobj execution" + }, + "header": { + "type": "object", + "properties": {}, + "description": "Header passed through from the qobj with job metadata"}, + "results": { + "type": "array", + "description": "Corresponding results for array of experiments of the input qobj", + "items": {"$ref": "#/definitions/resultobj"} + } + } +} diff --git a/test/python/test_backends.py b/test/python/test_backends.py index 7c5036597b8..58d328fa747 100644 --- a/test/python/test_backends.py +++ b/test/python/test_backends.py @@ -100,7 +100,7 @@ def test_local_backend_status(self): backend = local_provider.get_backend(name='local_qasm_simulator') status = backend.status schema_path = self._get_resource_path( - 'backends/backend_status_schema_py.json', path=Path.SCHEMAS) + 'deprecated/backends/backend_status_schema_py.json', path=Path.SCHEMAS) with open(schema_path, 'r') as schema_file: schema = json.load(schema_file) @@ -118,7 +118,7 @@ def test_remote_backend_status(self, QE_TOKEN, QE_URL): for backend in remotes: status = backend.status schema_path = self._get_resource_path( - 'backends/backend_status_schema_py.json', path=Path.SCHEMAS) + 'deprecated/backends/backend_status_schema_py.json', path=Path.SCHEMAS) with open(schema_path, 'r') as schema_file: schema = json.load(schema_file) jsonschema.validate(status, schema) @@ -133,7 +133,7 @@ def test_local_backend_configuration(self): for backend in local_backends: configuration = backend.configuration schema_path = self._get_resource_path( - 'backends/backend_configuration_schema_old_py.json', + 'deprecated/backends/backend_configuration_schema_old_py.json', path=Path.SCHEMAS) with open(schema_path, 'r') as schema_file: schema = json.load(schema_file) @@ -151,7 +151,7 @@ def test_remote_backend_configuration(self, QE_TOKEN, QE_URL): for backend in remotes: configuration = backend.configuration schema_path = self._get_resource_path( - 'backends/backend_configuration_schema_old_py.json', path=Path.SCHEMAS) + 'deprecated/backends/backend_configuration_schema_old_py.json', path=Path.SCHEMAS) with open(schema_path, 'r') as schema_file: schema = json.load(schema_file) jsonschema.validate(configuration, schema) diff --git a/test/schemas/check_schemas.py b/test/schemas/check_schemas.py new file mode 100644 index 00000000000..1a7de8d8e92 --- /dev/null +++ b/test/schemas/check_schemas.py @@ -0,0 +1,95 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 IBM RESEARCH. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================= + +""" +Created on Sat Apr 21 01:58:06 2018 + +@author: dcmckay + +Test the schemas against the examples as a batch file. +Run as `python test_schemas.py' +""" + +import os +import json +import jsonschema as jsch + +schema_tests = [] +verbose_err = False +any_error = False +cur_file_path = os.path.dirname(os.path.abspath(__file__)) +# go two directories up +cur_file_path = os.path.dirname(cur_file_path) +cur_file_path = os.path.dirname(cur_file_path) +cur_file_path = os.path.join(cur_file_path, 'qiskit', 'schemas') +print(cur_file_path) + +"""List the schemas and their examples.""" +schema_tests.append({"schema": "backend_config_schema.json", + "examples": [ + "backend_config_example_openpulse.json", + "backend_config_example_openqasm.json" + ]}) +schema_tests.append({"schema": "backend_props_schema.json", + "examples": [ + "backend_props_example.json" + ]}) +schema_tests.append({"schema": "backend_status_schema.json", + "examples": [ + "backend_status_example.json" + ]}) +schema_tests.append({"schema": "default_pulse_config_schema.json", + "examples": [ + "default_pulse_config_example.json" + ]}) +schema_tests.append({"schema": "job_status_schema.json", + "examples": [ + "job_status_example.json" + ]}) +schema_tests.append({"schema": "qobj_schema.json", + "examples": [ + "qobj_example_openpulse.json", + "qobj_example_openqasm.json" + ]}) +schema_tests.append({"schema": "result_schema.json", + "examples": [ + "result_example_openqasm.json", + "result_example_openpulse_lev0.json", + "result_example_openpulse_lev1.json", + "result_example_snapshots.json", + "result_example_statevector_simulator.json", + "result_example_unitary_simulator.json" + ]}) + +"""Run through each schema.""" +for schema_test in schema_tests: + print('Schema: %s' % (schema_test['schema'])) + for example_schema in schema_test['examples']: + schema = json.load(open(os.path.join(cur_file_path, + schema_test['schema']), 'r')) + example = json.load(open(os.path.join(cur_file_path, 'examples', + example_schema), 'r')) + try: + jsch.validate(example, schema) + except jsch.ValidationError as err: + print("Error on example %s:" % example_schema) + any_error = True + if verbose_err: + print(err) + continue + print('Passed: %s' % (example_schema)) +if not any_error: + print('ALL SCHEMAS PASSED')