microsoft / iqsharp

Microsoft's IQ# Server.
https://docs.microsoft.com/quantum
MIT License
126 stars 58 forks source link

%debug magic command does not display quantum state visualization. #740

Open vs4503 opened 1 year ago

vs4503 commented 1 year ago

Describe the bug The %debug magic command for Q# in Jupyter Notebook (IQ# Kernel), does not display the bar graphs for amplitudes, probabilities, or real/imaginary co-efficients. The circuit appears, but the corresponding changes in the states of the qubits are not shown.

To Reproduce

  1. Open a new Jupyter Notebook with a Q# Kernel.
  2. In the first cell write a basic Q# program. Ex: In operation 'TestMethod' - create a qubit, apply the Hadamard gate, and measure the qubit.
  3. In the next 2 cells, run %simulate TestMethod then %debug TestMethod.
  4. Debug Controls work fine, but Chart Controls, when clicked, do not display anything.
  5. Open the console (F12 on Windows), and the error "Couldn't process kernel message TypeError: state.getDenseAmplitudes is not a function" is seen.

Expected behavior The Chart controls of the %debug magic command should display the various states of the qubit as the program executes.

Screenshots Error Message: image

%Debug Output Window with no bar graph image

System information

xinyi-joffre commented 1 year ago

Unfortunately, %debug and %trace are not supported today in the Azure Portal's hosted notebooks interface or in VSCode notebooks. This is due to the extensibility mechanism being different for these clients.

It is still supported in Jupyter Notebook classic interface if running a Jupyter server locally or using MyBinder.