-
Notifications
You must be signed in to change notification settings - Fork 97
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
Reverse Endianness #1079
Reverse Endianness #1079
Conversation
This change reverse the display order of our state vector indices to make it line up with order of qubit allocation and ordering in result arrays. It also updates the descrptive text around the state dump and changes the ket representation for output histograms.
@swernli Shouldn't we reverse the order of the formatted tables as well so they still go from 00001 => 11111? |
|
No, because that is the correct order for what those entries are. If there were 4 qubits in equal superposition, it would go:
|
Benchmark for 9daf12dClick to view benchmark
|
The order of the printed entries is the second part of our discussion today, do we interpret bit strings as integers using little endian (least significant bit first) or big endian (most significant bit first)? For the CNOT matrix to have the right ("textbook") shape, we need to use big endian, so it makes sense to have the same for ordering the entries. (|0000⟩ then |0001⟩ then |0010⟩ etc.) |
Is there something imposing a particular order other than what we want to display? Displaying the kets in that order seems confusing to me. |
katas/content/multi_qubit_systems/prepare_with_complex/solution.md
Outdated
Show resolved
Hide resolved
Co-authored-by: Scott Carda <55811729+ScottCarda-MS@users.noreply.github.com>
Benchmark for 5b3dab7Click to view benchmark
|
Given the feedback and sticking with the theme of trying to make things less confusing, I'll make sure the state display is sorted according to the display format rather than the original state vector ordering. |
Is this correct? If |01> is the tensor product of |0> and |1>, then it is [1, 0]T x [0, 1]T which is [0, 1, 0, 0]T. In other words, the kets should be ordered from |00>, |01>, |10>, |11> to map to the way state vectors are typically ordered as sequential entries of [1, 0, 0, 0]T, [0, 1, 0, 0]T, [0, 0, 1, 0]T, and [0, 0, 0, 1]T. |
Benchmark for b096d88Click to view benchmark
|
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.
Phew, looks pretty thorough. Thanks!
Based on feedback, we are reversing the endianness of ket displays from the QDK along with associated code. This includes reversing the display for state dumps from within Q#, in the debugger, and in Jupyter output. Included in this change is the revert of updates to kata content that tried to accomodate the different ordering between exercise text and the state display. The change also includes update to the new
dump_operation
in Python so that it is consistent with the endianness and outputs matrices that match the same conventions.