Skip to content

Conversation

@sergeisakov
Copy link
Collaborator

Add detection of out of range qubits. Add clarifications on maximum qubit indices.

const GatesLat& gates_lat) {
for (unsigned q : gate.qubits) {
if (q >= max_qubit1) {
IO::errorf("gate qubits are out of range.\n");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Recommend including the offending gate or qubits in this error message, for debugging.

Same for the other messages below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

const GatesLat& gates_lat) {
for (unsigned q : gate.qubits) {
if (q >= max_qubit1) {
IO::errorf("gate qubits are out of range.\n");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above - include gate and/or qubits in these error messages.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

* fusing gates, use the other version of this method below.
* @param param Options for gate fusion.
* @param num_qubits The number of qubits acted on by 'gates'.
* @param max_qubit1 The maximum qubit index (plus one) acted on by 'gates'.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I assume this change is to more accurately describe situations where e.g. qubits {1, 2, 4} are being acted on? Would providing the exact set of qubits acted on be worthwhile, to ensure that a "skipped" qubit (3 in the previous example) isn't being erroneously acted on?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This change is to describe situations where e.g. qubits {1, 2, 4} and max_qubit1 (previously num_qubits) is smaller than 4+1. max_qubit1 is used to allocate an array in line 165 and there will be out of bound array access if any qubit acted on by gates is greater or equal to max_qubit1. It is OK if there are "skipped" qubits.

@sergeisakov sergeisakov merged commit 931865c into master Jan 4, 2022
@sergeisakov sergeisakov deleted the update-fusers branch January 4, 2022 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants