-
Notifications
You must be signed in to change notification settings - Fork 82
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
RISC-V machine: Use dynamic VADCOP #1683
Conversation
639b21a
to
49ee814
Compare
080adf2
to
e17c57b
Compare
49ee814
to
486facf
Compare
When making fixed lookup machines smaller in the RISC-V VM (#1683), I came across the issue that range-constraint lookups (e.g. `[two_bits] in [TWO_BITS]` where `TWO_BITS = [0, 1, 2, 3]`) where not recognized as such if the fixed column was *just* the right size (in the above example, `TWO_BITS = [0, 1, 2, 3, 0]` would have worked).
197047e
to
a022fa3
Compare
if let Some(external_values) = &external_values { | ||
if external_values.len() != poly.degree.unwrap() as usize { | ||
log::debug!( | ||
"External witness values for column {} were only partially provided \ | ||
(length is {} but the degree is {})", | ||
name, | ||
external_values.len(), | ||
poly.degree.unwrap() | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't really check this easily anymore with dynamic sizes, and it was only a debug log anyway.
@@ -11,7 +11,7 @@ on: | |||
env: | |||
CARGO_TERM_COLOR: always | |||
POWDR_GENERATE_PROOFS: "true" | |||
MAX_DEGREE_LOG: "10" | |||
MAX_DEGREE_LOG: "20" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to increase, because otherwise the RISC-V tests would run only for 256 rows... Now, it is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should also add log 22 tests at some point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After #1667, we can configure the range for each test and machine individually, should be much better than this global setting.
@@ -66,17 +66,17 @@ pub struct VmProcessor<'a, 'b, 'c, T: FieldElement, Q: QueryCallback<T>> { | |||
} | |||
|
|||
impl<'a, 'b, 'c, T: FieldElement, Q: QueryCallback<T>> VmProcessor<'a, 'b, 'c, T, Q> { | |||
#[allow(clippy::too_many_arguments)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aha
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
Pulled out of #1683 Because our memory machine requires a `Byte2` machine to range-check some values, we need to provide that machine in any test that uses memory. But that machine needs a size of $2^{16}$, which is a lot for just some simple tests. Previously, the `Byte2` machine did not have a size set (this will change in #1683), so it would just get the size of the main machine. This works because in our simple tests, the values are small enough in practice. But really, this breaks an assumption of the `Byte2` machine. With this PR, this is explicit, with all the affected test (that we want to keep small) using `std::machines::test_util::FakeByte2` instead of `std::machines::range::Byte2`. Note that this is exploiting the fact that we're not type checking the machine passed to memory. But the alternative would be to copy the memory machine and use that in the test.
has conflicts now |
6fc9231
to
f50c62e
Compare
I rebased onto |
Builds on #1687
Fixed #1572
With this PR, we are using dynamic VADCOP in the RISC-V zk-VM.
There were a few smaller fixes needed to make this work. In summary, the changes are as follows:
None
, and all fixed lookup machines to the appropriate size. As a consequence, the CPU, all block machines & memory have a dynamic size.Memory_<size>
machines 🎉1 << (MAX_DEGREE_LOG - 2)
steps and compute the bootloader inputs accordingly. With this choice, we can guarantee that the register memory (which can be up to 4x larger than the main machine) does not run out of rows.Note that while we do access
MAX_DEGREE_LOG
in a bunch of places now, this will go away once #1667 is merged, which will allow us to configure the degree range in ASM and for each machine individually.Example:
export MAX_LOG_DEGREE=18 cargo run -r --bin powdr-rs compile riscv/tests/riscv_data/many_chunks -o output --continuations cargo run -r --bin powdr-rs execute output/many_chunks.asm -o output --continuations -w cargo run -r --features plonky3,halo2 prove output/many_chunks.asm -d output/chunk_0 --field gl --backend plonky3-composite
This leads to the following output:
Note that
main_bootloader_inputs
is still equal to the maximum size, we should fix that in a following PR!