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

Serialization v1.0 #241

Merged
merged 9 commits into from
Mar 4, 2025

Conversation

arcondello
Copy link
Member

@arcondello arcondello commented Feb 25, 2025

Note this PR does not increment the default serialization version. We'll do that in 0.7.0.

In a followup PR that I am already working on, I will add CI testing backwards and forwards in time checking that models serialized by package version 0.5.2 are loadable from 0.6.0+ and vice versa.

The docs need another pass or two for clarity, but better than the # TODO that was there before 🙂

Specifically change
Symbol._state_from_zipfile() and Symbol._state_into_zipfile()
to the plural
Symbol._states_from_zipfile() and Symbol._states_into_zipfile().

Also Nodes now broadcast whether or not their state is
deterministic. Previously we used their status as a decision or
no to decide which nodes get their states saved. Now we save the
state of any node with a non-deterministic state.
@arcondello arcondello force-pushed the feature/serialization-v1 branch 2 times, most recently from f4e808e to 3de57c8 Compare February 27, 2025 16:28
@arcondello arcondello force-pushed the feature/serialization-v1 branch from f654205 to afc55fe Compare February 28, 2025 15:49
@arcondello arcondello force-pushed the feature/serialization-v1 branch from b5192e4 to 4268631 Compare March 3, 2025 23:45
@arcondello arcondello requested a review from randomir March 3, 2025 23:50
@arcondello arcondello marked this pull request as ready for review March 3, 2025 23:50

The serialization version is saved in a file ``version.txt``.

The states have the following structure.
Copy link
Member Author

Choose a reason for hiding this comment

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

This should note that only the states of decisions and other non-deterministic symbols is saved. I will fix.

Copy link
Member

Choose a reason for hiding this comment

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

the code below for v1.0 uses only_decision=False

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, because it's using the if symbol.deterministic_state(): continue logic instead. Before we just hard-limited it to decisions which gave the same thing if you don't have non-determistic intermediate nodes (which we currently do not, but want to add).

Copy link
Member

@randomir randomir left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +348 to +349
if symbol._deterministic_state():
continue
Copy link
Member

Choose a reason for hiding this comment

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

I see advantages of skipping deterministic states on load (since source of truth), but less so on save. Sure, we'll save some space, but to read out (construct) all the states, one now has to construct the whole model.

Copy link
Member Author

Choose a reason for hiding this comment

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

In many models saving all states would increase the state size by orders of magnitude. The way it's set up currently the state of intermediate variables is calculated lazily rather than eagerly.

Copy link
Member

@randomir randomir Mar 4, 2025

Choose a reason for hiding this comment

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

Inspecting states of large models is a use case I was thinking about. Perhaps you don't want to construct the huge model just to check states if debugging? So, not serializing by default is fine, but maybe leave that option open for users?


The serialization version is saved in a file ``version.txt``.

The states have the following structure.
Copy link
Member

Choose a reason for hiding this comment

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

the code below for v1.0 uses only_decision=False

Copy link
Member

Choose a reason for hiding this comment

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

I would add serialization tests for model and states that verify loading/failing of mismatched version (0.1 in 1.0 and 1.0 in 0.1).

Copy link
Member Author

@arcondello arcondello Mar 4, 2025

Choose a reason for hiding this comment

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

Totally agree. That's in the next PR.

Edit: added some simple ones in e6e4379. More forthcoming.

@arcondello arcondello merged commit cad3af1 into dwavesystems:main Mar 4, 2025
35 checks passed
@arcondello arcondello deleted the feature/serialization-v1 branch March 4, 2025 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants