Message Boards Message Boards

6
|
12625 Views
|
53 Replies
|
28 Total Likes
View groups...
Share
Share this post:

[WSG23] Daily Study Group: Quantum Computation Framework (Oct 24, 2022)

A new WolframU study group devoted to Quantum Computation Framework begins Monday, October 24th! A list of daily topics can be found on our Daily Study Groups page. This group will be led by me and @Nikolay Murzin, from Wolfram Quantum Team. We will meet daily, Monday to Friday. Study group sessions include time for exercises, discussion and Q&A. This study group will help you acquire an intro knowledge of quantum computation and learn how to implement quantum algorithms in the Wolfram Quantum Computation Framework. Feel free to explore our framework.

REGISTER HERE

enter image description here enter image description here

POSTED BY: Mads Bahrami
53 Replies
Posted 11 months ago

Does anyone have experience building multiqubit quantum channels? I can make a simple one with a single Krauss operator, but am having trouble defining a multiqubit channel with multiple Krauss operators. In this example, I'm applying a stochastic XX operator on qubits 1&2 and the identity on qubits 3&4.

This works:

channel = 
 QuantumChannel[
  Sqrt[0.5] QuantumTensorProduct[QuantumOperator["X", {1, 2}], 
    QuantumOperator["I", {3, 4}]]]

Now if I want to apply XX or YY with equal probability on qubits 1&2, I fail.

This doesn't work:

channel = 
 QuantumChannel[{Sqrt[0.5]
     QuantumTensorProduct[QuantumOperator["X", {1, 2}], 
     QuantumOperator["I", {3, 4}]], 
   Sqrt[0.5]
     QuantumTensorProduct[QuantumOperator["Y", {1, 2}], 
     QuantumOperator["I", {3, 4}]]}]

I get this error message:

Thread::tdlen: Objects of unequal length in {4}->{1,2,3,4} cannot be combined.

Thanks in advance for any help.

POSTED BY: David Hayes

Thx David for your input. Here is a notebook that may help. Let's us know:

POSTED BY: Mads Bahrami

The Paclet depository on QuantumDistance

https://resources.wolframcloud.com/PacletRepository/resources/Wolfram/QuantumFramework/ref/QuantumDistance.html

gives enter image description here

WoframCloud gives (using WQF 1.28) gives

enter image description here

Which one is correct ?

POSTED BY: Doug Beveridge

Similarly Paclet depository

enter image description here

Wolfram Cloud ( v 1.28)

enter image description here

POSTED BY: Doug Beveridge

Is it possible to have both WQF and Q3 installed (and in the context path) at the same time? I recall that one of the class participants said they liked to solve the homework problems simultaneously using Python, WQF, and Q3. But I seem to encounter issues when WQF and Q3 are both "visible" to any of my notebooks. I am planning on working through the exercises in Choi's e-book "A Quantum Computation Workbook", (Springer 2022) which is written with Q3 terminology. Of course I could simply ignore this and translate everything to Wolfram language constructs. But I thought it might be helpful to have the two languages running side-by-side. Is this a good or bad idea? :<)
Thanks

POSTED BY: Michael Ulrey

Qiskit is Py-based, so there should not be any issue. Q3, it depends, if same names for functions, yes, there will be issues

POSTED BY: Mads Bahrami

Regarding QFT I can do the QFT as a Sum

enter image description here

I am struggling to do it as a Product

enter image description here

POSTED BY: Doug Beveridge
QuantumTensorProduct[Table[QuantumState[{1, Exp[2 Pi I x/2^k]}], {k, Log2[n]}]]/Sqrt[n]
POSTED BY: Mads Bahrami
POSTED BY: Michael Ulrey

The short answer is: don't display the summary box for that tensor product, it crashes while trying to compute the entropy for it, so just put a semicolon after it u1=QuantumTensorProduct[s1,t1];.

The main culprit is the time-constrained MatrixLog bug, just try TimeConstrained[MatrixLog[RandomReal[1, {1024, 1024}]], 1], and it will crash your kernel. We need to constrain it for the summary box. Otherwise, it would take too long to render. But the "Entropy" property can be computed if you are willing to wait. The bug was already reported and should be fixed in 13.2.

POSTED BY: Nikolay Murzin

Thanks Nikolay for the quick reply. Wow, you work on Sunday! Sorry I didn't figure out this was already reported. I appreciate your patience in explaining it to a newbie yet again. :<)

POSTED BY: Michael Ulrey

Thanks to Mads and Nicholay (and whoever else contributed) to solving the problem in the previous post. It was magic. One day I had a problem with the four named states "BasisState", "Register","Graph", and "BlochVector", and the next day I re-installed a (presumably changed) version of WQF, and voila! everything worked as expected. Thank you. Here is the evidence.

POSTED BY: Michael Ulrey

No problem! :) But just to clarify, most of those states were only intended to work with some parameter, for example, Graph expects you to provide a graph as an argument QuantumState[{"Graph", graph}] otherwise "Graph" in QuantumState["Graph"] were interpreted as a simple symbolic amplitude like in QuantumState[a] which is just a|0>. I agree that it was confusing, so we've added default arguments for every named state so that strings that correspond to valid named states wouldn't be interpreted as an amplitude. Or for other objects, like QuantumCircuitOperator["Grover"], would return unevaluated. In general, don't expect that providing a name would always evaluate to a valid object.

POSTED BY: Nikolay Murzin

Thanks -- I figured theses were special states (BasisState, Register, Graph, and BlochVector) for which more information was required. I just couldn't find any thing in the documentation about it (it might be there, I just couldn't find it!). So thanks for letting me know how it's supposed to work!

POSTED BY: Michael Ulrey

We have documentation on different states in the Details&Options section of https://resources.wolframcloud.com/PacletRepository/resources/Wolfram/QuantumFramework/ref/QuantumState.html

enter image description here

POSTED BY: Nikolay Murzin
POSTED BY: Michael Ulrey
Posted 2 years ago

How do I add the Quantum Framework Palette to my accessible list of palettes?

POSTED BY: Syd Geraghty
POSTED BY: Michael Ulrey

Samples of sending queries to QPU (quantum hardwares)

POSTED BY: Mads Bahrami
Posted 2 years ago

Mads that looks good .

Could we not have a step by step tutorial laying out exactly how to set up a connection to IBMQ using ones own API token from IBM Quantum experience. (the graphics require MaTeX and how to set that up )

POSTED BY: Doug Beveridge

Regarding the multiplexer that we discussed today. Here is what we wanted to show. Let's construct the following circuit using only operators one by one: enter image description here First let's create the correct sequence for control-1 and control-0 qubits:

seq = Reverse[
  Values[<|0 -> {}, 1 -> {}, 
      GroupBy[Transpose[{#, {1, 2, 3}}], First -> Last]|>] & /@ 
   Tuples[{0, 1}, 3]]

which gives us:

{{{}, {1, 2, 3}}, {{3}, {1, 2}}, {{2}, {1, 3}}, {{2, 
   3}, {1}}, {{1}, {2, 3}}, {{1, 3}, {2}}, {{1, 2}, {3}}, {{1, 2, 
   3}, {}}}

Then the corresponding circuit can be created as follows:

qc = QuantumCircuitOperator[
  MapThread[{"C", #2, Sequence @@ #1} &, {Reverse[seq], {"H", "Y", 
     "Y", "Y", "Y", "Y", "H", "Y"}}]]

once can show that the operator circuit is equivalent to this operator:

QuantumOperator[{"Multiplexer", "H", "Y", "Y", "Y", "Y", "Y", "H", 
  "Y"}]

Test:

QuantumOperator[{"Multiplexer", "H", "Y", "Y", "Y", "Y", "Y", "H", 
"Y"}] == qc["CircuitOperator"]

Of course, note the difference in the number of qudits etc too

POSTED BY: Mads Bahrami
Posted 2 years ago

Mads

Is it possible to put all the course files on the cloud please . as above . The latest version of the WQF will only run on the new version of Mathematica (13.1) and not on 13.01. So I have to run these files in the cloud and if you post those links then I can get a copy into my Mathematica cloud ,

Can you also check , these state diagrams eg

QuantumState["1"]["Diagram"]

are not loading in the cloud and just give a black box

POSTED BY: Doug Beveridge
Posted 2 years ago

Thank you for this great answer

POSTED BY: Declan Flynn
Posted 2 years ago

I have successfully used Qiskit to run examples on the IBM Quantum computer, but I am also an applied math person, I need to understand what I am trying to achieve. You have shown us an amazing number of functions, but I am struggling to work out how and where to start. Any chance of a quick example, say the addition circuit using Toffoli at the end of " section 4.3 " of Qiskit textbook into to Wolfram code? After that I might have some chance with the quiz.

Attachment

Attachments:
POSTED BY: Declan Flynn
Posted 2 years ago

Hi Declyn

I currently spend most of my time transferring code from the new qiskit text book into WQF. The first thing to realise is that qiskit numbers the qubits from right to left | 3 2 1 > and mathematica and WQF numbers qibits from left to right | 1 2 3> , this means you need to invert your circuit above and the circuit diagram will then be compatible with WQF . ( I am sure Nik will have a trick in WQF to automatically do this )

I am currently doing this using Simons algorithm in the new Qiskit textbook invert the circuits (using the qiskit function inverse() then writing the WQF code to represent the inverted circuit . I will do this in a notebook (you may need to increase the size of the images in the notebook)

POSTED BY: Doug Beveridge
Posted 2 years ago

Nik is there a way to make this conversion from qiskit circuits to WQF easier . Does WQF have a similar inverse() function that would take a WQF circuit and invert it to represent the circuit in Qiskit style .

POSTED BY: Doug Beveridge

If you act with WQF circuit on a state, you can "Reverse" the final QuantumState, it will be the same as Qiskit's final statevector. If you compile a WQF circuit to a QuantumOperator, its "Reverse" will make the same unitary as Qiskit. It's trickier to reverse a measurement, I don't have an easy way of doing it right now, sorry

POSTED BY: Nikolay Murzin
Posted 2 years ago

Qiskit will not let you reverse a measurement , you have to reverse the circuit without measurement then add the measurement .to the reversed circuit

POSTED BY: Doug Beveridge

There is a way to do it purely in Wolfram, you will have to set up Python external session for it to work.

POSTED BY: Nikolay Murzin
Posted 2 years ago
POSTED BY: Declan Flynn
Posted 2 years ago
POSTED BY: Doug Beveridge

Doug, you can easily send queries to a quantum hardware from Wolfram notebook. See below examples

POSTED BY: Mads Bahrami
Posted 2 years ago

Doug, thank you for this informative reply, I had a suspicion that Qiskit would still be required for the real quantum machine, but would expect that to change soon, some positive developments in hardware coming. I also use Python a lot.

POSTED BY: Declan Flynn

Decan, that’s not correct. See notebooks that I shared, showing how to send queries to a quantum hardware from a Wolfram notebook

POSTED BY: Mads Bahrami
Posted 2 years ago

Mads, I accept your correction, your reply is good news i.e. that there is a full pathway in Wolfram from initial code to actual device. I will try converting the TSP to WQF, as I would like to stay inside Wolfram when I can.

POSTED BY: Declan Flynn
Posted 2 years ago
POSTED BY: Doug Beveridge
Posted 2 years ago

Is there a way to check the least busy hardware as currently Lima is paused !

enter image description here

POSTED BY: Doug Beveridge
Posted 2 years ago

I don't understand this problem:

  • create qubit trine (define as: |0>, -(1/2)|0>-Sqrt[3]/2 |1>,-(1/2)|0>+(Sqrt[3]/2) |1>
  • find their state vector in Pauli-Y basis

This looks like 3 state vectors. Is this supposed to be a basis?

POSTED BY: Updating Name

no, 3 different states (a textbook example when discussing POVMs) create each one separately, then transform them into Pauli-Y basis

POSTED BY: Mads Bahrami
Posted 2 years ago

Hi I am trying to work out how the built-in function/state "Werner " works i.e QuantumState[{"Werner",1/2, 2}]

see Notebookj

POSTED BY: Doug Beveridge

https://en.wikipedia.org/wiki/Werner_state yes, they are mixture of projectors try higher dimensions too and compare with

QuantumState[{"Werner",p,d}]
POSTED BY: Mads Bahrami

This is not really a reply, but a new question. I hope it's all right to put it here. How do you get immediate information on a particular function? Normally you do that by hovering over the name, and then click on the "i" that comes up. But the "i" is grayed out for me. I can get the overloaded formats for the functions, but not the documentation.

POSTED BY: Michael Ulrey

Hi Mike, on Mac, if you hover your mouse over the function, then click Command+Shift+T, the documentation page will pop up. Also, for some of functions (not all of them, eventually for all of them), we have added the option of seeing their most common template enter image description here

POSTED BY: Mads Bahrami
Posted 2 years ago

How would you do this code in WQF in the most compact form enter image description here

This seems to work for the POVM

Tr[QuantumTensorProduct[QuantumState["0"]["Dagger"], 
    QuantumState["Plus"]["Dagger"]][
   "DensityMatrix"] QuantumState["PhiPlus"]["DensityMatrix"]]

and the Projective measurement

((Abs[Normal[(QuantumTensorProduct[
        QuantumTensorProduct[QuantumState["0"]["Dagger"], 
         QuantumState["Plus"]["Dagger"]]]@ QuantumState["PhiPlus"])[
     "StateVector"]][[1]]
  ] ) ^2)  

So thats why I need a more compact form :)

POSTED BY: Doug Beveridge

I wouldn't call it a measurement, because you only extract a single specific probability. So it is just composing certain state projectors, or their corresponding operators, with a target state:

Tr[QuantumState["0"]["Operator"]@QuantumState["+", "X"]["Operator", {2}]@QuantumState["PhiPlus"]]

If you like nice notation, then after evaluating each piece inline individually and turning them into their TraditionalForm, it would look like this inside an Output cell:

enter image description here

Notice that I make a plus state in X basis and turn it into an operator that acts on the 2nd qubit: QuantumState["+", "X"]["Operator", {2}] (update the paclet to make it work).

If you want to do a measurement in computational and "X" basis and extract probabilities, you should act with QuantumMeasurementOperator on the state:

QuantumMeasurementOperator[{2, "X"}, {1, 2}][QuantumState["PhiPlus"]]["Probabilities"]

QuantumMeasurementOperator doesn't look very nice in TraditionalForm, but you can still display it:

enter image description here

These extra output bold kets are eigenvalues for your measurement (it's that vertical measurement wire that you see in circuit diagrams), it goes from 0 to D-1 by default. We will discuss it in more detail at the study group dedicated to measurement, stay tuned! ;)

POSTED BY: Nikolay Murzin
Posted 2 years ago

(update the paclet to make it work).

I did but now it will not run on my version 13.0,1,0 (it runs on the cloud )

enter image description here

POSTED BY: Doug Beveridge
Posted 2 years ago

I am sure that "EntangledQ" was part of QuantumState["Properties"] but it now it seems its missing

(found it QuantumEntangledQ )

POSTED BY: Doug Beveridge
Posted 2 years ago

What's the shorthand keyboard sequence for the MAC that allows me to toggle between formats?

POSTED BY: Steven Willis

It's Cmd+Shift+T for TraditionalForm, and Cmd+Shift+N for StandardForm.

POSTED BY: Nikolay Murzin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract