Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PrimitivesV2 schemas #14

Merged
merged 51 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
ffd2781
Partial version of EstimatorV2 input schema
gadial Feb 28, 2024
183b361
Full EstimatorV2 schema
gadial Feb 29, 2024
299d7c2
Added SamplerV2 schema and added `seed_estimator` to estimator schema
gadial Feb 29, 2024
377e168
Updating the estimator schema after options changes in qiskit runtime
gadial Mar 11, 2024
3e046dd
Updated SamplerV2 schema
gadial Mar 11, 2024
c565ff8
Update schemas/estimator_v2_schema.json
gadial Mar 13, 2024
1849443
Update schemas/estimator_v2_schema.json
gadial Mar 13, 2024
18af181
Update schemas/estimator_v2_schema.json
gadial Mar 13, 2024
aed9bbe
Fixes according to PR review
gadial Mar 13, 2024
bcf6256
Update schemas/estimator_v2_schema.json
gadial Apr 3, 2024
337867e
Update schemas/estimator_v2_schema.json
gadial Apr 3, 2024
8d946fa
Update schemas/estimator_v2_schema.json
gadial Apr 3, 2024
82609b6
Update schemas/estimator_v2_schema.json
gadial Apr 3, 2024
255fcd7
Update schemas/sampler_v2_schema.json
gadial Apr 3, 2024
1886b62
Update schemas/sampler_v2_schema.json
gadial Apr 3, 2024
141f86c
Update schemas/estimator_v2_schema.json
gadial Apr 3, 2024
158e3ff
Update schemas/estimator_v2_schema.json
gadial Apr 3, 2024
a63eb71
Update schemas/estimator_v2_schema.json
gadial Apr 3, 2024
1c1e6f8
Update schemas/estimator_v2_schema.json
gadial Apr 3, 2024
126276d
Update schemas/estimator_v2_schema.json
gadial Apr 3, 2024
e3c233b
Update schemas/estimator_v2_schema.json
gadial Apr 3, 2024
3f284dc
Update schemas/estimator_v2_schema.json
gadial Apr 3, 2024
9ce0aeb
Update schemas/estimator_v2_schema.json
gadial Apr 3, 2024
5ccb378
Update schemas/estimator_v2_schema.json
gadial Apr 3, 2024
420d814
Update schemas/estimator_v2_schema.json
gadial Apr 3, 2024
55a7c67
Starting to add tests
gadial Apr 3, 2024
6913d3d
Added a framework to test schema vs runtime validator
gadial Apr 3, 2024
54ab15d
Added dynamical decoupling tests and fixed some bugs in the framework
gadial Apr 4, 2024
7c1b9fc
Test for resilience boolean values and schema fix based on the test
gadial Apr 4, 2024
e3ff48a
Tests for zne options; extended the schema to validate correct number…
gadial Apr 5, 2024
ce5231b
Improving the test framework
gadial Apr 8, 2024
5b117e3
Updated the schema to verify zne implies zne_mitigation=True, and mea…
gadial Apr 8, 2024
0b361c3
Added pec options tests and updated the schema to require `pec_mitiga…
gadial Apr 23, 2024
520983b
Added noise learning tests
gadial Apr 23, 2024
ca09808
Added execution and twirling tests
gadial Apr 23, 2024
2cd2681
Added Sampler tests
gadial Apr 23, 2024
5cb7635
linting
gadial Apr 23, 2024
16f4322
Schema fix: `noise_gain` is inclusive minimum
gadial Apr 23, 2024
7387a4b
Added default shots/precision
gadial Apr 23, 2024
24579c4
Added `support_qiskit`
gadial Apr 23, 2024
7983a03
Additional data on PUBS
gadial Apr 24, 2024
34a6cb4
Allow longer line length with flake8
gadial Apr 24, 2024
74e3c83
linting
gadial Apr 24, 2024
167a74d
Switching to test against the `main` branch of `qiskit-ibm-runtime`
gadial Apr 25, 2024
ab2c1d4
use https instead of ssh
gadial Apr 25, 2024
1441aa2
Fixes
gadial Apr 25, 2024
7687e6e
Fixes
gadial Apr 25, 2024
7335f96
Fix shots
jyu00 May 20, 2024
f6304e8
Added `meas_type` to Sampler schema
gadial May 21, 2024
b9f8687
QuantumCircuit can be either object or string
gadial May 21, 2024
bbf4bd9
Change back to shots
jyu00 May 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length = 120
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ fastjsonschema
jsonschema
jsonschema-rs
ddt
qiskit-ibm-runtime@git+https://[email protected]/Qiskit/qiskit-ibm-runtime.git
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason we want to install from main branch and not just the latest release?

Copy link
Contributor Author

@gadial gadial May 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally it was qiskit-ibm-runtime>=0.22 but I changed it because we had test failures due to obsolete code. I tried switching to 0.23 and had a similar problem now. That's because of small errors in qiskit-ibm-runtime which I already fixed (e.g. it considered value of 0 for a pec-option as boolean False and so did not check whether the enable-pec option is True. Really minor stuff.

606 changes: 606 additions & 0 deletions schemas/estimator_v2_schema.json

Large diffs are not rendered by default.

89 changes: 89 additions & 0 deletions schemas/sampler_v2_schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "http://www.qiskit.org/schemas/sampler_v2_schema.json",
"title": "SamplerV2 input",
"description": "The input for an SamplerV2 API call",
"version": "1.0.0",
"type": "object",
"required": ["pubs"],
"properties": {
"pubs": {
"type": "array",
"description": "Primitive Unit Blocs of data. Each PUB is of the form (Circuit, Parameters, Shots) where the circuit is required, parameters should be passed only for parametrized circuits, and shots is optional",
"items": {
"type": "array",
"minItems": 1,
"prefixItems": [
{"description": "The quantum circuit in QASM string or base64-encoded QPY format. See https://docs.quantum.ibm.com/api/qiskit/qpy for more details on QPY.", "type": ["object", "string"]},
{"description": "A dictionary of the parameter values. The keys are the names of the parameters, and the values are the actual parameter values.", "type": "object"},
{"description": "The number of shots to use in this pub", "type": "integer"}
]
}
},
"options": {
"type": "object",
"description": "Options for V2 Sampler",
"properties": {
"default_shots": {
"description": "The default number of shots to use if none are specified in the PUBs",
"type": "integer"
},
"dynamical_decoupling": {
"description": "Suboptions for dynamical decoupling",
"type": "object",
"properties": {
"enable": {
"description": "Whether to enable DD as specified by the other options in this class",
"type": "boolean"
},
"sequence_type": {
"description": "Which dynamical decoupling sequence to use",
"type": "string",
"enum": ["XX", "XpXm", "XY4"]
},
"extra_slack_distribution": {
"description": "Where to put extra timing delays due to rounding issues",
"type": "string",
"enum": ["middle", "edges"]
},
"scheduling_method": {
"description": "Whether to schedule gates as soon as ('asap') or as late as ('alap') possible",
"type": "string",
"enum": ["alap", "asap"]
}
}
},
"execution": {
"description": "Execution options",
"type": "object",
"properties": {
"init_qubits": {
"description": "Whether to reset the qubits to the ground state for each shot",
"type": "boolean"
},
"rep_delay": {
"description": "The delay between a measurement and the subsequent quantum circuit",
"type": "number"
},
"meas_type": {
"description": "How to process and return measurement results",
"enum": ["classified", "kerneled", "avg_kerneled"]
}
jyu00 marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
},
"shots": {
jyu00 marked this conversation as resolved.
Show resolved Hide resolved
"description": "Default number of shots which applies to all pubs without shots",
"type": "integer"
},
"support_qiskit": {
"description": "If True, returns a qiskit-style output, meant to be parsed using the runtime result decoder, or resort to returning pure JSON results (resulting in larger objects)",
"type": "boolean"
},
"version": {
"description": "For SamplerV2, version should always be 2",
"enum": [2]
}
}
}
jyu00 marked this conversation as resolved.
Show resolved Hide resolved
51 changes: 51 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2017.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

"""With some utils"""

import itertools
from ddt import data, unpack


class Case(dict):
"""<no description>"""


def generate_cases(docstring, dsc=None, name=None, **kwargs):
"""Combines kwargs in Cartesian product and creates Case with them"""
ret = []
keys = kwargs.keys()
vals = kwargs.values()
for values in itertools.product(*vals):
case = Case(zip(keys, values))
if docstring is not None:
setattr(case, "__doc__", docstring.format(**case))
if dsc is not None:
setattr(case, "__doc__", dsc.format(**case))
if name is not None:
setattr(case, "__name__", name.format(**case))
ret.append(case)
return ret


def combine(**kwargs):
"""Decorator to create combinations and tests
@combine(level=[0, 1, 2, 3],
circuit=[a, b, c, d],
dsc='Test circuit {circuit.__name__} with level {level}',
name='{circuit.__name__}_level{level}')
"""

def deco(func):
return data(*generate_cases(docstring=func.__doc__, **kwargs))(unpack(func))

return deco
Loading
Loading