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

Add JSON serialization support for QasmUGate #4750

Merged
merged 9 commits into from
Dec 16, 2021

Conversation

yjt98765
Copy link
Contributor

This PR provides the serialization support for the QasmUGate class following serialization.md. Without this support, QasmUGate cannot be properly serialized and deserialized, which causes issue #4728.

The test of serialization ability is done through the .repr and .json files under json_test_data folder. These files are also added for QasmUGate.

close #4728

@yjt98765 yjt98765 requested review from cduck, vtomole and a team as code owners December 14, 2021 03:51
@CirqBot CirqBot added the size: S 10< lines changed <50 label Dec 14, 2021
@@ -156,6 +156,7 @@ def _parallel_gate_op(gate, qubits):
'VarianceStoppingCriteria': cirq.work.VarianceStoppingCriteria,
'VirtualTag': cirq.VirtualTag,
'WaitGate': cirq.WaitGate,
'QasmUGate': cirq.circuits.qasm_output.QasmUGate,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should have alphabetical ordering (before 'QuantumFourierTransformGate': cirq.QuantumFourierTransformGate,. While we are at it, let's fix the ordering of 'RandomGateChannel': cirq.RandomGateChannel, as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is more than that! Many items are placed in the wrong order. Since you mentioned it, I reordered them in the new commit.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice! Thanks for going the extra mile! I've left a few minor comments then this should be good to merge.

Copy link
Collaborator

@vtomole vtomole left a comment

Choose a reason for hiding this comment

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

Please make the suggested changes manually. Clicking on the "commit suggestions" tends to screw up the CLA bot.

cirq-core/cirq/circuits/qasm_output.py Outdated Show resolved Hide resolved
cirq-core/cirq/circuits/qasm_output.py Outdated Show resolved Hide resolved
@yjt98765
Copy link
Contributor Author

Please make the suggested changes manually. Clicking on the "commit suggestions" tends to screw up the CLA bot.

Sorry, I did not see this until I click...

@yjt98765
Copy link
Contributor Author

@vtomole You are right, the CLA bot is screwed up. I tried to trigger the CI process like last time, but it did not work. It is interesting that the bot is not complaining about me actually, it complained about you:

Screenshot 2021-12-16 160018

Finally, I have to reset hard to the commit before clicking "commit suggestions" and forced push it. It seems that the PR goes back to the right track. 🙏

Copy link
Collaborator

@vtomole vtomole left a comment

Choose a reason for hiding this comment

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

LGTM!

@vtomole vtomole added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Dec 16, 2021
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Dec 16, 2021
@CirqBot CirqBot merged commit c33bd9b into quantumlib:master Dec 16, 2021
@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Dec 16, 2021
@yjt98765 yjt98765 deleted the qasm-json branch December 16, 2021 15:16
MichaelBroughton pushed a commit to MichaelBroughton/Cirq that referenced this pull request Jan 22, 2022
This PR provides the serialization support for the `QasmUGate` class following [serialization.md](https://github.com/quantumlib/Cirq/blob/master/docs/dev/serialization.md). Without this support, `QasmUGate` cannot be properly serialized and deserialized, which causes issue quantumlib#4728.

The test of serialization ability is done through the .repr and .json files under json_test_data folder. These files are also added for `QasmUGate`.

close quantumlib#4728
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
This PR provides the serialization support for the `QasmUGate` class following [serialization.md](https://github.com/quantumlib/Cirq/blob/master/docs/dev/serialization.md). Without this support, `QasmUGate` cannot be properly serialized and deserialized, which causes issue quantumlib#4728.

The test of serialization ability is done through the .repr and .json files under json_test_data folder. These files are also added for `QasmUGate`.

close quantumlib#4728
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this pull request Oct 31, 2024
This PR provides the serialization support for the `QasmUGate` class following [serialization.md](https://github.com/quantumlib/Cirq/blob/master/docs/dev/serialization.md). Without this support, `QasmUGate` cannot be properly serialized and deserialized, which causes issue quantumlib#4728.

The test of serialization ability is done through the .repr and .json files under json_test_data folder. These files are also added for `QasmUGate`.

close quantumlib#4728
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: S 10< lines changed <50
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cirq.read_json() fails to read a json containing a QasmUGate
3 participants