microsoft / QuantumLibraries

Q# libraries for the Quantum Development Kit
https://docs.microsoft.com/quantum
MIT License
543 stars 179 forks source link

DumpMachine state labelling bug when qubits >= 8 #684

Open cspwcspw opened 1 year ago

cspwcspw commented 1 year ago

Describe the bug Under Jupyter, when 8 or more Qubits used, DumpMachine sometimes outputs 8-bit row labels, sometimes 16-bit labels.

To Reproduce Run these two cells under Jupyter:

 open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Diagnostics;

operation TestDump(n:Int) : Unit
{
   use qs = Qubit[n];
   for i in 0..n-1 {
     H(qs[i]);  // put all bits into equal superposition.
   }
   DumpMachine();
   ResetAll(qs);
}
%config dump.basisStateLabelingConvention="BitString"
%simulate TestDump n=8

Expected behavior All rows should be labelled consistently, as they are whenever n < 8.

Screenshots DumpBug

System information

Windows 11
[I 11:03:07.200 NotebookApp] Kernel started: d293a705-353d-4e26-9191-0e0a089dea93, name: iqsharp  ??
IPython          : 8.15.0
ipykernel        : 6.25.0
ipywidgets       : 8.0.4
jupyter_client   : 7.4.9
jupyter_core     : 5.3.0
jupyter_server   : 1.23.4
jupyterlab       : 3.6.3
nbclient         : 0.5.13
nbconvert        : 6.5.4
nbformat         : 5.9.2
notebook         : 6.5.4
qtconsole        : 5.4.2
traitlets        : 5.7.1

Additional context Add any other context about the problem here.