Expand description
Basic block: a straight-line sequence of quantum gate instructions.
A BasicBlock is the primary container for gate sequences in the Libket
IR. It maintains an index of qubit read/write dependencies that is
used by the qubit-mapping pass, and it applies lightweight algebraic
optimizations (gate merging and cancellation) whenever a new instruction is
appended.
§Gate simplification
When a new gate is appended, the block scans backwards through the existing instruction list for the first instruction that shares any qubit:
- If the two instructions have the same target and controls and are inverses of each other, both are cancelled (removed).
- If they have the same target and controls and are on the same rotation axis, their parameters are added and emitted as a single merged gate.
- If neither simplification applies, the gate is appended unconditionally.
Structs§
- Basic
Block - A straight-line sequence of quantum gate instructions.
- QubitOp
- Per-qubit dependency record maintained by a
BasicBlock.