Scaling zk-Rollups with Hardware

ProtoLayers Talks · December 2024 · 17:32

Tibor Tribus of Maya ZK explores hardware optimisation for zk-rollups and uncovers both the possibilities and the limitations of scaling zero-knowledge proofs. The talk looks at how specialised hardware can speed up proof generation, and what that means for the throughput and cost of rollups that rely on validity proofs.

Speakers

Topics

From ProtoLayers Talks, hosted by ProtoLayers.

Transcript

okay can you hear me okay perfect so yeah I would actually like like to stay and talk with elas about all the stuff he mentioned because like my presentation will be very similar or at least touching the same topic but okay so first question like who is cryptographer or like mathematician by Design okay so I can lie to you and no one will tell uh okay so basically like I will be touching the very similar topic which IAS was talking about and this is basically like scaling ZK with Hardware like what's possible basically he was mentioning like ZK costs like 45k to 1 billion on infra cost but this is like

this huge range right like have the F you went from 45k to 1 billion right it's like oh oopsy doopsy like my accountant made a mistake so basically that's what I want to talk about so you know I will not talk about the ZK I guess you are all expert after the previous talk but we know ZK is good okay ZK is good it's maybe fast and it's secure that's that's good and we have like kind of like two ZK in this room one is for privacy the second one is for scaling so I will not be talking about someone referring to ZK ZK I will be talking about the snarks the SN part

so no like you know not for privacy purposes and why I will be talking about this and actually I choose like Hello to with kcg which alas was talking this is I don't think so I mean it's in production the chains are doing good we have like you know several teams working on this they did tremendous work and okay so we are back and basically I would say we can use you know like Hello to for something else than ZK like we don't all of us have to have our own ZK laabs you can build like you know some other cool stuff like ZK email which was also is written in Z in hello to with kg

so let's say like Hello to is good and okay so the problem is like you know ZK is the great computation it's so so we can verify like the you know statement very succinctly but we are paying right like there is a so we are paying for the proof generation and how much like I don't know or like I know I will tell you tell you later but basically why right we have like this old fancy world like commitment hashing you heard maybe like MSM several times last year ffts basically that's like where we are paying the price for sing verification right it's like asymmetric game kind of you can verify a lot but you need to pay price somewhere and the price is proof

generation okay so if you will you know just having some Friday nights out and you will be bored you start profiling like Hello to right because what else what else would you do like basically that's like pretty common and you would get this picture right so this is like the hello to kyg with 128 transaction to the 20 and to the 20 of the size of the circuit right so it's like pretty common zkl tool and you would find out like we have like this bad actas like not really bad but like the guys who are like responsible that the ZK is slow and there's like multiscalar multiplication entity or like ffts and custom gate evaluation so I mean if it would be like you know

2022 I would be talking about MSM and how we did like tremendous work how we speed up ffs but like this problem this is solved basically you know like the Z price maybe you heard someone about the Z price yeah someone okay they solved this basically I mean it's not that it's solved but it's like we did pretty good job it doesn't make sense any like not that it doesn't make sense we don't have to spend too much time I but if you will zoom in right you will see like this MSM entity and custom gate they take quite significant time so like you can see like the button okay you cannot hear me so you can see it takes a significant time in the whole computation so it's oh it's actually like 80% so so if we will

tackle like those Force we will s kind of like 80% of the computation so I don't want to go into the details of and's law but if you will speed is you get some speed up you know basically what I want to say is like let's focus on this 80% and we will be good okay and you can see actually the MSM is not 80% of the computation which maybe you were told before okay so like CPU Baseline right let's okay I still have time so if you will run your roll up you know in AWS or on bare metal and you will use CPU because you know like you spend all your money on marketing and you don't have any gpus left basically that's how much it will cost it will take how much it

will take to generate one proof and this one proof is basically as I said 128 transaction of the circuit size total 20 okay is this clear you will see this table several times like 128 like on linear SC or anyone yes on but why buy Circ size why is BU Times by what's not SC so this is like I'm not sure if it's ERC transaction to be honest now or is like you know just if or like yeah I I'm not sure if it's herec actually so that's I I actually was asking that myself and what is the size is just the zkm as a whole yeah this is like super secet okay yeah yeah

it's uh I it's it's one secret let's leave it with that it's more complicated but it's like the secret is like to 20 that's what is important okay so yeah I just took you know like one machine from AWS and one our machine like machine of our partner and yeah basically it will take like 30 minutes on like bare metal let's say but you can see like the processor is like two times slower in terms of the course or like almost two times uh and it will take like 27 27 minute in AWS so you would get proof every 27 minutes like I mean

that's not great but better than seven days but of course you can have several proofs right running in parallel but okay so 30 minutes that's how much how much does it take to generate one proof so yeah there is some potential for improvements right so either you can be like cryptographers which seems to be none of us here are cryptographers so we have so what we will do like basically we will spend our monies right so we will acquire some gpus not fpgs please don't spend your money on fpgs it's if you are not being team don't do it and A6 well we don't have any A6 several teams working on this I'm

looking forward for them to deliver because I believe there's a huge potential but unfortunately we don't have A6 today so yeah let's go with the gpus what what actually gpus can do for you like I mean what really gpus can do for you so if you were like you know I don't want to spend too much time because this I think is like two years old topic but if you will accelerate those MSM ffts that's what you can get right you will get to the 22 minutes or 24 minutes so just you know for comparison like you basically you know you wrote om from in goniana you saying hey my Pro is slow can you do something he will say yeah pay me license for icycle I will give you I will save you like well seven

minutes and you are like seven minutes faster by like writing to you know one guy for somewhere on Twitter so yeah there like you know 10% speed up up to 25% speed up but what's important like kind of you already have like 80 gpus so look at the table I'm not using one GPU I'm using like 80 gpus so that is like small trick you're already paying a lot so maybe take a moment just to see the graph so you're paying some significant amount of money you saved 7 minutes but you are utilizing GP only to like

2% not great right so I mean this is like 2022 let's move on WE accelerated MSM we accelerated ffts let's do something more so there is like I was talking about this third like computation which is called custom gate evaluation so unfortunately none of us here are cryptographers so I will just say like it's important computation you need to have it in place we can talk details later but basically we will exploit the structure so basically you can see there is like indices on the left side right 01 to up to 1 million and actually you know when you use you usually see such a thing you're starting thinking okay can

like maybe one thread compute over the whole table or does this thread needs to compute something else and we just find out actually one thread can compute over the whole table so actually can you hear me you can do like split the whole compation over the table to one thread like this so you don't have to wait like for one thre to compute over the whole table but you will you will basically there like you know single instruction multiple data which is great because we have you know this Chinese guy C of Nvidia happens to be and he gave us like gpus which are really great at this so actually so what's like this computation look like like so on the CPU we actually have eight of this computation why because we're going to the extended domain which

is like eight times why because like we Computing some quo Pol but like those are like mathematical details that's like which needs to happen right we know it's like we multiply this compination eight times and one computation one this box takes on CPU like 48 seconds right but we need to do it eight times that's the important so the whole computation takes almost like 400 seconds okay and even though like Hello to has some heavy parallelism in place but this parallelism happening within the inner Lo right so you can see we actually paralyzing the inner for so actually this is like paralyzed right but this

eight but those eight computation they are not paralized right so I mean we are smart here right we both gpus so let's use them yeah but then basically we will find out like the GPU that don't have infinite memory right which is like a suck and basically like I mean the circuit is pretty huge and also you need you know it's not like you Computing only over the one piece of data you're actually Computing over like 200 indices so we need all this data on the GPU so then it's like our so basically like you need like 67 GB of memory well I mean you I have this beautiful GPU here which I can sell

you but it has only like 24 gabyt of M so yeah we need to do something and basically like again I will not go into the details but you know you can come with some Chun processing and optimize like you know how do you reduce so actually don't need all the data in one place but you can make sure CH the CC and you need only some intermediate values so exactly what is happening you you know like one thread is Computing that's like the orange color and then we actually like just chunk process this over this table so that's like the rotations like the red colors so I know maybe this is like a bit misleading if you don't know what's going on but

basically we solve the issue that's like we are great right we are like celebrating because we went from like 30 gigs of memory to 4 gigs of so now the whole computation fits to one GPU okay so what's the Baseline right right so we have like single GPU and if we will run this computation we actually say like what 29 seconds that's good or bad what do you think I mean it's not great right I mean you're paying a lot and you just said like 29 seconds right it's it's okay it's it's not great is okay so basically but still holds we need like eight of

this computation right so it's like 19 seconds * 8 is still like 152 seconds so we went from almost like 400 seconds to 152 seconds not great but like that's not what you know want to this not the asymmetric return right you you want to get you want to pay a lot but you want to speed up a lot so actually you can use different GPU right so what can GPU do for you if you will switch from L4 which is like 19 seconds to 490 you almost saved 50% right so you can see like the you can go like from the 90 seconds to 10 seconds so this is maybe interesting right and the 409s are not that expensive compared

to L4 but yeah you saw maybe you know remember I had the agps actually on the server so I mean this is not some black magic right this is like kind of obvious you can split this computation amongst the eight gpus and compute it at Once In Parallel right so actually we will really go from this 400 seconds to 19 seconds and that's that's actually you know you're paying a lot but you are already starting to getting something on return right okay so now we kind of Saved like you know we went from 40 400 seconds to 19 seconds and then you are checking and then you see you will I mean you will start your computer inside system inside

compute and you will find out actually you spend like seven SEC or like six seconds on data transfers this is like no I okay we are back I don't want to say like bad but it's like you actually realize like the compu is not the problem the problem is memory so either like the memory is restricted because you don't have enough memory or actually you need to like transfer data right the comput is is is great actually the computer is not a problem so if you know like heard someone like about the acceleration just think about it like usually the memory is the problem not the computer but okay so can we do something yeah I mean this is if you ever heard

about the gpus you wrote some code you basically can leverage like multiple streams so actually you can see the first case is like very I don't want to say stupid I will say naive or like simple and actually it's like you copy some data because we're doing this chunks because of the memory so we cannot process the whole ccle at once we need the Chun of the data then we ex you know execute the C and we're doing this and that this and that right so not great but actually you can mask the execution with copying the data right that's like smart and actually you can save like you know we went from 19 seconds to almost 14 seconds on The L4

so so yeah that's pretty nice right and okay so what does it looks like at the end so What GPU can do for you right that's like where I will answer the question is basically if you you can like with 80 gpus go from like almost 400 seconds to 14 seconds there like 27 times Improvement and this is getting know to some what interesting or if you will lose like 3090 4090 you can get almost like 40 times speed up right and this is what you want to get if you are paying a lot you want to get at least this okay yeah so this is like just the you know WRA up like so we basically went like from 30 minutes or like 27

minutes on the CPU to 17 minutes on the GPU right and then like alash was mentioning basically how much does it cost so basically one of these machines in Cloud which is like AWS the gcp will be very similar cost like $9,000 right this is like this is in Frankfurt so pretty expensive region I know you can get some cheaper but I would say it's a lot basically we fast we building servers our partners Ro is building server and we have like faster server and you know three times cheaper so I would say like ZK is already on a good stack like way to become cheaper because this is the most expensive it ever be you know from this point of

time okay and thank you thank you all than