-
Notifications
You must be signed in to change notification settings - Fork 615
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
Fix snapshot wire order when simulation indices different than device wires #6461
Conversation
Hello. You may have forgotten to update the changelog!
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## v0.39.0-rc0 #6461 +/- ##
==============================================
Coverage ? 99.38%
==============================================
Files ? 452
Lines ? 42819
Branches ? 0
==============================================
Hits ? 42557
Misses ? 262
Partials ? 0 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One suggestion, otherwise LGTM!
This is dealing with a hardcoded testcases, so it should be safe to replace the redundancy with suggestions. Co-authored-by: Astral Cai <astral.cai@xanadu.ai>
Co-authored-by: Astral Cai <astral.cai@xanadu.ai>
Context:
Internally, default qubit only performs the simulation with the wires that it needs for apply the operation. Any wires only present in measurements are only added in at the very end. This can be substantially more memory and time efficient in certain edge cases.
Unfortunately, this can cause confusion about the snapshotted state taken mid-simulation. Mid simulation we have fewer wires and a different wire order.
Description of the Change:
map_wires
method to snapshot to allow us to map the wiresvalidate_device_wires
.StateMP.process_state
to add in blank subsystems when the measurement has wires not present in the state's wire order.These three steps are sufficient to make sure that snapshots always match the device's wire order.
Benefits:
Less Confusion
Possible Drawbacks:
It's no longer the state being used during the simulation at that point. We are hiding away the fact we are working with a different state during the simulation.
Related GitHub Issues:
Fixes #6427 [sc-76515]