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

Add QPY module #250

Merged
Merged

Commits on Feb 23, 2022

  1. Move QPY serializer to own module (#7582)

    * Move qpy to own module.
    
    qpy_serialization.py is splint into several files for maintenability. This commit also adds several bytes Enum classes for type keys in the header, and provides several helper functions. Some namedtuple class names are updated because, for example, INSTRUCTION will be vague when we add schedule, i.e. it's basically different program and has own instruction that has different data format. Basically CIRCUIT_ prefix is added to them.
    
    * manually cherry-pick #7584 with some cleanup
    
    - change qiskit.qpy.objects -> qiskit.qpy.binary_io
    - TUPLE -> SEQUENCE (we may use this for list in future)
    - add QpyError
    - add _write_register in circuit io to remove boilerplate code
    
    * respond to review comments
    - expose several private methods for backward compatibility
    - use options for symengine
    - rename alphanumeric -> value
    - rename write, read methods and remove alias
    - improve container read
    
    * remove import warning
    
    * replace alphanumeric with value in comments and messages.
    
    * private functions import
    
    Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
    2 people authored and rathishcholarajan committed Feb 23, 2022
    Configuration menu
    Copy the full SHA
    22637ce View commit details
    Browse the repository at this point in the history

Commits on Mar 11, 2022

  1. Add support for custom metadata serializers to QPY load() and dump() …

    …(#7550)
    
    * Add support for custom metadata serializers to QPY load() and dump()
    
    This commit adds a new argument to load(), metadata_serializer, and
    dump(), metadata_deserializer, which is used to specify custom
    serialization functions to use for serializing the python dictionary for
    each circuit's metadata attribute. By default QPY expects the serialized
    metadata payload to be encoded as a utf8 json string. But since there
    are no user constraints on the metadata dictionary's contents a simple
    json.dump() of the circuit's metadata attribute may not be feasible. To
    address this issue these new arguments are added to enable users to
    specify a custom function to encode the dictionary as binary data
    however is required for their circuit's metadata and then read that
    custom format as required when deserializing.
    
    The QPY format specification does not change here and still explicitly
    lists a UTF8 encoded JSON string as the contents. A fixed format is
    needed in the format specification for potential interoperability for
    other tools generating QPY data (none exist currently to my knowledge
    but nothing precludes it which is why the format is publicly
    documented). These new arguments are specific to only the qiskit
    implementation and should only be used when generating qpy files and
    loading them via qiskit.
    
    * Pivot to use JSONEncoder and JSONDecoder classes for new argument
    
    This commit pivots to leveraging custom JSONEncoder and JSONDecoder
    classes for the optional serializer and deserializer arguments instead
    of custom callables that return bytes. In the previous commit we used
    callables that would be passed the dictionary and returned bytes.
    However, while this was flexible it was pretty easy for a user to create
    QPY out of spec. While this was documented it is probably easier to just
    constrain the argument to always producing valid json. Using custom
    encoder and decoder classes let users still handle custom types but also
    restrict things to always be JSON. This should fix the potential risk in
    the previous iteration but still fix the underlying issue.
    
    * Update release note
    
    * Remove pylint ignores from release note example
    
    Co-authored-by: Jake Lishman <[email protected]>
    
    Co-authored-by: Jake Lishman <[email protected]>
    Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
    3 people authored and rathishcholarajan committed Mar 11, 2022
    Configuration menu
    Copy the full SHA
    ceeb993 View commit details
    Browse the repository at this point in the history

Commits on Mar 30, 2022

  1. Configuration menu
    Copy the full SHA
    045e6f3 View commit details
    Browse the repository at this point in the history

Commits on Mar 31, 2022

  1. Configuration menu
    Copy the full SHA
    6389232 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    2fa23f2 View commit details
    Browse the repository at this point in the history