-
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
Merged
Merged
Changes from 50 commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
ffd2781
Partial version of EstimatorV2 input schema
gadial 183b361
Full EstimatorV2 schema
gadial 299d7c2
Added SamplerV2 schema and added `seed_estimator` to estimator schema
gadial 377e168
Updating the estimator schema after options changes in qiskit runtime
gadial 3e046dd
Updated SamplerV2 schema
gadial c565ff8
Update schemas/estimator_v2_schema.json
gadial 1849443
Update schemas/estimator_v2_schema.json
gadial 18af181
Update schemas/estimator_v2_schema.json
gadial aed9bbe
Fixes according to PR review
gadial bcf6256
Update schemas/estimator_v2_schema.json
gadial 337867e
Update schemas/estimator_v2_schema.json
gadial 8d946fa
Update schemas/estimator_v2_schema.json
gadial 82609b6
Update schemas/estimator_v2_schema.json
gadial 255fcd7
Update schemas/sampler_v2_schema.json
gadial 1886b62
Update schemas/sampler_v2_schema.json
gadial 141f86c
Update schemas/estimator_v2_schema.json
gadial 158e3ff
Update schemas/estimator_v2_schema.json
gadial a63eb71
Update schemas/estimator_v2_schema.json
gadial 1c1e6f8
Update schemas/estimator_v2_schema.json
gadial 126276d
Update schemas/estimator_v2_schema.json
gadial e3c233b
Update schemas/estimator_v2_schema.json
gadial 3f284dc
Update schemas/estimator_v2_schema.json
gadial 9ce0aeb
Update schemas/estimator_v2_schema.json
gadial 5ccb378
Update schemas/estimator_v2_schema.json
gadial 420d814
Update schemas/estimator_v2_schema.json
gadial 55a7c67
Starting to add tests
gadial 6913d3d
Added a framework to test schema vs runtime validator
gadial 54ab15d
Added dynamical decoupling tests and fixed some bugs in the framework
gadial 7c1b9fc
Test for resilience boolean values and schema fix based on the test
gadial e3ff48a
Tests for zne options; extended the schema to validate correct number…
gadial ce5231b
Improving the test framework
gadial 5b117e3
Updated the schema to verify zne implies zne_mitigation=True, and mea…
gadial 0b361c3
Added pec options tests and updated the schema to require `pec_mitiga…
gadial 520983b
Added noise learning tests
gadial ca09808
Added execution and twirling tests
gadial 2cd2681
Added Sampler tests
gadial 5cb7635
linting
gadial 16f4322
Schema fix: `noise_gain` is inclusive minimum
gadial 7387a4b
Added default shots/precision
gadial 24579c4
Added `support_qiskit`
gadial 7983a03
Additional data on PUBS
gadial 34a6cb4
Allow longer line length with flake8
gadial 74e3c83
linting
gadial 167a74d
Switching to test against the `main` branch of `qiskit-ibm-runtime`
gadial ab2c1d4
use https instead of ssh
gadial 1441aa2
Fixes
gadial 7687e6e
Fixes
gadial 7335f96
Fix shots
jyu00 f6304e8
Added `meas_type` to Sampler schema
gadial b9f8687
QuantumCircuit can be either object or string
gadial bbf4bd9
Change back to shots
jyu00 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[flake8] | ||
max-line-length = 120 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
|
||
} | ||
} | ||
} | ||
}, | ||
"default_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
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.