-
Notifications
You must be signed in to change notification settings - Fork 983
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 random quantum circuit generation #2621
Conversation
mypy complains
but #2626 |
Actually I modified the code so mypy no longer complains. |
cirq/experiments/__init__.py
Outdated
@@ -30,6 +30,13 @@ | |||
xeb_fidelity, | |||
) | |||
|
|||
from cirq.experiments.random_quantum_circuit import ( |
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.
The name of this code needs to be more descriptive. "Random quantum circuit" can mean a lot of things. Make it like "random_rotations_between_interaction_layers" or something. Be as descriptive as possible... although the name should fit on a line.
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.
I think we could keep the module name as is or perhaps just add "generation" to it (as in random_quantum_circuit_generation
or random_circuit_generation
) with the intention for any future RQC-generation code to be added here as well.
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.
I renamed the module to random_quantum_circuit_generation
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.
cirq/experiments/__init__.py
Outdated
@@ -30,6 +30,13 @@ | |||
xeb_fidelity, | |||
) | |||
|
|||
from cirq.experiments.random_quantum_circuit import ( |
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.
I think we could keep the module name as is or perhaps just add "generation" to it (as in random_quantum_circuit_generation
or random_circuit_generation
) with the intention for any future RQC-generation code to be added here as well.
cirq/experiments/__init__.py
Outdated
GMON_EASY_PATTERN, | ||
GMON_HARD_PATTERN, | ||
GmonLayer, | ||
random_quantum_circuit, |
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.
As suggested by @Strilanc above, we should name this more specific. This will also make the module future-proof by preventing name collisions. Example name for the function: make_layered_random_circuit
.
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.
I renamed it random_rotations_between_grid_interaction_layers_circuit
.
Windows build is failing. |
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, with some minor nits.
single_qubit_gates: Sequence['cirq.Gate'], | ||
previous_single_qubit_layer: Dict['cirq.GridQubit', 'cirq.Gate'], | ||
prng: 'np.random.RandomState', | ||
) -> Dict['cirq.GridQubit', 'cirq.Gate']: |
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.
For defense-in-depth, you could check consistency of qubits and previous layer:
if not previous_single_qubit_layer and set(qubits) != set(previous_single_qubit_layer.keys()):
raise ValueError(...)
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.
I think you put the not
there by mistake. I think this is quite unnecessary; I'd rather omit it.
Automerge cancelled: Need a fresh 🍪. |
Automerge cancelled: The automerge label was removed. |
Automerge cancelled: Need a fresh 🍪. |
Automerge cancelled: The automerge label was removed. |
Adapted from pyle.
Let me know if the name
random_quantum_circuit
is too generic. What would be a better name?@XiaoMiQC