Skip to content

Enable serialization of non-GridQubits. #2966

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

Merged
merged 11 commits into from
May 13, 2020

Conversation

95-martin-orion
Copy link
Collaborator

@95-martin-orion 95-martin-orion commented May 4, 2020

Fixes #1325.

Most of the work was already done here - the only remaining effort was to remove checks and add a mux for the deserialize methods. This does have a noticeable side-effect: this code now accepts any proto ID as a valid qubit, since NamedQubit has no restrictions on the strings allowed as names.

As an aside, it's a little odd that we use x_y notation for GridQubits, when int('1_2') returns 12. This makes parsing strings as different qubit types order-dependent.

@95-martin-orion 95-martin-orion requested a review from dabacon May 4, 2020 17:18
@googlebot googlebot added the cla: yes Makes googlebot stop complaining. label May 4, 2020
@dabacon
Copy link
Collaborator

dabacon commented May 4, 2020

Does the simulator accept arbitrary strings right now?

@95-martin-orion
Copy link
Collaborator Author

Does the simulator accept arbitrary strings right now?

Yes - it populates a map of qubits to string IDs with no parsing/validation on the IDs. This will probably misbehave if you mix e.g. LineQubit(1) with NamedQubit('1'), but that's ill-advised for plenty of other reasons.

@95-martin-orion 95-martin-orion requested a review from dabacon May 7, 2020 17:21
Copy link
Collaborator

@dabacon dabacon left a comment

Choose a reason for hiding this comment

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

LGTM

@95-martin-orion 95-martin-orion merged commit 3d645b7 into quantumlib:master May 13, 2020
tonybruguier pushed a commit to tonybruguier/Cirq that referenced this pull request Aug 23, 2020
* Enable serialization of non-GridQubits.

* Lint fixes for serializer.

* LineQubit proto IDs must be digits-only.

* Add coverage.

* named_qubit_* -> qubit_*

* Fix lint error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Makes googlebot stop complaining.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Qubits other than GridQubit don't work on Quantum Engine Simulator
3 participants