-
Notifications
You must be signed in to change notification settings - Fork 26
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
Changes from 47 commits
ffd2781
183b361
299d7c2
377e168
3e046dd
c565ff8
1849443
18af181
aed9bbe
bcf6256
337867e
8d946fa
82609b6
255fcd7
1886b62
141f86c
158e3ff
a63eb71
1c1e6f8
126276d
e3c233b
3f284dc
9ce0aeb
5ccb378
420d814
55a7c67
6913d3d
54ab15d
7c1b9fc
e3ff48a
ce5231b
5b117e3
0b361c3
520983b
ca09808
2cd2681
5cb7635
16f4322
7387a4b
24579c4
7983a03
34a6cb4
74e3c83
167a74d
ab2c1d4
1441aa2
7687e6e
7335f96
f6304e8
b9f8687
bbf4bd9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[flake8] | ||
max-line-length = 120 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ fastjsonschema | |
jsonschema | ||
jsonschema-rs | ||
ddt | ||
qiskit-ibm-runtime@git+https://[email protected]/Qiskit/qiskit-ibm-runtime.git | ||
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
{ | ||
"$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"}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this type should be an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in |
||
{"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" | ||
} | ||
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
|
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 inqiskit-ibm-runtime
which I already fixed (e.g. it considered value of0
for a pec-option as booleanFalse
and so did not check whether theenable-pec
option isTrue
. Really minor stuff.