Grovers Algorithm - Programming on Quantum Computers - Coding with Qiskit S2E3

Поділитися
Вставка
  • Опубліковано 21 вер 2024

КОМЕНТАРІ • 118

  • @danielwang5366
    @danielwang5366 3 роки тому +46

    Say it with me everyone, "Thank you Qiskit!!!"

  • @tomwong301
    @tomwong301 3 роки тому +92

    Great video! A couple of minor corrections:
    1) At 6:08, the (oracle + reflection) were together referred to as "Grover's diffusion operator." Together, they are actually called "Grover's iterate." The reflection by itself is Grover's diffusion operator.
    2) At 12:42, the reflection should be 2|sXs| - I. That is, the factor of 2 is missing.
    Looking forward to where this series is going!

    • @jin-sungkim8492
      @jin-sungkim8492 3 роки тому +10

      good catches, thanks!

    • @JNCressey
      @JNCressey 2 роки тому

      I don't know if X is a shorthand for two angle brackets, but just to note, in the second point it has a ket vector s multiplied by a bra vector s. It's not as I first read it as the modulus of a cross product.

    • @leif1075
      @leif1075 2 роки тому +1

      How does How does algorithm actually work and WHY I don't think the video addressed this..

  • @michaeljburt
    @michaeljburt 3 роки тому +3

    This is absolutely mind bending. I am a continual studier of theoretical physics, but seeing it applied so rapidly and so readily is jarring. Wow.

  • @k_pragya
    @k_pragya 3 роки тому +9

    Aaamazzinnngg...!!! Jin came back in the same way he vanished out in last week's video. Yayy... Team Qiskit never fails to add the fun spice in the learning recipe!! Thanks Jin for the helpful knowledge!!

  • @b.ambrozio
    @b.ambrozio 3 роки тому +48

    I understood how the classical computation solved the search example over the 10 elements array, and I (think I) also understood Grover's algorithm. However, I didn't understand how Grover's algorithm would solve the problem given in the begin (find the index of the array that has the number 7). Would be nice seeing Grover's algorithm implementation actually solving the problem just solved by the classical computation.

    • @sukhsagardubey48
      @sukhsagardubey48 3 роки тому +1

      i also want same thing.

    • @evaandres7986
      @evaandres7986 3 роки тому

      I have the same doubt, I've read some papers about this but I haven't found the solution yet. Someone have an example using grover to get the index of the array that has the number?

    • @juliaplewa662
      @juliaplewa662 2 роки тому +9

      I think they simplified this a little bit. The actual idea is that, given some function f(x), you can use this algorithm to find the value of x for which f(x) is equal to some specific value. In the example shown in this video, the function they used is f(x) = x and they searched for the value of x that guarantees that f(x) = 3 (or 11 in binary). Surprisingly the answer was x = 3 ;)
      If you implemented a quantum gate that maps between the indices and the values of some array, you could easily solve the problem you're interested in - given the value, you'd get the index. I'm not sure how easy to implement the specific function from the video would be, but I don't think that was their point.
      Instead of indices, try to think of the domain of your function, and instead of array values, consider the values the function assumes for different input values. If you think of it this way, Grover's algorithm is actually a way of inverting functions. This is perfect for constraint satisfaction problems - there's a neat little example about Sudoku puzzles on the Qiskit website.

    • @tws80408
      @tws80408 2 роки тому +1

      Same, the explanation of grover algorithm is too simplified

    • @zevan4b
      @zevan4b 2 роки тому +4

      I am in the same situation. I am not understanding how the Quantum algorithm solved the problem by returning the (11) state.

  • @jordanchuri2454
    @jordanchuri2454 3 роки тому +3

    Great video. One of the better descriptions of an oracle that I have seen/read for Grover's algorithm.

  • @SankalpSanand
    @SankalpSanand 3 роки тому +4

    2 things for some people confused with the benefit of this and why are we using CZ gate:
    1. This can be used to quickly find whether a particular element exists in a list of elements
    2. We design an oracle so that it can flip the state, e.g if we needed to find state |01> the oracle would've been, circuit.x(0) then circuit.cz(0, 1).

  • @adhishagammanpila
    @adhishagammanpila 3 роки тому +31

    Great explanation, I am curious why didn't the example of finding 7 from the array was not done using using the Quantum Algorithm ?

    • @rajesh020271
      @rajesh020271 2 роки тому +1

      It will not be different, you just have to code these numbers into binary states (i.e. 3 cubit system), everything else will be the same. You might have noticed that quantum operators are matrices and the states are vectors, the matrix-vector products are time consuming on classical computers. On quantum computers, these operations are done in the "physical systems" like atoms and molecules. Therefore, it is not possible to benchmark classical and quantum computations. I guess, benchmarking of classical and quantum search for turn-around-time or the complexity, or the number of flops etc was not the intention of this video.

  • @namanjain1164
    @namanjain1164 3 роки тому +20

    Great explanation! A query tho: In this case, you just hardcoded the oracle for | 11 >. So, you were looking for the item at index 3 (if actually searching through a list). Doesn't that mean you already know where the item is ?!!. How could the oracle be implemented more generally?

  • @МаринаЛисниченко-о2ъ

    What is going on from the 14:00? Why do we use again Hadamard after oracle in reflection? What I see in the 2 and 3 rows of the "reflection" is a repetition of the oracle. And after that we use CZ - why?

  • @smcg2490
    @smcg2490 Рік тому +1

    That was so cool. I’m new to quantum algorithms. This has been really helpful. The videos have a clear direction, are easy to understand and well filmed. Well done everyone! 😊

  • @davide8228
    @davide8228 9 місяців тому +1

    Great video! I got this but I don't understand why once we have flipped the sign of the winner state we can't use addition/subtraction with the original state to get the winner immediately. For instance, whithout the normalization coefficient of 1/2 it's: |1, 1, 1, -1> - |1, 1, 1, 1> = |0, 0, 0, 1>. In this way we wouldn't require neither the reflection nor the iteration.

  • @juanete69
    @juanete69 3 роки тому +17

    Hello.
    I don't understand. You were looking for the number "7", in binary 111, which is at index 9 (1001 in binary), but you got 11.
    I guess you just mixed the original problem with a simpler one.
    You would need to change the oracle, how would it be?
    And how is the initialization done if we want to use mylist as the input instead of random qubits?

    • @algoboi
      @algoboi 7 місяців тому +1

      in the circuit, he shown only 4 states {0,1,2,3} -> {00, 01, 10, 11} (using 2 qubits) and he chose 11 to be the winner state.

  • @adityaprakash8027
    @adityaprakash8027 3 роки тому +4

    Thank you. 😁Eagerly waiting for next video

  • @iliqnew
    @iliqnew 3 роки тому +14

    Amazing! A question tho: how does the quantum version of this algorithm refers to the problem in the beginning? Or how can we pass the function through the circuit in order to get the index of the winning number in the list? I just still can't see how the two problems are the same. I've learned the operators used in these circuits but please somebody HELP! Quantum computers are so interesting to me but I still can't "translate" the boring for-loops to a quantum circuit and I really want to

    • @sergeyivanow5648
      @sergeyivanow5648 3 роки тому

      @iliyan Iliev How have you done this problem?

    • @juliaplewa662
      @juliaplewa662 2 роки тому +4

      They didn't really explain this part too well. The idea here is that, given a circuit that implements some f(x), you can use the algorithm to find the x for which f(x) is equal to some specific value. If you wanted to implement the array index search scenario, you'd have to create a circuit that, given an index, returns the value that occupies this index in your array. Then you could search for the value of x that results in f(x) = 7. I'm not sure how easy this particular f(x) would be to implement, I think they just gave this example without giving it much thought.
      A much more practical approach of Grover's search is in constraint satisfaction problems. Qiskit has a neat little example of a Sudoku puzzle in their textbook and I highly recommend it.

  • @bigpuddle
    @bigpuddle 2 роки тому +2

    This is the same material presented in the same way as many other videos of the Grover Algorithm. I have yet to see an Oracle 'mark' a meaningful search target. Why not implement the same search task in both classical and quantum programming so that a comparison can be drawn?

  • @thomasmonti2450
    @thomasmonti2450 Рік тому

    Nice 1903/83 its very clear now thank for all your support...

  • @matthewwongsakdi4997
    @matthewwongsakdi4997 2 роки тому +4

    Can someone please explain when the |11> winning state was defined during the coding process?

    • @SKathiresan
      @SKathiresan 3 місяці тому +1

      It was defined in the oracle.

  • @abhirammodak8377
    @abhirammodak8377 3 роки тому +4

    I have a basic doubt - if the oracle can single out the entry we are looking for, why is the subsequent circuit required?

    • @juliaplewa662
      @juliaplewa662 2 роки тому +2

      The oracle lets you know when it sees the right answer. You could iterate through all the possible answers and apply the oracle to each one, but that's basically the same as the classical algorithm, the complexity of which is O(N). The other parts of the circuit implement the actual quantum algorithm with complexity O(sqrt(N)), the oracle is just its subroutine.
      This example is obviously a bit counter-intuitive, because you start off by implementing an oracle for a specific answer and then you write an algorithm that looks for the answer marked by this oracle. This is just a basic example and its goal is to demonstrate the general idea. If you want to see more practical applications, I recommend looking up examples related to constraint satisfaction. There's a neat sudoku example in the Qiskit docs.

  • @louben5573
    @louben5573 3 роки тому +1

    Great video Amaaazinggg, was looking so forward for this, thank you for making this possible, best from Amsterdam cozy-west side

  • @mantiksalcpp
    @mantiksalcpp 8 місяців тому +1

    Grovers Algorithm is a search algorithm. So, if it does not know what it shoul search it cannot be done and you did not give a marked state. People loves to talk about unknowledgeble topics

  • @MegalaSrinivasan
    @MegalaSrinivasan 5 місяців тому +1

    Thank you sir

  • @JuneJulia
    @JuneJulia 3 роки тому +4

    I have hard time understanding Oracle function.
    How can It recognize the winning state without do the math to all the states O(N)? Can you help please..

    • @michellefernandez805
      @michellefernandez805 3 роки тому +3

      If you encode the winning state w to 11, you can apply the controlled z gate to all your qubits (00, 01, 10, 11) *simultaneously*. All of them will remain the same except for the 11, which will be flipped to -11 and that's how the system recognizes it @5:50

  • @vasu_in_swiss
    @vasu_in_swiss 4 місяці тому +1

    If the oracle already knows which vector to negate the phase of, doesnt it already know that the answer is in fact what we are looking for ?

  • @Shubhamkumar-sv1ty
    @Shubhamkumar-sv1ty 3 роки тому +2

    the oracle flips the winning state but it has to go through the superposition of state to flip 11 to -11 its doing the work of searching then how is it different from classical computation

  • @noahchou892
    @noahchou892 3 роки тому +2

    Thanks for the wonder video. However, i have difficulties in understanding the implementation of the reflection. 14:08 you mentioned takes all superposition state back to all zero state. If the state is all zero state, then the control z can not add the negative phase right? (Do you mean all one state)? Even if this is true, how does this implementation means the reflection operator 2 |s>

  • @Cybernetblog
    @Cybernetblog 7 місяців тому

    now the question is how did i encode an actual word or intergers into those basic state?? This is quite interesting, but in reality i think it will be an actual word or intergers rather than quantum basic state

  • @juanete69
    @juanete69 3 роки тому +2

    You designed the cz gate ad hoc for "11". But how would it be done in general, for any number?

    • @juliaplewa662
      @juliaplewa662 2 роки тому +2

      If the answer was 01, you would have to negate the qubit that's supposed to be 0 before applying the CZ gate, but otherwise you wouldn't need to treat it any different.
      If there were more than 2 qubits, the idea would stay the same - you'd just need a Z gate with more control qubits. Such gates are typically not readily available, but Qiskit does have a Multiple-Control Toffoli (MCT) gate that could easily be used for this.
      I recommend checking out the paper "Complete 3-Qubit Grover Search in a Programmable Quantum Computer" - it goes over some oracle examples and it explains an important distinction between boolean oracles and phase oracles. To implement a boolean oracle, the MCT gate is all you need. To implement a phase oracle (like the one in the video), you'd need to play around with the MCT a little bit more.

  • @michellefernandez805
    @michellefernandez805 3 роки тому

    Awesome explanation Jin, thanks!!

  • @juanete69
    @juanete69 3 роки тому +2

    How is that Oracle Physically implemented?

  • @fengxiong6994
    @fengxiong6994 9 місяців тому

    I have a question on how to design the oracle and the reflection part for multiple qubits?

  • @HansMilosToquicaCaceres
    @HansMilosToquicaCaceres 3 роки тому

    Thanks man, amazing video. Keep it up!!

  • @iammouliroy
    @iammouliroy 9 місяців тому

    loved this! thanks

  • @mercyware5321
    @mercyware5321 3 роки тому +1

    Whoa thanks for all thar knowledge 😍

  • @ryanhasmanners9997
    @ryanhasmanners9997 3 роки тому +1

    But you need to know what it’s going to output in order to program the oracle function, so what’s the point

  • @SwapnilMore2ME
    @SwapnilMore2ME 3 роки тому +2

    Hi,
    What is the difference between the two backends used in this video ('statevector_simulator' and 'qasm_simulator')?
    I executed the circuit on both of them, and the result looks the same.

    • @juliaplewa662
      @juliaplewa662 2 роки тому +1

      Statevector returns the amplitudes (which you can square to get the probabilities) and Qasm pretends that it's actually making measurements by sampling the probability distribution (the one determined by the amplitudes).

  • @tycooperaow
    @tycooperaow 3 роки тому

    This was very informational!

  • @nikhilashodariya
    @nikhilashodariya Рік тому

    How does it comes to know what is amplitude of the target like which amplitude to increase? does it checks one by one?

  • @akshitkushwaha9479
    @akshitkushwaha9479 2 роки тому

    Thank you Qiskit

  • @najilulbarokah
    @najilulbarokah Місяць тому

    how to solve this ImportError: cannot import name 'Aer' from 'qiskit'

  • @kunalkasodekar8562
    @kunalkasodekar8562 3 роки тому

    Wow, great explanation!

  • @LarreaAI
    @LarreaAI 3 роки тому

    Great video, thanks!

  • @alimahmoudali1390
    @alimahmoudali1390 11 місяців тому

    How programming the Quantum Cat swarm optimization algorithm ?

  • @juanete69
    @juanete69 Рік тому

    Any video explaining this with real circuit components, how to design them, how to initialize them, how to control them, how to read them... with a real example?

  • @Steve168xyz
    @Steve168xyz 3 роки тому

    Hi Jin
    Thanks for the great vids in here - I tried to google of how to create the super position / entanglement / interference? but now found any related docs

  • @gabrielmonteiro3388
    @gabrielmonteiro3388 3 роки тому

    Would this be the right algorithm for a quantum version of the stable marriage(stable matching) problem?

  • @TheCJD89
    @TheCJD89 3 роки тому

    Really cool. Thanks

  • @p2187-z5e
    @p2187-z5e Рік тому

    Where we define 11 to oracle?

  • @reachingout9285
    @reachingout9285 3 роки тому

    So would it be smart to make some sort of dictionary, where a value (like 7) had an assigned qubit, and you used a quantum computer in the same way as the video?

  • @lindavid1975
    @lindavid1975 3 роки тому

    In Out[8]: array([ 0.5+0.j, 0.5+0.j, 0.5+0.j, -0.5+0.j]) @9.22 How do you know that the "-0.5 +0.j" statevector corresponds to the 1,1 state of the oracle output? Since the quantum calculation is done simultaneously, how can you be sure of that order?

    • @jin-sungkim8492
      @jin-sungkim8492 3 роки тому +2

      the convention of the output array is such that each element of the array represents the coefficient of the basis states in sequential order, so in this 2 qubit case the elements of the array represent the coefficients of the following states: 00, 01, 10, 11. hope that helps!

    • @erickjian7025
      @erickjian7025 3 роки тому

      @@jin-sungkim8492 Hello. I wonder where did you define the dataset to contain only 4 elements (00, 01, 10, 11) ? Is it by you used 2 qubits ? Also where did you define the oracle only changes sign for state 11 ? (is it the default setting of the simultator) ?

    • @juliaplewa662
      @juliaplewa662 2 роки тому

      @@erickjian7025 The datasets has 4 elements, because 2 qubits were used (2^2 = 4). The oracle marks the state 11, because that's how it was implemented. To mark the state 01, we'd need to add an X gate to the first qubit before using the CZ gate.

    • @CaceresHoracio
      @CaceresHoracio 6 місяців тому

      To mark the state 01:
      #define the oracle circuit
      oracle = QuantumCircuit (2, name= 'oracle' )
      oracle.cz(0,1)
      # oracle.x(0)
      oracle.x(1)
      oracle.to_gate()
      oracle.draw()

  • @QuantumSteve
    @QuantumSteve 3 роки тому +1

    Nice!

  • @bm-ub6zc
    @bm-ub6zc 2 роки тому

    If Grover is the 2nd most popular quantum algorithm, which one is the 1st most popular? The one that can crack RSA?

    • @qiskit
      @qiskit  2 роки тому

      Shor's Algo

  • @afv726
    @afv726 2 роки тому

    Great Thank you

  • @harikrishnank.j.4954
    @harikrishnank.j.4954 3 роки тому

    Are the oracle, reflection circuit structures same in the case of higher qubit grover circuit? Whether these are specific for this particular winning state?

    • @jin-sungkim8492
      @jin-sungkim8492 3 роки тому +2

      for the 2 qubit case one can add x gates to the oracle so you can define an arbitrary basis state as the winning state (the winner doesn't have to be |11>!). For the larger qubit cases, you will generally need additional gates to define the oracle and reflection operators, see for example here: qiskit.org/textbook/ch-algorithms/grover.html#3.-Example:-3-Qubits-

  • @kevinli431
    @kevinli431 3 роки тому

    How would do this to bigger lists? This might be dumb but would the possible unique values in a list be limited by the number of cubits then?

    • @jin-sungkim8492
      @jin-sungkim8492 3 роки тому

      yes you are correct. for larger lists one needs more qubits. however, the number of elements in the list that can be represented scales exponentially with the number of qubits, ie 2^n.

  • @varshneydevansh
    @varshneydevansh 3 роки тому +3

    That Damn Portrait

  • @nisalbimsara4105
    @nisalbimsara4105 Рік тому

    In quskit can I define qutrit gates???

  • @generalsnicky3219
    @generalsnicky3219 3 роки тому +2

    I do not understand this algorithm... if the algorithm returns the winning state, and you coded the algorithm with knowledge of the winning state, then what does this algorithm tell us?

    • @ryanhasmanners9997
      @ryanhasmanners9997 3 роки тому

      Exactly what I don’t get, sounds kinda dumb tbh

    • @iamsantanubanerjee
      @iamsantanubanerjee 3 роки тому +1

      For this particular example, it seems useless. But, you can apply constraints and create your own oracle function to find solutions you don't know where it exists. The Qiskit textbook has a simple sudoku example on that. I'd recommend taking a look at that!

    • @juliaplewa662
      @juliaplewa662 2 роки тому

      @@iamsantanubanerjee +1 on the Sudoku suggestion, it's a great example. Grover's algorithm is much more useful as a constraint satisfaction algorithm. In the video, the constraint is just `x0 AND x1`, but you could implement more complicated constraints that don't have super obvious answers.

    • @allanaraujo2157
      @allanaraujo2157 2 роки тому

      it tells that what you looking for is on the list w sqrt(n) time

  • @NewsSphereNetwork
    @NewsSphereNetwork 3 роки тому +2

    Honestly, I didn't get anything from this one, Unfortunately

  • @Great.American.Stories.
    @Great.American.Stories. 2 роки тому

    Does anybody know where I can find the complete code for this?

  • @jackalhu8228
    @jackalhu8228 3 роки тому

    Intro Grover‘s algorithm 05:03

  • @fredidi4918
    @fredidi4918 Рік тому

    This is not showing how he guessed the secret at all. Why there is no input?

  • @AKILANDESWARIA-vz3mc
    @AKILANDESWARIA-vz3mc Рік тому

    if i want 10 as a winner what should be changed

  • @bhargavpatel4781
    @bhargavpatel4781 3 роки тому +1

    Can you make video on VQE

    • @qiskit
      @qiskit  3 роки тому +3

      Hmm you might like the next episode

  • @mantiksalcpp
    @mantiksalcpp 8 місяців тому

    Where is your "marked state"

  • @Charan_Vendra
    @Charan_Vendra Рік тому

    The only thing I don't understand is why you have to call it "oracle". Why not call it a black box or a function.
    And what is the point of this video?

  • @mimArmand
    @mimArmand 3 роки тому

    So how does the Grover Algorithm work again?!

    • @schmetterling4477
      @schmetterling4477 2 роки тому

      The same way every time that another idiot on the internet thinks he has to implement the only QC algorithm that he know again and again and again.

  • @schmetterling4477
    @schmetterling4477 3 роки тому

    You aren't using a quantum computer. You are using an extremely slow simulation of a quantum computer written in Python. :-)

  • @AsifShah-fi7oj
    @AsifShah-fi7oj 3 роки тому

    I need that music in the beginning

    • @qiskit
      @qiskit  3 роки тому

      open.spotify.com/track/25fvSzPCfev7xpoNKiFx2B?si=H41aZxHhTsaU17nKqDh3Ew

    • @sergeyivanow5648
      @sergeyivanow5648 3 роки тому

      Please, answer the question: "Amazing! A question tho: how does the quantum version of this algorithm refers to the problem in the beginning? Or how can we pass the function through the circuit in order to get the index of the winning number in the list? I just still can't see how the two problems are the same. I've learned the operators used in these circuits but please somebody HELP! Quantum computers are so interesting to me but I still can't "translate" the boring for-loops to a quantum circuit and I really"

  • @divyanshusingh239
    @divyanshusingh239 3 роки тому +2

    First Comment is mine now . This is posted before the video ends XD

  • @장규상-l8i
    @장규상-l8i Рік тому

    ㅇㅎ qiskit에 한국인?도 있군요

  • @Shubhamkumar-sv1ty
    @Shubhamkumar-sv1ty 3 роки тому

    what's the name of the theme song???

    • @qiskit
      @qiskit  3 роки тому +1

      open.spotify.com/track/25fvSzPCfev7xpoNKiFx2B?si=ejjTEIhiSrqyaBQdB2uTXw

  • @iandmetick07
    @iandmetick07 3 роки тому

    It's better, but still not super fast. Log n is ideal.

  • @ZapOKill
    @ZapOKill 3 роки тому

    this (classical) oracle function should never pass a PR

  • @shemmo
    @shemmo 2 роки тому

    IBM Quantum but uses Apple laptop

  • @soroushasadzadeh1410
    @soroushasadzadeh1410 2 роки тому +2

    One suggestion, please never explain anything to anybody anymore :D I didn't understand anything :D even I confused the things I have already known.

  • @krokenstiv8777
    @krokenstiv8777 Рік тому +1

    you did not solve the original problem, and you didn't explain why it works. qc is fake

  • @spottery2k
    @spottery2k 8 місяців тому

    I took a crack at it and imported everything as shown in the video on my Windows 64-bit system, but get import errors at Aer.get.backend(). Any ideas?