-
Notifications
You must be signed in to change notification settings - Fork 188
Update fusers. #493
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
Update fusers. #493
Conversation
lib/fuser_basic.h
Outdated
| const GatesLat& gates_lat) { | ||
| for (unsigned q : gate.qubits) { | ||
| if (q >= max_qubit1) { | ||
| IO::errorf("gate qubits are out of range.\n"); |
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.
Recommend including the offending gate or qubits in this error message, for debugging.
Same for the other messages below.
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.
Done.
lib/fuser_mqubit.h
Outdated
| const GatesLat& gates_lat) { | ||
| for (unsigned q : gate.qubits) { | ||
| if (q >= max_qubit1) { | ||
| IO::errorf("gate qubits are out of range.\n"); |
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.
Same as above - include gate and/or qubits in these error messages.
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.
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'. |
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 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?
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.
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.
Add detection of out of range qubits. Add clarifications on maximum qubit indices.