You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes incorrect controlled-gate unitary matrices in QCO and unifies matrix wire indexing on the QuantumComputation convention.
Problem: CtrlOp::getUnitaryMatrix() embedded the inner unitary via DynamicMatrix::setBottomRightCorner (I_{2^c} ⊗ U), which is only correct when controls sit on the most significant wires. For general wire placement (e.g. cx(q[0], q[1])), the result did not match QuantumComputation.
Solution:
Add embedControlledUnitary() to place a multi-controlled unitary using actual control/target register indices (QC little-endian: qubit i = bit i).
Resolve compile-time wire indices in CtrlOp from qco.static and constant qtensor.extract operands.
Unify embedInNqubit, kron, and related helpers on the same bit ordering (replacing the old MSB-first embedding).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c++Anything related to C++ codeMLIRAnything related to MLIR
1 participant
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes incorrect controlled-gate unitary matrices in QCO and unifies matrix wire indexing on the
QuantumComputationconvention.Problem:
CtrlOp::getUnitaryMatrix()embedded the inner unitary viaDynamicMatrix::setBottomRightCorner (I_{2^c} ⊗ U), which is only correct when controls sit on the most significant wires. For general wire placement (e.g.cx(q[0], q[1])), the result did not matchQuantumComputation.Solution:
embedControlledUnitary()to place a multi-controlled unitary using actual control/target register indices (QC little-endian: qubiti= biti).qco.staticand constantqtensor.extractoperands.embedInNqubit,kron, and related helpers on the same bit ordering (replacing the old MSB-first embedding).DynamicMatrix::setBottomRightCornerAPI.Fixes #1821
Checklist
If PR contains AI-assisted content:
Assisted-by: [Model Name] via [Tool Name]footer.