6
|
12595 Views
|
53 Replies
|
28 Total Likes
View groups...
Share
GROUPS:

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

Posted 2 years ago
 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
53 Replies
Sort By:
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 11 months ago
 Thx David for your input. Here is a notebook that may help. Let's us know:
Posted 1 year ago
 https://community.wolfram.com/groups/-/m/t/2846060 IBM-quantum service connect
Posted 1 year ago
 The Paclet depository on QuantumDistance https://resources.wolframcloud.com/PacletRepository/resources/Wolfram/QuantumFramework/ref/QuantumDistance.htmlgives WoframCloud gives (using WQF 1.28) gives Which one is correct ?
Posted 1 year ago
 Similarly Paclet depositoryWolfram Cloud ( v 1.28)
Posted 1 year ago
 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 1 year ago
 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 1 year ago
 Regarding QFT I can do the QFT as a SumI am struggling to do it as a Product
Posted 1 year ago
 QuantumTensorProduct[Table[QuantumState[{1, Exp[2 Pi I x/2^k]}], {k, Log2[n]}]]/Sqrt[n] 
Posted 1 year ago
 I am experiencing a weird effect from any attempt to call QuantumTensorProduct[] in a notebook. It seems to have the side effect of removing WQF from the context path, and from the point on, any previously defined variables turn blue, and all previous calculations are nullified. This seems to be the only function that has this effect, and so far I've used almost all of the ones that were covered in the course. At one time I had tried to include both WQF and Q3 paclets in my context, which caused all kinds of problems, so I uninstalled Q3 and everything went back to normal for awhile, until this. I can't imagine this is the reason since Q3 is no longer in my context path.And I know you will probably suggest that I shut everything down and restart and reinstall WQF. I have done this multiple times, but nothing seems to make QuantumTesnorProduct work normally again.Any suggestions are welcome! Thanks.
Posted 1 year ago
 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 1 year ago
 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 1 year ago
 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 1 year ago
 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 1 year ago
 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 1 year ago
 We have documentation on different states in the Details&Options section of https://resources.wolframcloud.com/PacletRepository/resources/Wolfram/QuantumFramework/ref/QuantumState.html
Posted 1 year ago
 This is a new question, but related to the homework problems from the recent WQF course in October. I hope this is the right place to ask. It has to do with the four named states BasisState, Register, Graph, and BlochVector. Due to the fact that their density matrices contain text, it makes determination of certain properties either nonexistent or counterintuitive. I wonder if you could enlighten me -- I'm sure there's a simple explanation but I can't figure it out. Pleases see attached notebook snippet. Thanks, Mike
Posted 2 years ago
 How do I add the Quantum Framework Palette to my accessible list of palettes?
Posted 2 years ago
 The solution to the homework problem to show the equivalence between a power of a Pauli gate and a suitable corresponding rotation generates an error (at least the one shown in the Operators and measurements notebook (from the talk)). Namely,.(equivalence assertion is as follows:) QuantumOperator["X"]^t == Exp[I Pi/2 t] QuantumOperator[{"R", [Pi] t, "X"}] // Simplify(followed by very long error message:) I am not sure how to fix this. It is the Quantum Operator[{"R", pi t, "X"}] on the right that causes the problem. Here is the first part of the error messageQuantumState::failprop: property NormalizedDensityMatrix failed with Failure[[WarningSign] Message: SparseArray[Specified elements: 2 Dimensions: {2,2}]/Tr[SparseArray[Specified elements: 2 Dimensions: {2,2}]] produced a message on evaluation. Tag: ConfirmationFailed]$RecursionLimit::reclim2: Recursion depth of 1024 exceeded during evaluation of WolframQuantumFrameworkPackageScopeQuantumOperatorQ[Unevaluated[E^Failure[[WarningSign] Message: MatrixQ[QuantumState[Mixed state Qudits: 1 Type: Matrix Dimension: 2 Picture: SchrÃ¶dinger ]] did not return True. Tag: ConfirmationFailed]]].$RecursionLimit::reclim2: Recursion depth of 1024 exceeded during evaluation of WolframQuantumFrameworkPackageScopeQuantumMeasurementOperatorQ[Unevaluated[E^Failure[[WarningSign] Message: MatrixQ[QuantumState[Mixed state Qudits: 1 Type: Matrix Dimension: 2 Picture: SchrÃ¶dinger ]] did not return True. Tag: ConfirmationFailed]]].$RecursionLimit::reclim2: Recursion depth of 1024 exceeded during evaluation of WolframQuantumFrameworkPackageScopeQuantumChannelQ[Unevaluated[E^Failure[[WarningSign] Message: MatrixQ[QuantumState[Mixed state Qudits: 1 Type: Matrix Dimension: 2 Picture: SchrÃ¶dinger ]] did not return True. Tag: ConfirmationFailed]]].General::stop: Further output of$RecursionLimit::reclim2 will be suppressed during this calculation.$IterationLimit::itlim: Iteration limit of 4096 exceeded.$IterationLimit::itlim: Iteration limit of 4096 exceeded.JordanDecomposition::eivn: Incorrect number 0 of eigenvectors for eigenvalue -2.9914910^15+3.7192510^15 I with multiplicity 1.JordanDecomposition::eivn: Incorrect number 0 of eigenvectors for eigenvalue -2.9914910^15+3.7192510^15 I with multiplicity 1.JordanDecomposition::eivn: Incorrect number 0 of eigenvectors for eigenvalue -2.9914910^15+3.7192510^15 I with multiplicity 1.General::stop: Further output of JordanDecomposition::eivn will be suppressed during this calculation.JordanDecomposition::eival: Unable to find all roots of the characteristic polynomial.JordanDecomposition::eival: Unable to find all roots of the characteristic polynomial.
Posted 2 years ago
 Samples of sending queries to QPU (quantum hardwares) Attachments:
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 2 years ago
Posted 2 years ago
 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: 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 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 2 years ago
 https://www.wolframcloud.com/obj/wolframquantumframework/Published/Operators%20and%20measurement%20-%20Live.nbToday's live notebookBTW, our framework works fine on cloud, too
Posted 2 years ago
 Thank you for this great answer
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. Attachments:
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 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 2 years ago
 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 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 2 years ago
 There is a way to do it purely in Wolfram, you will have to set up Python external session for it to work.
Posted 2 years ago
 Hi DougRe your reply "I currently spend most of my time transferring code from the new qiskit textbook into WQF", is this for personal use or will the examples turn up into the future in Wolfram language as examples? My interest is in the Travelling Salesperson Problem (TSP) which you know is in Qiskit, I have used Mathematica for more than twenty-five years and would like, if possible, to stick with the home team.
Posted 2 years ago
 Hi Declan I have used Mathematica extensively for more than 30 years now and it is my preferred language to do my studies in physics and mathematics. Most of my academic studies uses python as the language of instruction eg currently Quantum information theory and quantum computing. IBM currently offers a path to academic studies eg the summer schools that they have been running for the last three years and therefore python and qiskit is a prerequisite. One advantage of Qiskit is you can run your code on real hardware. Currently my method of study is to do a topic first in qiskit ( because of the resources available and the code examples available eg Qiskit textbook , then I code them up in a Mathematica addon "Quantum" and then code it up in WQF. By coding up in these 3 methods I get a good overview, and experience different approaches to the topic. For example my topic this week is Simons algorithm so will work through a lecture by Ekert Ekert Simon's Algorthm and then a lecture by Vazerani Vazerani Simons Algorithm then use the New qiskit book to do the code in Qiskit , then code it up in ""Quantum" in Mathematica and then in WQF . This is how I approach all the topics in QIT and QC that interest me .
Posted 2 years ago
 Doug, you can easily send queries to a quantum hardware from Wolfram notebook. See below examples
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 2 years ago
 Decan, thatâ€™s not correct. See notebooks that I shared, showing how to send queries to a quantum hardware from a Wolfram notebook
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 2 years ago
 Declan I think we will be using qiskit to access real hardware . We are told we can access it through WQF but we are not given the resources to do it . The three files are not going to achieve that goal . leaving out the Amazon bracket file and concentrate on the two IBM files .Looking at IBMQ we are given a link to https://qiskit.org/documentation/partners/qiskitibmruntime/getting_started.html):and then token = Import["~/.qiskit/qiskit-ibm.json", "RawJSON"][ "default-ibm-quantum", "token"]; I assume we install the qiskit-ibm-runtime in qiskit ands access a json file to generate a token . Who knows . So the rest of the IBMQ file makes no sense as I cannot run the first line .So lets turn to the qiskitIBMQ file . Alls well until qiskitCircuit["Graphics", "Scale" -> 1] The "Graphics", needs Matex installing and help with this would be helpful then down to the first timer we attempt to run on hardware grover[[;; -2]]["Qiskit"][initState, "Provider" -> "IBMQ"] which obviously will not run on my machine as I have not done the setup . So what we need is a notebook with a clean setup from installing the qiskit-ibm-runtime in qiskit to creating a token ( using your own personal api-token in IBM-quantum-experience) , creating an ID and then running some QASMs:. Then create the code to run grover grover = QuantumMeasurementOperator[Range[3]]@ QuantumCircuitOperator[{"Grover", a && ! b && c}] groverQiskit=grover["Qiskit"]["Decompose"] initState=QuantumOperator["Z",{4}]@QuantumState[{"UniformSuperposition",4}]; grover[[;;-2]]["Qiskit"][initState,"Provider"->"IBMQ"] cloudSimMeasurement=groverQiskit[initState,"Provider"->"IBMQ"] deviceMeasurement=groverQiskit[initState,"Provider"->"IBMQ","Backend"->"ibmq_lima"] BarChart[Merge[{exactMeasurement["Probabilities"],simMeasurement["Probabilities"],deviceMeasurement["Probabilities"]},Identity],ChartLabels->Automatic, ChartLegends->Placed[{"Exact","Simulation","QPU"},Below]] Hopefully then the code will run
Posted 2 years ago
 Is there a way to check the least busy hardware as currently Lima is paused !
Posted 2 years ago
 https://community.wolfram.com/groups/-/m/t/2491392Take a look at this one too
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 2 years ago
 no, 3 different states (a textbook example when discussing POVMs) create each one separately, then transform them into Pauli-Y basis
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 2 years ago
 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 2 years ago
 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 2 years ago
 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
Posted 2 years ago
 How would you do this code in WQF in the most compact form 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 2 years ago
 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: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: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 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 )
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 2 years ago
 What's the shorthand keyboard sequence for the MAC that allows me to toggle between formats?
Posted 2 years ago
 It's Cmd+Shift+T for TraditionalForm, and Cmd+Shift+N for StandardForm.