-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Update the qobj schema to support pulse gate calibrations. #4761
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
Merged
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
6b099f8
Update the qobj schema to support pulse gate calibrations.
lcapelluto 764f8c7
Fixup qobj classes: add docstrings, call out to super
lcapelluto e80e839
Merge remote-tracking branch 'upstream/master' into pulse-gates/schema
lcapelluto e195b3a
Move pulse library to top level. Fill in more details in qasm_qobj.py
lcapelluto 8d7fd5c
Fix mistake in schema: the pulse_library definition already contains …
lcapelluto d6d0d73
Move pulse library to top level in qasm_qobj.py as well
lcapelluto 01e8cbf
Add GateCalibration to qobj/__init__.py
lcapelluto d9b1c0c
Fixup some implementation errors: gates contains a list of dict items…
lcapelluto 8ffc521
Put gate calibrations into calibrations.gates to leave room for addin…
lcapelluto 7edf6d3
Add an example json
lcapelluto f6318ca
Schema version should be referenced not hardcoded a second time
lcapelluto 4bf931f
Pretty print example file
lcapelluto b652f2e
Merge branch 'master' into pulse-gates/schema
lcapelluto 636f1cc
Check if calibrations is present when doing to from dict
lcapelluto 0bae536
Fixup qobj test
lcapelluto ea72add
Update the qobj schema to support pulse gate calibrations.
lcapelluto 1033384
Fixup qobj classes: add docstrings, call out to super
lcapelluto f3b36c1
Move pulse library to top level. Fill in more details in qasm_qobj.py
lcapelluto dbf85b1
Fix mistake in schema: the pulse_library definition already contains …
lcapelluto 7cd80d2
Move pulse library to top level in qasm_qobj.py as well
lcapelluto b44d018
Add GateCalibration to qobj/__init__.py
lcapelluto af04a34
Fixup some implementation errors: gates contains a list of dict items…
lcapelluto e761e1f
Put gate calibrations into calibrations.gates to leave room for addin…
lcapelluto e6d0a42
Add an example json
lcapelluto 7c9e33d
Schema version should be referenced not hardcoded a second time
lcapelluto faf155e
Pretty print example file
lcapelluto 158c4de
Update backend snapshots with new conf or defs (#4897)
mtreinish ec3997f
One reference to get_sample_pulse is raising deprecation warnings fro…
lcapelluto 0633bf0
Check if calibrations is present when doing to from dict
lcapelluto 6cfbdb6
Fixup qobj test
lcapelluto 21b9366
Merge branch 'master' into pulse-gates/schema
lcapelluto 5cdaaa6
Add qobj.config.calibrations for common cals
lcapelluto ed30a25
Merge branch 'pulse-gates/schema' of github.com:lcapelluto/qiskit-ter…
lcapelluto d75ecac
style
lcapelluto 63f85ff
Merge remote-tracking branch 'upstream/master' into pulse-gates/schema
lcapelluto 6e5c968
Move recent qasm qobj changes to the new qobj.common file
lcapelluto 71e06b4
Update schema with qobj level and experiment level calibrations
lcapelluto 4e59942
Add schema test
lcapelluto 2d45267
Apply suggestions from code review
lcapelluto 989f20d
Merge branch 'master' into pulse-gates/schema
lcapelluto 6a836cf
Fix encoding for validation of new pulse library field in qasm qobj. …
lcapelluto 58ea1ff
Merge branch 'pulse-gates/schema' of github.com:lcapelluto/qiskit-ter…
lcapelluto 6de11b4
Merge branch 'master' into pulse-gates/schema
mergify[bot] 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 hidden or 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
This file contains hidden or 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,83 @@ | ||
| # This code is part of Qiskit. | ||
| # | ||
| # (C) Copyright IBM 2020. | ||
| # | ||
| # 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. | ||
| # pylint: disable=invalid-name | ||
|
|
||
| """Module providing definitions of common Qobj classes.""" | ||
| import json | ||
| import os | ||
| from types import SimpleNamespace | ||
|
|
||
| import fastjsonschema | ||
|
|
||
|
|
||
| path_part = 'schemas/qobj_schema.json' | ||
| path = os.path.join( | ||
| os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | ||
| path_part) | ||
| with open(path) as fd: | ||
| json_schema = json.loads(fd.read()) | ||
| validator = fastjsonschema.compile(json_schema) | ||
|
lcapelluto marked this conversation as resolved.
mtreinish marked this conversation as resolved.
|
||
|
|
||
|
|
||
| class QobjDictField(SimpleNamespace): | ||
| """A class used to represent a dictionary field in Qobj | ||
|
|
||
| Exists as a backwards compatibility shim around a dictionary for Qobjs | ||
| previously constructed using marshmallow. | ||
| """ | ||
|
|
||
| def __init__(self, **kwargs): | ||
| """Instantiate a new Qobj dict field object. | ||
|
|
||
| Args: | ||
| kwargs: arbitrary keyword arguments that can be accessed as | ||
| attributes of the object. | ||
| """ | ||
| self.__dict__.update(kwargs) | ||
|
|
||
| def to_dict(self): | ||
| """Return a dictionary format representation of the QASM Qobj. | ||
|
|
||
| Returns: | ||
| dict: The dictionary form of the QobjHeader. | ||
| """ | ||
| return self.__dict__ | ||
|
|
||
| @classmethod | ||
| def from_dict(cls, data): | ||
| """Create a new QobjHeader object from a dictionary. | ||
|
|
||
| Args: | ||
| data (dict): A dictionary representing the QobjHeader to create. It | ||
| will be in the same format as output by :func:`to_dict`. | ||
|
|
||
| Returns: | ||
| QobjDictFieldr: The QobjDictField from the input dictionary. | ||
| """ | ||
|
|
||
| return cls(**data) | ||
|
|
||
| def __eq__(self, other): | ||
| if isinstance(other, self.__class__): | ||
| if self.__dict__ == other.__dict__: | ||
| return True | ||
| return False | ||
|
|
||
|
|
||
| class QobjHeader(QobjDictField): | ||
| """A class used to represent a dictionary header in Qobj objects.""" | ||
| pass | ||
|
|
||
|
|
||
| class QobjExperimentHeader(QobjHeader): | ||
| """A class representing a header dictionary for a Qobj Experiment.""" | ||
| pass | ||
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.