0
$\begingroup$

I am learning the Q# language, and my script is in Python (I am using the online Azure interface).

I created an example quantum circuit on three qubits:

%%qsharp

    open Microsoft.Quantum.Intrinsic;
    open Microsoft.Quantum.Diagnostics;
    open Microsoft.Quantum.Math;
    open Microsoft.Quantum.Arrays;
    
    operation AlgoTest() : Result[] {
        use q = Qubit[3];
        mutable resultArray = [Zero, size = 3];
        CNOT(q[1],q[0]);
        H(q[2]);
        H(q[0]);
        S(q[1]);
        I(q[2]);
        CNOT(q[2],q[1]);
        H(q[2]);
        for i in IndexRange(q) {
                    set resultArray w/= i <- M(q[i]);
                }
        return resultArray;
    }

Is there a simple way to represent the quantum circuit associated to AlgoTest in a standard quantum circuit diagram?

I found these refs (1, 2), but they seem to assume the full program is in Q# (while I am using Python+Q#). For instance the command:

%%qsharp
%trace AlgoTest

Doesn't return me anything.

$\endgroup$

1 Answer 1

1
$\begingroup$

%trace magic only works in notebooks with Q# kernel (not Python+Q#), and only if they run on a local Jupyter Notebooks setup, not in Azure-hosted notebooks. There's no way to get a circuit plotted when running the code in Azure.

qpic sample can be a viable workaround, but it also requires a local setup and it also assumes that the quantum circuit is expressed in Q#.

$\endgroup$
1
  • 1
    $\begingroup$ Allright, thank you. As I see you work for Microsoft, I should say it would be a useful functionnality in the Aazure workspace =) $\endgroup$ Jul 25, 2023 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.