Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

QPY serialization fails under Qiskit 0.45rc1 #755

Closed
nonhermitian opened this issue Oct 20, 2023 · 3 comments
Closed

QPY serialization fails under Qiskit 0.45rc1 #755

nonhermitian opened this issue Oct 20, 2023 · 3 comments
Labels
type: bug Something isn't working

Comments

@nonhermitian
Copy link
Contributor

Information

  • qiskit-ibm-provider version: latest
  • Python version:
  • Operating system:

What is the current behavior?

Trying to submit a circuit to a IBM device gives

 File "/home/ray/anaconda3/lib/python3.9/site-packages/qiskit_ibm_provider/qpy/common.py", line 206, in data_to_binary
    serializer(container, obj, **kwargs)
  File "/home/ray/anaconda3/lib/python3.9/site-packages/qiskit_ibm_provider/qpy/binary_io/circuits.py", line 993, in write_circuit
    circuit.metadata, separators=(",", ":"), cls=metadata_serializer
AttributeError: 'NoneType' object has no attribute 'metadata'

Steps to reproduce the problem

try to submit a circuit using Qiskit 0.45rc1

What is the expected behavior?

It works like it did in Qiskit-terra==0.25.2

Suggested solutions

@nonhermitian nonhermitian added the type: bug Something isn't working label Oct 20, 2023
@kt474
Copy link
Member

kt474 commented Oct 20, 2023

I'm getting the same error on all jobs - I believe this should be fixed by #736 after the qiskit version is also updated on the ntc-provider side.

Currently getting this error for all jobs on my updated qpy branch.

IBMJobFailureError: "Job failed: TypeError: Invalid payload format data kind 'b'p''."

cc: @mtreinish

@mtreinish
Copy link
Member

As we discussed offline this error message is being caused by the server side not having a new enough version of qiskit to read the QPY format version 10 being emitted with #736. I pushed up a pull request to address the error message to make it more clear: Qiskit/qiskit#11074

Until we're able to upgrade the server side with 0.45.0 final, to support using qiskit-ibm-provider with 0.45.0rc1 we'll have to have an intermediate update to the provider's qpy form that fixes the controlled gate error reported in this issue but doesn't include the payload format changes introduced in qiskit 0.45.0rc1.

mtreinish added a commit to mtreinish/qiskit-ibm that referenced this issue Oct 24, 2023
The qiskit-ibm-provider package maintains a fork of the QPY
serialization module from upstream qiskit. This is done primarily
because Qiskit only supports writing a single qpy format version per
release (whatever the most recent is). However, since the server side of
the ibm runtime version does not always support the latest QPY format
version immediately and tends to lag a bit behind what upstream Qiskit
is emitting. The fork in qiskit-ibm-provider is used to control the
QPY format version that is used for job submission so it ensure the
leading edge only moves as quickly as the server side is updated.
However, for the upcoming qiskit 0.45.0 release there were some internal
object model changes and the fork of qpy (which is a copy of the qpy
module from qiskit-terra 0.25.x/qiskit 0.44.x) is incompatible with
those changes. This results in errors during the serialization because
the qpy module is trying to serialize the circuit with assumptions of
the code that do not hold with the upcoming 0.45.0 release. To further
complicate matters qiskit 0.45.0 also introduced QPY version 10 which is
completely incompatible with version 9 being used by the ibm runtime
currently. This means the normal strategy of porting all the changes
from qiskit during the upcoming release to the provider isn't viable in
the short term, at least until the server side is updated to support QPY
version 10.

To address this compatibility in the short term, this commit is a partial
backport of the changes made in qiskit 0.45.0 to the qpy module, but only
those changes made to accomodate the internal qiskit changes during the
release. It's also done in a manner where it doesn't require the 0.45.0
release, so that the provider can be used with either qiskit 0.44.x and
0.45.0. However, this is only a short term solution, once the server side
is updated to support QPY we should use Qiskit#736 and release a new minor
version of the provider package to just use QPY format version 10.

This commit is explicitly only for the 0.7.x release series and is being
proposed directly to the stable/0.7 branch. For 0.8.0 Qiskit#736 will port
over the upstream changes to QPY including QPY format version 10 which
is a more sustianable fix longer term. But this is blocked until the
server side has support for QPY format version 10. To simplify the
dependency tree, and to enable users to submit ibm runtime jobs using
0.45.0rc1 this targets solely compatibility between qiskit 0.45.0 and
qiskit-ibm-provider 0.7.x.

Fixes Qiskit#755
kt474 added a commit that referenced this issue Oct 25, 2023
The qiskit-ibm-provider package maintains a fork of the QPY
serialization module from upstream qiskit. This is done primarily
because Qiskit only supports writing a single qpy format version per
release (whatever the most recent is). However, since the server side of
the ibm runtime version does not always support the latest QPY format
version immediately and tends to lag a bit behind what upstream Qiskit
is emitting. The fork in qiskit-ibm-provider is used to control the
QPY format version that is used for job submission so it ensure the
leading edge only moves as quickly as the server side is updated.
However, for the upcoming qiskit 0.45.0 release there were some internal
object model changes and the fork of qpy (which is a copy of the qpy
module from qiskit-terra 0.25.x/qiskit 0.44.x) is incompatible with
those changes. This results in errors during the serialization because
the qpy module is trying to serialize the circuit with assumptions of
the code that do not hold with the upcoming 0.45.0 release. To further
complicate matters qiskit 0.45.0 also introduced QPY version 10 which is
completely incompatible with version 9 being used by the ibm runtime
currently. This means the normal strategy of porting all the changes
from qiskit during the upcoming release to the provider isn't viable in
the short term, at least until the server side is updated to support QPY
version 10.

To address this compatibility in the short term, this commit is a partial
backport of the changes made in qiskit 0.45.0 to the qpy module, but only
those changes made to accomodate the internal qiskit changes during the
release. It's also done in a manner where it doesn't require the 0.45.0
release, so that the provider can be used with either qiskit 0.44.x and
0.45.0. However, this is only a short term solution, once the server side
is updated to support QPY we should use #736 and release a new minor
version of the provider package to just use QPY format version 10.

This commit is explicitly only for the 0.7.x release series and is being
proposed directly to the stable/0.7 branch. For 0.8.0 #736 will port
over the upstream changes to QPY including QPY format version 10 which
is a more sustianable fix longer term. But this is blocked until the
server side has support for QPY format version 10. To simplify the
dependency tree, and to enable users to submit ibm runtime jobs using
0.45.0rc1 this targets solely compatibility between qiskit 0.45.0 and
qiskit-ibm-provider 0.7.x.

Fixes #755

Co-authored-by: Kevin Tian <kevin.tian@ibm.com>
@kt474
Copy link
Member

kt474 commented Oct 25, 2023

fixed by #757, in newest release 0.7.2

@kt474 kt474 closed this as completed Oct 25, 2023
dieris pushed a commit to dieris/qiskit-ibm-provider that referenced this issue Dec 12, 2023
The qiskit-ibm-provider package maintains a fork of the QPY
serialization module from upstream qiskit. This is done primarily
because Qiskit only supports writing a single qpy format version per
release (whatever the most recent is). However, since the server side of
the ibm runtime version does not always support the latest QPY format
version immediately and tends to lag a bit behind what upstream Qiskit
is emitting. The fork in qiskit-ibm-provider is used to control the
QPY format version that is used for job submission so it ensure the
leading edge only moves as quickly as the server side is updated.
However, for the upcoming qiskit 0.45.0 release there were some internal
object model changes and the fork of qpy (which is a copy of the qpy
module from qiskit-terra 0.25.x/qiskit 0.44.x) is incompatible with
those changes. This results in errors during the serialization because
the qpy module is trying to serialize the circuit with assumptions of
the code that do not hold with the upcoming 0.45.0 release. To further
complicate matters qiskit 0.45.0 also introduced QPY version 10 which is
completely incompatible with version 9 being used by the ibm runtime
currently. This means the normal strategy of porting all the changes
from qiskit during the upcoming release to the provider isn't viable in
the short term, at least until the server side is updated to support QPY
version 10.

To address this compatibility in the short term, this commit is a partial
backport of the changes made in qiskit 0.45.0 to the qpy module, but only
those changes made to accomodate the internal qiskit changes during the
release. It's also done in a manner where it doesn't require the 0.45.0
release, so that the provider can be used with either qiskit 0.44.x and
0.45.0. However, this is only a short term solution, once the server side
is updated to support QPY we should use Qiskit#736 and release a new minor
version of the provider package to just use QPY format version 10.

This commit is explicitly only for the 0.7.x release series and is being
proposed directly to the stable/0.7 branch. For 0.8.0 Qiskit#736 will port
over the upstream changes to QPY including QPY format version 10 which
is a more sustianable fix longer term. But this is blocked until the
server side has support for QPY format version 10. To simplify the
dependency tree, and to enable users to submit ibm runtime jobs using
0.45.0rc1 this targets solely compatibility between qiskit 0.45.0 and
qiskit-ibm-provider 0.7.x.

Fixes Qiskit#755

Co-authored-by: Kevin Tian <kevin.tian@ibm.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants