Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Range checker improvements #395

Closed
Tracked by #603 ...
bobbinth opened this issue Sep 11, 2022 · 3 comments
Closed
Tracked by #603 ...

Range checker improvements #395

bobbinth opened this issue Sep 11, 2022 · 3 comments
Assignees
Labels
air Related to Miden AIR and constraints processor Related to Miden VM processor
Milestone

Comments

@bobbinth
Copy link
Contributor

bobbinth commented Sep 11, 2022

In the current implementation, the range checker component (described here) consists of two tables: 8-bit table and 16-bit table. We use a selector column to identify which table we are in.

This structure can be greatly simplified if we get rid of the 8-bit table entirely, and instead, use a single constraint to allow "jumps" between two consecutive rows of the 16-bit table to be at most 8. Denoting $\Delta v = v' - v$, the constraint would look as follows:

$$ \prod_{i=0}^8 (\Delta v - i) = 0 $$

This constraint would have degree 9, which is fine for us.

The advantages of this approach:

  • The range checker becomes much simpler.
  • We can get rid of 1 main trace column (the one that is used as the selector) and 1 auxiliary trace column (the one that is used for the 8-bit table).

The drawbacks of this approach:

  • We'd need to increase the minimum trace length from ~1K rows to about ~8K rows. In my mind this is not really a drawback as the vast majority of programs are likely to be 8K rows or more. However, this will affect test runtimes, and we'll probably need to refactor our testing methodology to avoid increasing test times by 8x.
@bobbinth bobbinth added processor Related to Miden VM processor air Related to Miden AIR and constraints v0.4 labels Sep 11, 2022
@tohrnii tohrnii self-assigned this Dec 27, 2022
@grjte grjte added v0.6 and removed v0.4 labels Apr 18, 2023
@tohrnii tohrnii added the on hold This issue is blocked or we don't want to start it yet label May 31, 2023
@bobbinth
Copy link
Contributor Author

I think I figured out how we can make this work without having to increase the minimum trace length to 16K cycles (and maybe we can even decrease it to be smaller than 1K cycles).

The core of the idea in the original post is that we allow $\Delta v$ to be between $0$ and $8$ (both inclusive). This works but runs into limitations described in #906.

But what if instead we allow $\Delta v$ to be 9 discrete values (rather than a contiguous range). For example, it could be $0$, $1$, $2$, $4$, $8$, $16$, $32$, $64$, and $128$. The constraint needed to enforce these values would be:

$$ \Delta v \cdot (\Delta v - 1) \cdot (\Delta v - 2) \cdot (\Delta v - 4) \cdot (\Delta v - 8) \cdot (\Delta v - 16) \cdot (\Delta v - 32) \cdot (\Delta v - 64) \cdot (\Delta v - 128) = 0 $$

This is still a degree $9$ constraint, but now we can "jump" by up to 128 units between two adjacent values. The logic for filling-in bridge values would become a bit more complicated, but probably not hugely. The extra complexity would be that if say, the $\Delta v$ between two values had to be $57$, we'd need to insert several "bridge" rows - i.e., with deltas $32$, $16$, $8$, and $1$ - but this would still be better than what was proposed in the original post.

@tohrnii @grjte - what do you think?

@tohrnii
Copy link
Contributor

tohrnii commented Jun 16, 2023

Ah, makes sense.

@bobbinth bobbinth removed the on hold This issue is blocked or we don't want to start it yet label Jun 28, 2023
@bobbinth bobbinth added v0.7 and removed v0.6 labels Jun 30, 2023
@tohrnii
Copy link
Contributor

tohrnii commented Jun 30, 2023

Closed by #949

@tohrnii tohrnii closed this as completed Jun 30, 2023
@bobbinth bobbinth moved this to Done in Miden VM v0.7 Jul 1, 2023
@bobbinth bobbinth removed the v0.7 label Jul 20, 2023
@bobbinth bobbinth added this to the v0.7 milestone Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
air Related to Miden AIR and constraints processor Related to Miden VM processor
Projects
Status: Done
Development

No branches or pull requests

3 participants