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

QPY Qiskit 1.0 updates #1365

Closed
wants to merge 15 commits into from
Closed

QPY Qiskit 1.0 updates #1365

wants to merge 15 commits into from

Conversation

kt474
Copy link
Member

@kt474 kt474 commented Feb 1, 2024

Copy link
Collaborator

@ElePT ElePT left a comment

Choose a reason for hiding this comment

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

Hi @kt474, I see a few 1.0 QPY changes not reflected in this PR, they were last-minute changes so I'm bringing them to your attention in case they had slipped under your radar (if not, feel free to ignore):

qiskit_ibm_runtime/qpy/exceptions.py Outdated Show resolved Hide resolved
Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>
@mtreinish
Copy link
Member

There's also: Qiskit/qiskit#11505

@mtreinish
Copy link
Member

FWIW, I just opened #1375 to track deleting the fork of the qpy module here. In qiskit 1.0.0 we added the necessary functionality to cover emitting older versions of the QPY format from qiskit.qpy.dump(). However, we obviously can't remove the fork until we're ready to set the qiskit dependency to >=1.0.0

@jyu00
Copy link
Collaborator

jyu00 commented Feb 5, 2024

Would this work with pre-1.0 QPY? Because the server is still at 0.*

@mtreinish
Copy link
Member

Would this work with pre-1.0 QPY? Because the server is still at 0.*

Yes, there is specifically overlap in the versions supported by dump() to enable this. The minimum qpy compatibility version is 10 in the 1.x series, which is the version dump() emits by qiskit 0.45.x and 0.46.x and is the maximum version load() supports in 0.45.x and 0.46.x. I outlined a few of the details in #1375 on how ideally we can do version negotiation if there is an API we can query to either figure out what the maximum qpy version is supported by the server (or alternatively which qiskit version is deployed)

@@ -44,7 +48,7 @@ def _write_parameter_vec(file_obj, obj): # type: ignore[no-untyped-def]
formats.PARAMETER_VECTOR_ELEMENT_PACK,
len(name_bytes),
obj._vector._size,
obj._uuid.bytes,
obj.uuid.bytes,
Copy link
Member Author

Choose a reason for hiding this comment

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

@mtreinish to be compatible with 0.45, this is causing an error

AttributeError: 'ParameterVectorElement' object has no attribute 'uuid'

Because uuid is added as an attribute to Parameter here, only in 1.0

How should this be handled here?

Copy link
Member

Choose a reason for hiding this comment

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

Fully porting the qpy changes from qiskit 1.0.0rc1 will inherently be unsound for use with qiskit 0.45.0 or 0.46.0. The internals of the qpy module are updated in lock-step with the QuantumCircuit class. This is basically the same underlying issue we hit that needed: Qiskit/qiskit-ibm-provider#757

This will also start emitting qpy version 11 which will cause a version mismatch with what the server side can parse until it is upgraded to qiskit 1.0.0. I pushed up: #1377 as an alternative to this which will let you do the upgrade in a manner which is compatible with both versions so you can publish a release that is both 0.45.x/0.46.x and 1.0.0 compatible. It also removes the vendored fork completely as it is not needed anymore (and luckily has never been released either, so there is no backwards compatibility issue).

Copy link
Member Author

Choose a reason for hiding this comment

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

Got it, thank you so much for taking care of this!

I'll close this PR

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll create a PR to do the same in qiskit-ibm-provider (but we can't remove the fork completely yet)

@1ucian0
Copy link
Member

1ucian0 commented Feb 5, 2024

@mtreinish wrote #1377 as an alternative to this PR. 1377 handles QPY in a way that supports qiskit 0.45/0.46 and 1.0.

@kt474 kt474 closed this Feb 5, 2024
@kt474 kt474 deleted the qpy-1.0 branch February 5, 2024 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update QPY Module for Qiskit 1.0
5 participants