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
This is the correct matrix, multiplied by the global phase 0.9239−0.3827𝑖.
The second snippet should return the same matrix as the first, because by definition, R1(π)=diag(1, e^iπ)=diag(1,-1)=Z.
Expected behavior
Matrices from both snippets should match.
Screenshots
N/A
System information
qsharp 1.12.1
Additional context
Documentation for DumpOperation does say that global phase is expected when there are other qubits allocated. However, in this example there are no other qubits besides the three qubits on which this operation acts. If this is intended behaviour, please update the documentation.
I discovered this bug when migrating tests for my quantum_decomp library to use modern Q# in tests (and use DumpUnitary instead of calling DumpMachine many times). It worked for 2x2 and 4x4 matrices, but failed for 8x8 matrices. Temporary fix is to compare matrices up to global phase.
The text was updated successfully, but these errors were encountered:
fedimser
changed the title
DumpOperation has unexepcted global phase for double-controlled-R1 gate
DumpOperation has unexpected global phase for double-controlled-R1 gate
Jan 18, 2025
The decomposition for controlled-`T` in the stdlib uses `Rz` gates that are correct up to a global phase, which is fine for hardware but distracting in simulation. Correcting for that global phase in `T` fixes the global phase in `S`, which in turn allows removing a patch that made `R1` use a global phase consistent with `S`.
Fixes#2106
The decomposition for controlled-`T` in the stdlib uses `Rz` gates that
are correct up to a global phase, which is fine for hardware but
distracting in simulation. Correcting for that global phase in `T` fixes
the global phase in `S`, which in turn allows removing a patch that made
`R1` use a global phase consistent with `S`.
Fixes#2106
Describe the bug
Std.Diagnostics.DumpOperation
, when applied to R1 gate with 2 controls, produces incorrect matrix.To Reproduce
First, run this code:
You will get this correct output:
Then, run this code:
You will get:
This is the correct matrix, multiplied by the global phase
0.9239−0.3827𝑖
.The second snippet should return the same matrix as the first, because by definition,
R1(π)=diag(1, e^iπ)=diag(1,-1)=Z
.Expected behavior
Matrices from both snippets should match.
Screenshots
N/A
System information
qsharp 1.12.1
Additional context
The text was updated successfully, but these errors were encountered: