Uknown (possibly Kernel Related) Error on Azure Quantum

IT student 66 Reputation points

So I found this error.


The issue is, that the program at times runs normally, without any issues.
At other times I get errors like this.

What I've noticed is that the Kernel sometimes switches between Q# and Python, and most of the time the cause is a poor internet connection.
However even when I went to a place with a strong and stable connection, the issue still persisted.
There are also errors like these:


With this last image, the last line of code stand in the que and cannot begin running.

Azure Quantum
Azure Quantum
An Azure service that provides quantum computing and optimization solutions.
38 questions
No comments
{count} votes

Accepted answer
  1. vipullag-MSFT 16,736 Reputation points Microsoft Employee

    @ ITstudent-4917

    Apologies in delayed response on this.

    Internal team check on this issue, and it looks like there was an issue in the code with the way the gates are commented out in the TestBellState function:


    Currently, Q# only supports single line comments using “//”. For more info, see:

    So, switching to this, then the operation should work:
    // H(q1);
    // M(q1);
    // H(q1);

    In terms of investigating why the user didn't see the error, it looks like the outputs for the cell were set to “hidden” in their notebook. This may have been done accidentally by you, since if you click around the cell to select it (but cursor is not in the cell itself), the official Jupyter Notebook shortcut toggle for “Show Output” and “Hide Output” is just the letter “O”.

    Once outputs are displayed for the operation, the error is given below for the compiler not being able to parse line 11:

    To make sure all outputs are displayed, there are two places to “Show all outputs”, either in command bar above:


    Or for the cell itself:


    No comments

1 additional answer

Sort by: Most helpful
  1. vipullag-MSFT 16,736 Reputation points Microsoft Employee

    @IT student

    Welcome to Microsoft Q&A Platform, thanks for posting your query here.

    For Kernel deleted, this typically happens in 2 scenarios:

    • One reason kernels are killed is if the kernel is idle for a half hour. If the user has left the kernel idle with no cells running, and there is no active code running in the background on the kernel, then the kernel will be automatically cleaned up after a long idle time, and they will need to restart from the first cell since all previous state from run cells is cleaned up. If they try to run the %simulate cell directly after a kernel restart but have not rerun the prior cells that define the operation, it will throw the error “Invalid operation name: TestBellState”. This part is managed by Jupyter server, so the behavior is similar to if you “Restart Kernel” manually.
    • Another reason a kernel process may be killed by the server is if it used too much memory or CPU. The notebook host is meant for lightweight development (4 GB memory and 2 vCPU). Since you are running local simulation through %simulate (which runs within the container), it’s possible that the kernel crashed because of out of memory or CPU if the code is requiring more resources than are available.
      o Once a kernel has crashed, running a cell will restart a clean kernel, but the state is lost. So, previous cells need to run again. If you are running %simulate cell directly after a kernel restart, but have not rerun the prior cells that define the operation, it will throw the error “Invalid operation name: TestBellState”.
      o If memory or cpu is a problem, then the proposal is to submit to either IonQ simulator or Quantinuum emulator (or joins our private preview for Microsoft First Party simulator), all of which will have more memory.
      o If you are just running this TestBellState sample defined in our docs without any modifications to the code, then it is verified that the code is not a problem and it can run fine within constraints of the container.
       If you opened a lot of IQ# notebooks and each still has a kernel alive in a 30 min span (not cleaned up yet), it’s possible that the code above can still run out of vCPU or memory since each IQ# kernel does consume around half of the resources available in the container. In the screenshots shared it is not clear that you were opening lots of IQ# notebooks, it’s possible that that may cause kernel crashes eventually due to running out of memory.

    Hope that helps.
    If the suggested response helped you resolve your issue, please 'Accept as answer', so that it can help others in the community looking for help on similar topics.