Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

DumpMachine output uses different ket symbols depending on the relative phase #1080

Open
tcNickolas opened this issue Aug 27, 2022 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@tcNickolas
Copy link
Member

tcNickolas commented Aug 27, 2022

Describe the bug

DumpMachine uses different ket symbols for states with real and complex amplitudes.
This happens both for full state simulator and for sparse simulator.

To Reproduce

The following code produces the following output on full state simulator:

use qs = Qubit[2] {
    H(qs[0]);
    Controlled Rx([qs[0]], (1.56, qs[1]));
    DumpMachine();
    ResetAll(qs);
}

image

The output for sparse simulator is the same, minus the basis state with zero amplitude.

Expected behavior

I expect DumpMachine to use the same ket symbol always, preferably the one that renders in the output (the one currently used for basis states with relative phase).

System information

  • OS: Windows 11
  • .NET Core Version: 6.0.400
  • QDK version: 0.24.201332, 0.25.222597
@tcNickolas tcNickolas added bug Something isn't working needs triage An initial review by a maintainer is needed labels Aug 27, 2022
@bettinaheim bettinaheim removed the needs triage An initial review by a maintainer is needed label Sep 7, 2022
@DmitryVasilevsky
Copy link
Contributor

DmitryVasilevsky commented Sep 19, 2022

Please note that if you copy/paste this from the console to notepad, the symbols will appear correctly. This may be an issue with the way symbols are displayed. They are printed out by the same code on every line and for both real and complex amplitudes.

@DmitryVasilevsky DmitryVasilevsky changed the title DumpMachine output uses different ket vectors depending on the relative phase DumpMachine output uses different ket symbols depending on the relative phase Sep 20, 2022
@DmitryVasilevsky DmitryVasilevsky self-assigned this Sep 20, 2022
@billti
Copy link
Member

billti commented Oct 12, 2022

Interesting. It does appear to be an issue with the old Windows console host. If I use the new Windows Terminal, I don't see an issue. (See screen shot below with Terminal app in the background, and old Console in the foreground, both running exactly the same project). I assume there is no issue on other OSes? (i.e. Mac or Linux)

I thought it might just be the non-Unicode code page used by default (e.g. see https://stackoverflow.com/questions/57131654/using-utf-8-encoding-chcp-65001-in-command-prompt-windows-powershell-window), but even changing that didn't help in the old console.

Being that the new Terminal app is the default on Windows going forward (see https://devblogs.microsoft.com/commandline/windows-terminal-as-your-default-command-line-experience/), I'm not sure how much time we should spend on this one.

image

@billti
Copy link
Member

billti commented Oct 12, 2022

One last comment. Directing the output to file and examining in a hex editor, I can see the correct UTF-8 chars are in the output stream for all places the right angle bracket is emitted (i.e. e2 9f a9 - see table at the bottom of https://unicode-table.com/en/27E9/ ). As Dmitry already mentioned, pasting the text from the console where it is displaying incorrectly into notepad makes it appear correctly. (The fact the right bracket on |3> is showing correctly proves it is not a font issue). So looks like a bug in the old Windows Console, which will almost certainly not get fixed. Either we move to using a regular ASCII right bracket by default, or just recommend people use the new Windows Terminal for console execution.

image

@billti
Copy link
Member

billti commented Oct 12, 2022

(Oh, and it looks fine in the VS Code terminal on Windows too)

image

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants