Scale By The Bay 2021 : Chris Fregly 10 Things You Should Know About Quantum Computing and ML
[Music] i've got uh 10 things that i think you should know about quantum and machine learning uh there's a lot of cool stuff in this field it's pretty new field um well it's not a new field it's actually quite an old field but it's new in the sense that we're starting to actually see some real progress and uh concrete advancements in this area and so i'm here to sort of break down a lot of this and try to unders or try to help you understand some of these fundamentals and how you can apply these to your big data and machine learning workloads and just to manage expectations we aren't quite there yet so at the end of this i've heard um i've done this talk uh once before in uh london and the term that uh one of the people used to describe this talk was bonkers and so that's a british term for uh crazy i guess so there are lots of crazy ideas here but just bear with me let's get through the fundamentals let's show uh i'll show you a cool demo as well too at the end and how to use aws to actually try out some of these bonkers ideas and so check out the book too we actually do have a section in there about quantum uh this book was released earlier this year uh it's it's totally up to date um about 500 pages i think a couple hundred code samples uh 250 images it's it's insane it's a bonkers book so uh check it out all right so the best way to think about quantum and quantum mechanics is that it's nature's operating system right so we and it's this field is a combination of many many disciplines so there's quantum physics there's electrical engineering chemical engineering material science thermo photonics of course our favorites linear algebra and probabilistic methods um and that's just a few of them einstein calls quantum mechanics spooky or called uh he is no longer with us uh but he in his own words that no reasonable definition of reality could be expected to permit quantum mechanics uh still lots of internal debate in fact i just got off a call with uh one of the heads of the amazon bracket quantum service and he and i were having internal debates about this so uh there's there's a lot of debate within the actual quantum academic community as well as uh the practical and the applied side as well too also keep in mind that there are lots of hardware limitations to quantum and if you think about how you know the world was with uh transistors you know way long ago that's really where we're at with quantum it's trying to um it's you know trying to capture this power into something that can be manufactured that can be uh scaled out and can ultimately end up in a you know small little iphone like we have here uh so some of the quantum fundamentals and you'll see this in the upper right here which i think might be actually blurred out by something but i show this in multiple places so don't worry you'll see it here in a bit but the first thing that we have to do is oh well to start there's this concept or this uh physical construct called a qubit and so think of it like a bit right like a physical bit a digital bit that we are familiar with and this qubit can really be in this linear combination of a zero or a one probability and so but when we go to actually measure the qubit it then collapses into either the zero or the one okay and so some of you might recall the schrodinger principle and that kind of thing uh and that that's it is certainly related here i don't bring it up here much because it's it's just another buzz word that isn't really um uh that um important for the way that that i present this so this qubit when when and the whole idea of quantum is to put these qubits into what's called superposition and that's this probabilistic state and what you're trying to do also with these quantum algorithms is you're nudging those probabilities to get closer to one or closer to zero okay and so and then but now keep in mind that when you do go to measure that qubit does collapse into zero or one so it's not actually true some of you might have heard that a qubit and superposition is a zero and a one at the same time and that's not technically correct and this is one of those internal debates and internal external practical uh sort of theoretical uh differences in uh so this quantum community i've come to realize by the way is uh very precise in the way that they describe things and if you don't describe it in that precise way um you won't really get very far so i've actually had to you know figure out how these things are presented and hopefully i'm sharing those with you here today uh and so there's also this concept of entanglement and this is really the spooky part einstein was talking about here which is two qubits can can actually be connected such that when they're measured they will both go to the same state 100 of the time even if they were in different you know probabilistic states separately thousands of miles away they can be entangled such that they both collapse to a zero or both collapse to the one and so i measured that or yes i mentioned we are constantly trying to nudge these uh probabilities and nudge you know nature's operating system uh into something that we can use and train models or solve you know large uh complex linear systems of equations and the way that we do this is using waves and so we can use constructive and destructive waves that can help to amplify or de-amplify uh and nudge these these probabilities and so just like in classic you know digital bits we have um circuits right and we have like algorithms uh and so that's the same with quantum they're called gates and they're called operators uh and these are what we use to do this nudging and oh yeah i should also mention that uh there is this photonics subset of quantum that actually uses photonic pulses to do this nudging and so when you talk about quantum i actually have a slide on this later there are different uh there are different implementations of quantum so it would either be you know super conducting super cooled which is classically what we see when we see the google and like the ibm um those like images of a quantum computer but there are also uh photonic based uh like implementations and hardware that's using light to do this nudging a couple gates that you should know about uh there is one called the hadamard and this is what actually puts our uh that qubit into superposition okay and that's you know typically h and that's you know somebody's name very famous person's name uh and then there's also controlled knots so c knots and so just like we have knots and and you know in like classical digital bits there's something called a controlled knot a c naught that entangles two qubits and it's basically like if this first qubit is this value then that um it is now entangled with that second value uh some like algorithms to know about so these algorithms build upon these these uh gates and these operators shores algorithm this is what you'll hear and read quite a lot about when you read quantum where they talk about how to perform prime factorization with um at like quantum scale and with quantum hardware there's also quantum walk where we're walking a graph for example determining the minimum path between two like vertices in our graph so very common algorithm to implement also grover's search algorithm uh grover search algorithm is the basis for quite a lot of other more advanced algorithms and uh really for specifically optimization problems and really builds on amplification which we discuss with the constructive and the destructor and so there's examples here so you see in like the upper right where that that image uh the that first section i was talking about where we nudged a little bit and got 51 49 uh you see on the right the image of you know really there are only about 12 operators um 12 is there 12 there maybe 10 operators uh and with those you can now construct you know many uh hundreds of uh circuits and then other algorithms and then yes ultimately bottom right we see the results of a grover search algorithm where one of the results ha is now the most amplified and that is the answer uh with you know so with like 81.6 probability that's the right answer and what we've done is through a series of gates and these operators we have nudged and used quantum to solve our problem so let's talk about quantum eras and this term quantum the quantum supremacy so we are in the second era which is called noisy intermediate scale quantum so nisk era that's where we are if you look at that chart on the right it's the big black area there uh the the first era was more where we were simulating and you know now we are at the point where um we are seeing moderately useful apps and actually have an eye towards uh this concept of the advantage um where quantum does have the advantage so these are sort of loose terms they were coins i believe by google um quantum supremacy which we theoretically just crossed over i believe in 2019 and that was a pretty easy uh simple problem but we showed that the quantum computer could do more than a classical supercomputer okay it was a very a super simple problem uh not very useful to you know businesses applications uh but did show that we reached this state of supremacy but we really want to be at the advantage where we see linear speedups and then hopefully exponential speedups over classical computers with these modern machine learning algorithms and so keep in mind too that the final era will be this error corrected so i should mention that noisy means this hardware is still pretty noisy right so trying to capture uh nature's operating system is not an easy task and requires super cooling you know requires a lot of special hardware uh custom-built hardware and we are not at the point where all of our qubits can be utilized fully in other words we need these extra qubits to actually you know help uh fix this uh light error and do the actual error correcting so very similar to error correcting ram and you know back when we used to pay attention to that like we don't really pay attention to it today uh it still happens uh there's just there's plenty of hardware now to help correct uh those uh error on the on these modern chips and so one thing to note is we are at the stage of about 100 qubits you know maybe getting to a thousand qubits here soon uh so below 50 not very useful between 50 and 100 000 could be useful um 50 not so much but and then of course greater than 100 000 will um you know in theory these numbers are all just sort of you should think of them more as uh like orders of magnitude versus specific numbers right but just keep in mind that until we can solve the uh problem of like error correction we really can't uh use all of these uh yeah these qubits and now there's so 0.5 here is quantum data qram and then yeah of course error correction so classic data has to first be put into this probabilistic superposition before we can operate it um inside of this uh right this quantum computer and so keep in mind that 30 qubits does require 16 uh like gigabytes of ram and we can simulate that because we have modern hardware that you know one single instance can hold 16 gigs 16 terabytes 40 qubits um is needed to store 50 qubits of data uh yes we need 16 petabytes and now we're starting to exceed what we can simulate right so uh and i'll talk about simulators here in a bit and of course yes aws bracket or yeah sorry amazon bracket does have simulators uh but they're more in the 30 to 40 qubit range because of these ram constraints and so without qram by the way and this is really how things are happening today every time that we execute a circuit that data has to be converted from disk or from you know classical bits into superposition right has to go through this uh hadamard gate and if we have to do this every single time i mean think about you know trying to do this with 16 gigabytes 16 terabytes 16 petabytes just to run you know a single algorithm or one pass through the algorithm right because keep in mind we are typically going one pass through and then making a small change doing another pass you know classic sort of uh like hyper parameter tuning or or just you know going through the data set multiple times to do multiple iterations and so this is a huge barrier to trying to achieve these linear and exponential speed ups over classical supercomputers and also keep in mind that classic sort of redundant error correction is difficult because there is this fundamental concept of quantum mechanics called no cloning you can't actually clone matter uh but um if you could we would be living in a very different world there's a lot of uh you know crazy things you can think of there if we were able to actually clone um and so so with quantum mechanics just know that there is a no cloning principle there are tricks to do error correction and there's a lot of research in this area because really without qram we would have to do this conversion every time and it's infeasible uh to do anything useful when we have to continually go from digital to superposition uh that's where all of the time will take place because once you actually get it into superposition then those operations happen pretty quickly uh so let's talk about hardware differences so i mentioned earlier there's superconducting there's something called trapped ion and then photonics these are really sort of the high level uh differences and a lot of companies in in this area now of course aws being aws uh they like to give options to their customers and so they support um superconducting and trapped ion uh there's three companies right now that we work with and yeah hopefully more coming um and there's different methods so there's like the the like gate base is the version that we've been talking about up until now where um i showed you gates being chained together into circuits there's also annealing which is um d-wave actually does quite a bit of that's their whole method and they claim to be superior in terms of uh like optimization problems with the annealing method we will talk about gate base it's you know really the one that is closest right now to the integration with these machine learning libraries so uh yeah amazon bracket sports all supports these so here's here's one image here uh so there's d wave we have ion q that's the trapped ion and then superconducting by regetti also it is public knowledge now that uh as amazon is working on their own quantum computer and i believe it'll be super conducting based and if you go through the like amazon job postings like you could pretty much figure that out yourself as well too based on the types of people that they're trying to hire all right let's go to quantum programming sdks and simulator so here's where the rubber meets the road if you will as the saying goes so this is where you know us as developers we want to know how do we get access to and start to build these quantum algorithms or even just simple circuits and so there's something called open chasm with a queue as everything of course in quantum starts with a queue or has a queue somewhere uh and this is really the assembly language if you will um and this was pioneered by ibm and and now is um now open uh it's not very readable you know just like any assembly language it's just kind of cryptic you can kind of make it out if you're you know willing to spend the time doing that mental mapping um or you could use something called this kit um and key so that's q i s k i t this is also by ibm uh it's a layer on top of uh open chasm and um i believe it's public now but yeah amazon is supporting open chasm uh and so we are working on the amazon bracket apis that actually sit on top of like open chasm and so similar to how ibm kisket sits on top of open chasm and very very well documented by the way kiss kit is a super well documented lots of examples um ibm even has the summer school quantum school i highly recommend that you check out um you have to basically be there the day that the link goes live otherwise you won't get in uh i don't have a link offhand but if you google ibm quantum summer school uh you'll be able to find it uh and so uh you know google being google has um created their own sdks and you know specific for their google hardware for their google quantum hardware um i haven't heard uh much about them supporting openchasm um i don't even think that they're involved much i could be wrong but i should double check that before saying but they do have their own apis the the cool thing about google's apis is they are actually now part of tensorflow and so tensorflow now has this library tensorflow quantum that has these optimized hybrid algorithms that can do um you know sort of classical machine learning and only use the quantum computer to do quantum optimized operations and so of course you still have to get the data in and out of superposition but uh in certain cases it's worth it and so uh definitely check out tensorflow quantum uh there's also of course the amazon bracket sdk that i mentioned the benefit of the amazon bracket sdk if you are already using aws uh with just a single line of code you can change the hardware like i showed earlier um with you know a few lines of code you can integrate with amazon s3 to get your data from s3 into superposition uh you can um yes a bracket uh natively integrates of course with like ian security and of course cloud watch for the logging so you you know have all of the fundamentals you have data security uh you have uh different hardware and you have logging all built in uh just by using that sdk and of course bracket sdk does support opencastle now penny lane this is uh by a third-party company but it is open source uh a company called xanadu with an x they're out of canada uh this is also open source quantum machine learning they support tensorflow pytorch they have plugins for amazon bracket uh for you know all the hardware supported by amazon bracket for the google circ hardware also so check out penny lane a lot of really cool examples uh that company xanadu by the way is one of the companies pioneering the photonics version uh of quantum uh so check that out if you're interested and then also simulator so all of these these apis have some sort of simulator that you can run and basically simulating in on classical computers some use gpu some don't really need the gpus but they support the these you know six or five api six apis and um can actually run your circuits your uh like quantum circuits um they are limited though of course to you know 30 qubits maybe 42-bits uh the other cool thing is that they can simulate noise there's literally a flag that says noise equal true or you know noise percentage equals 10 something like that that can simulate the randomness and the the noise sorry not randomness but the noise that is coming into the quantum computer which is very sensitive to the outside environment these are the simulators that are currently available so we see 34 qubits 50 qubits and then 17. so maybe check out uh some of those and let's talk about quantum machine learning algorithms and i've got about six minutes left so i'll probably have to share the link to the github um if i don't have time for the demo but uh i'll at least show it to you so yeah quantum machine learning the the cool thing here is with these hybrid algorithms we can do things in the near term and just do short bursts of qpu computation so similar to how we would do like gpu computations using the nvidia gpu for certain things we and but still be coordinated by the cpu so for example all the if statements if something then missed that's all on the cpu uh but then we would then dish it off to the gpu to just do massive parallelism and so similar kind of thing where we would have qpu that we pull in quantum machine learning research has actually inspired improvements to classical algorithms and so there's this really cool archive paper here quantum inspired classical algorithm for recommendation systems there's also a variant of gradient descent called quantum natural gradients and so by studying these things in this this newer quantum world and we can actually make changes and improve classical algorithms and so uh we'll see we there's quantum variation algorithms that train circuits like neural nets so we can actually do uh you know similar to neural networks uh principal component analysis support vector machines clustering uh linear regression binary classification quantum neural networks now just for to be completely upfront these are very slow these are not going to beat your classical uh right like versions of these algorithms and so you know while it's fun to get binary classification going which is what what my demo does with quantum also keep in mind that it is slow and it's a little bit right now expensive because of the cost of the hardware uh so you know definitely stick to the simulators those are cheap those are you know relatively free basically um you can just do it on your own laptop like you can actually run one of these simulators on your laptop as well all right so here's the uh binary classification so you know from a jupiter notebook this is the demo um actually let me get to the rest of the slides here just do nine because this is pretty important three minutes quantum use cases so these are theoretical use cases cryptography uh and factorization so not to to scare you all but i'm gonna scare you uh you know it is theoretically possible to break the 2048 bit rsa encryption in approximately three minutes with quantum now there's a lot of asterisks here and that's that this has been revised over the last couple times i've done this talk but we would need you know 6 000 clean qubits and clean qubit is error free you know noise free that translates to about 1 million noisy qubits and we are nowhere near that and you know also so chemistry material science right so doing simulations doing protein folding these are very very high dimensional complex problems to solve we can do them like relatively quickly with quantum quantum has the ability to uh you know massively scale and perform many many optimizations and can do protein folding um very very quickly and let's see optimization problems uh search and rank um and so you know 200 clean qubits for simulation maybe 100 for optimization problems using grover's algorithm uh but just know that that we're still pretty far away so the highlights for quantum potential for massive parallelism beyond rightly anything that we've ever seen today with classical computers can operate on many qubits at once while in superposition um yes i mentioned [Music] that there are theoretical speedups for certain classes of algorithms so you know back to the big o notation o n goes to o log n for example which is a huge uh performance savings now low lights current qubits do not hold state very long so up until now we've been talking about mostly the number of qubits we've talked about the error in the qubits just know that these qubits cannot hold that state for more than maybe just a few nanoseconds or you know a few milliseconds current circuits therefore cannot be very deep uh right now maybe 100 to 200 gates at the time of this um of this talk current hardware is still very noisy very sensitive to the physical environment which is why these things need to be super cool okay so i guess i'll just post the link here in the chat thank you so much you know there are there is long-term potential here just huge huge long-term potential uh currently not a lot of real world apps but you know you want to be part of this quantum flywheel and you should start to learn this stuff now um yeah check out kiss kit check out amazon bracket uh and as you know more people come online to this quantum world we start getting better hardware we start getting better algorithms uh and things get cheaper and the wheel spins so thank you much [Music] you