Polybase feedback #497
Replies: 2 comments 1 reply
-
Hey @calummoore thanks so much your feedback! It's great to hear you're enjoying using Miden & also great to get concrete suggestions. 1. Named breaksAs you've pointed out, this would be useful, and I like your suggestion to follow the Web Assembly However, it would be quite a bit of effort to implement, so it's something we were planning to deal with at a higher language level. If you guys have the bandwidth to work on it, the PR would be very welcome and we'd be happy to discuss and provide guidance throughout. Since it's your top priority, maybe this makes sense for you - if you want to go for it, feel free to open an issue and we can move future discussion there. 2. Float32Floating point emulation support would be good to add, but we'd prefer to add this to the standard library rather than to the assembly instruction set. There's also the question of what your needs are here - do you need true IEEE standard float support or is it sufficient to have some fixed point ops? Let's move this to an issue - can you create one with a bit more detail about your needs? 3. Recursive proof verificationWe're working on this! 🎉 We need a few more things in AirScript before we can finish this though. We're working on improving the transparency of our roadmap & releases, so expect info about the status/progress of this to be more available in the coming weeks. I can update here once that's happened. 4. Recursive proc callsThis would be possible to do, but it's really complicated, so it's not something we can focus on at the moment unfortunately. 5. Advice tape to memoryWe ran into this too and closed an issue on it this week! We've added 6. movup.n for n > 15This is difficult to do and probably not worth it at this point. If the main benefit is to manipulate the stack more easily and use memory less then maybe program restructuring can achieve the same goal. @itzmeanjan has done a bunch of miden assembly work on the stdlib hash functions including several rounds of optimizations and can maybe share some general thoughts. 7.
|
Beta Was this translation helpful? Give feedback.
-
Sure! We should have our next steps sketched out in the repo next week. I'll update here, and then you guys can join the discussion and decide how involved you want to be.
Sounds good on both counts - we'd be looking at this for stdlib down the line anyway, so we can revisit whenever. It'll be awesome to get benchmark results when you have them
No, actually stack items after the top 16 are no longer stored in the main execution trace. We put them into a "virtual table", and we maintain consistency using multiset checks on a column in an "auxiliary" trace that we build after committing to the main trace using randomness we get from the verifier. (This may be familiar, since I used our stack overflow virtual table as an example in my zkSummit talk about multiset checks in STARKs) The complexity of doing this would be in the constraints. It's straightforward to enforce constraints against the top 16 stack items because they're all in the main trace. However, if we need to take something out of the virtual table (at an arbitrary row) and put something else into it, then the constraints become more complex and likely higher degree so that we'd have to add another column for degree reduction, etc. The cost doesn't seem worth it in terms of both increased complexity and loss of performance.
Yes, exactly :) I'm going to move this point to the discussion in that issue so the context stays together. |
Beta Was this translation helpful? Give feedback.
-
We're currently building/compiling our Polybase language (based on typescript) to miden assembly.
Firstly, Miden has been incredible to work with, it's amazing what we can already build with it 🔥. Just wanted to share some feedback on our experience working with it.
In order of priority (from our side).
1. Named breaks
Currently there is no way to break early from code, other than using lots of nested
if
statements.Current solution for break in loops
Current solution for early return
Our recommendation, would be to have named break clauses, that allow for breaking within a given block of code. This would enable us to skip blocks of code more easily, and thus implement better
throw
,return
,continue
andbreak
logic.You could achieve this by adding two new commands:
block.<name>
andbreak.<name>
. This is similar block in WebAssembly.This would also allow us to inline our functions, instead of using procedures. Inlining functions lets us move values around less and optimise things like shift right to use a constant (compile time known) value instead of reading from stack (4 cycles vs 40 cycles).
2. Float32
We can obviously achieve this currently, but I think a lot of optimisation could be done if this was handled by the miden assembly.
3. Miden verification (verify proofs in miden)
This would allow us to:
4. Recursive proc calls
We're unsure how we would be able to do this with the current miden assembly.
5. Advice tape to memory
A lot of the time we are moving data from the advice tape to memory, as the VM can only access the head of the tape. It would be useful to be able to optimise this process if possible.
Currently in order to move from advice tape to memory we use
adv_push.n
and thenmem_store
. It would be great to have a single command to move multiple values into the store at once, so instead of:adv_push mem_store.1 drop adv_push mem_store.2 drop
we could haveadv_to_mem.2.1
where 2 is the number of field elements to read and 1 is the start addr. It might only be worth doing this if we can reduce the no. of cycles.6. movup.n
movup.n
(and associated cmds) currently only allow to move values from the top 16 items in the stack. This means we have to move more values into memory rather than keeping them in the stack. Now that the stack can be >16, it would be good to be able to use these values by bringing them to the head.7. Mem store + drop
A variant of mem_store that swallows/drops the value stack element, i.e. equivalent of
mem_store drop
. As we usually don't need the value immediately after its been put into memory.8. Int32
Currently we only have
unint
variants, would be helpful to have anint
version. We have already implemented this, but again, I'm sure it would be more performant if it was handled by the compiler.Let me know if you have any questions, or if anything is unclear!
Beta Was this translation helpful? Give feedback.
All reactions