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

Cannot pickle Frame objects under certain circumstances #1747

Open
2 tasks done
steve-jeffrey opened this issue Feb 27, 2024 · 0 comments
Open
2 tasks done

Cannot pickle Frame objects under certain circumstances #1747

steve-jeffrey opened this issue Feb 27, 2024 · 0 comments
Labels
bug 🐛 An issue that needs fixing.

Comments

@steve-jeffrey
Copy link

Pre-Report Checklist

  • I am running the latest versions of pyQuil and the Forest SDK
  • I checked to make sure that this bug has not already been reported

Issue Description

A Program containing Frames cannot be pickled if the frames member has been accessed.

For example, in the example below:

  • a pyQuil program with calibrations can be pickled
  • a pyQuil program's frames member cannot be pickled (but other individual members can be pickled, such as waveforms.
  • a pyQuil program with calibrations cannot be pickled if the frames have been accessed, for example, if the copy_everything_except_instructions() method has been called.

Code Snippet

import pickle
from typing import cast

from pyquil import get_qc
from pyquil.api import QPUCompiler

qc = get_qc("Ankaa-9Q-1")

compiler = cast(QPUCompiler, qc.compiler)

cals = compiler.get_calibration_program()

# Works
with open('/tmp/test', 'wb') as file:
    pickle.dump(cals, file)

# Works i.e. some individual members can be pickled
with open('/tmp/test', 'wb') as file:
    pickle.dump(cals.waveforms, file)

# Fails i.e. the frames member cannot be pickled
with open('/tmp/test', 'wb') as file:
    pickle.dump(cals.frames, file)

# Fails
tmp = cals.copy_everything_except_instructions()
with open('/tmp/test', 'wb') as file:
    pickle.dump(cals, file)

Error Output

Traceback (most recent call last):
  File "test.py", line 28, in <module>
    pickle.dump(cals, file)
TypeError: cannot pickle 'Frame' object

Environment Context

Operating System: Fedora 39
Python: 3.10
PyQuil: 4.7.0

@steve-jeffrey steve-jeffrey added the bug 🐛 An issue that needs fixing. label Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An issue that needs fixing.
Projects
None yet
Development

No branches or pull requests

1 participant