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

Hand-written bus witness generation #2191

Merged
merged 2 commits into from
Dec 9, 2024
Merged

Hand-written bus witness generation #2191

merged 2 commits into from
Dec 9, 2024

Conversation

georgwiese
Copy link
Collaborator

@georgwiese georgwiese commented Dec 3, 2024

Builds on #2194 and #2183.

This PR gives us (relatively) fast witness generation for the bus, by writing custom code instead of relying on the generic solver + prover functions:

$ cargo run -r --features plonky3 --bin powdr-rs compile riscv/tests/riscv_data/keccak-o output --max-degree-log 18 --field gl
$ cargo run -r --features plonky3 pil output/$TEST.asm -o output -f --field gl --prove-with mock --linker-mode bus
...
Running main machine for 262144 rows
[00:00:05 (ETA: 00:00:05)] █████████░░░░░░░░░░░ 48% - 24283 rows/s, 3169k identities/s, 92% progress                                    
Found loop with period 1 starting at row 127900
[00:00:05 (ETA: 00:00:00)] ████████████████████ 100% - 151125 rows/s, 16170k identities/s, 100% progress                                
Witness generation took 5.748081s
Writing output/commits.bin.
Backend setup for mock...
Setup took 0.54769236s
Generating later-stage witnesses took 0.29s
Proof generation took 2.0383847s

On main, second-stage witgen for the main machine alone takes about 5 minutes.

@georgwiese georgwiese mentioned this pull request Dec 3, 2024
@georgwiese georgwiese changed the base branch from main to phantom-bus-interaction December 3, 2024 16:35
@georgwiese georgwiese force-pushed the bus-witgen branch 4 times, most recently from 9f3af11 to c8a7ab6 Compare December 4, 2024 11:30
@georgwiese georgwiese changed the base branch from phantom-bus-interaction to simple-evaluator December 4, 2024 11:31
@georgwiese georgwiese changed the base branch from simple-evaluator to simple-evaluator2 December 4, 2024 21:18
@georgwiese georgwiese force-pushed the bus-witgen branch 2 times, most recently from 61fdd88 to b3a3169 Compare December 5, 2024 20:56
@georgwiese georgwiese changed the title [WIP] Hand-written bus witness generation Hand-written bus witness generation Dec 5, 2024
@georgwiese georgwiese marked this pull request as ready for review December 5, 2024 20:57
Schaeff
Schaeff previously approved these changes Dec 6, 2024
Copy link
Collaborator

@Schaeff Schaeff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@georgwiese georgwiese changed the base branch from simple-evaluator2 to simple-evaluator December 9, 2024 09:59
github-merge-queue bot pushed a commit that referenced this pull request Dec 9, 2024
This PR:
- Renames the current `executor::witgen::ExpressionEvaluator` to
`executor::witgen::evaluators::partial_expression_evaluator::PartialExpressionEvaluator`
- It is used when solving and evaluates to a
`AffineResult<AlgebraicVariable<'a>, T>`, which might still contain
unknown variables.
- Adds a new `ExpressionEvaluator` that simply evaluates to `T`
- Changes `MockBackend` to use the new `ExpressionEvaluator` (previously
wrapped what is now called the `PartialExpressionEvaluator`)

As a result, the code in `MockBackend` can be simplified. Also, I'm
building on this in #2191 for fast witness generation for the bus.
Base automatically changed from simple-evaluator to main December 9, 2024 12:06
@leonardoalt leonardoalt dismissed Schaeff’s stale review December 9, 2024 12:06

The base branch was changed.

@leonardoalt
Copy link
Member

has conflicts now

@georgwiese
Copy link
Collaborator Author

rebased

Copy link
Member

@leonardoalt leonardoalt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving because @Schaeff had already approved before the rebase

@leonardoalt leonardoalt added this pull request to the merge queue Dec 9, 2024
Merged via the queue into main with commit dbc53c7 Dec 9, 2024
14 checks passed
@leonardoalt leonardoalt deleted the bus-witgen branch December 9, 2024 14:08
github-merge-queue bot pushed a commit that referenced this pull request Dec 9, 2024
This PR:
- Removes the `acc_next` columns, which were only needed because of a
limitation of prover functions. The prover function that existed is now
removed entirely, because we use the hand written witgen anyway, see
#2191.
- Also this PR materializes the folded tuple. This lowers the degree of
the constraints if the tuples being sent have a degree > 1. It also
enables next references in the tuple being sent.

As a result, we can now generate Plonky3 proofs with a bus!

```bash
cargo run -r --features plonky3 --bin powdr-rs compile riscv/tests/riscv_data/keccak -o output --max-degree-log 18 --field gl
cargo run -r --features plonky3 pil output/keccak.asm -o output -f --field gl --prove-with plonky3 --linker-mode bus
```

The proof generation takes 8.32s (of which 394ms are spent on generating
the second-stage witness). This compares to 2.07s proof time without a
bus.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants