Previous work from other groups
Folding model architecture vs inference
- Folding model architecture
- Pros: get much more compression ratio as we wish per inference
- Cons: require models to be specifically designed for folding, which might not be practical for the current web2 industry
- Folding model inference
- Pros: do not need to modify current models
- Cons: performance still limited by the model depth and complexity
Let's try to fold model inference!
In order to use Nova-Scotia to fold Circom circuits:
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More โ
We write a circuit that takes a list of public inputs (these must be named step_in for the Nova-Scotia interface) and outputs the same number of public outputs (named step_out). These public outputs will then be routed to the next step of recursion as step_in, and this will continue until we reach the end of the recursion iterations. Within a step circuit, besides the public inputs, Circom circuits can input additional private inputs (with any name/JSON structure Circom will accept).
Let's try to write out the step_in
, step_out
, and private inputs at each step!
Scenario 1: Public Data, Private Model
Attempt 1: naive approach
signals |
Step 1 |
Step 2 |
โฆ |
Step N-1 |
Step N |
|
|
|
โฆ |
|
|
|
|
|
โฆ |
|
|
private inputs |
model weights |
model weights |
โฆ |
model weights |
model weights |
Issues:
- the size of the public outputs (hence the size of the proof) grows linearly
- a lot of switchers need to be used to insert at the correct positions
Attempt 2: Merkle root?
signals |
Step 1 |
Step 2 |
โฆ |
Step N-1 |
Step N |
|
|
โฆ |
|
|
|
|
|
|
โฆ |
|
|
private inputs |
|
|
โฆ |
|
|
Improvements:
- less public inputs/outputs
Issues:
- order of data matters!
- relatively cheaper (than Attempt 3) if try to verify the entire tree on chain
- number of hashes per step
- need to publish Merkle leaves elsewhere
Attempt 3: Recursive hashing?
signals |
Step 1 |
Step 2 |
โฆ |
Step N-1 |
Step N |
|
|
โฆ |
|
|
|
|
|
|
โฆ |
|
|
private inputs |
|
|
โฆ |
|
|
Improvements:
- only 2 hashes per step
- less signals to pass around
Issues:
- order of data still matters
- very expensive to verify on chain, but luckily we can precompute and commit the final hash
- need to publish raw inputs elsewhere
Scenario 2: Private Data, Public Model
Attempt 1: naive approach
signals |
Step 1 |
Step 2 |
โฆ |
Step N-1 |
Step N |
|
|
|
โฆ |
|
|
|
|
|
โฆ |
|
|
private inputs |
|
|
โฆ |
|
|
Issues: same as Scenario 1 Attempt 1
Solution: see Scenario 1 Attempt 3
Issues:
- we will need to publish the model weights elsewhere