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

Add PhantomBusInteraction #2183

Merged
merged 11 commits into from
Dec 6, 2024
Merged

Add PhantomBusInteraction #2183

merged 11 commits into from
Dec 6, 2024

Conversation

georgwiese
Copy link
Collaborator

@georgwiese georgwiese commented Dec 2, 2024

This PR adds a Constr:: PhantomBusInteraction variant. For now, it is ignored - if users want to use a bus, they need to express this in terms of phantom lookups / permutations as before this PR.

I added a few TODO(bus_interaction) and opened #2184 to track support for phantom bus interactions.

One use-case this could have before though is to trigger a "hand-written" witness generation for the bus, as discussed in the chat.

pilopt/src/lib.rs Outdated Show resolved Hide resolved
pilopt/src/lib.rs Outdated Show resolved Hide resolved
@georgwiese georgwiese marked this pull request as ready for review December 2, 2024 15:12
@georgwiese
Copy link
Collaborator Author

The following test seems to fail. Witgen ends in an infinite loop after the loop is detected in the main machine:

export TEST=sum
cargo run -r --features plonky3 --bin powdr-rs compile riscv/tests/riscv_data/$TEST -o output --max-degree-log 15 --field gl
cargo run -r --features plonky3 pil output/$TEST.asm -o output -f --field gl --prove-with mock --linker-mode bus -i 1,1,1

Looks like removing the bus interaction fixes it. Gotta debug tomorrow.

@georgwiese
Copy link
Collaborator Author

The commit above fixes the bug.

@@ -313,6 +315,7 @@ impl<'a, T: FieldElement> MachineExtractor<'a, T> {
}
Identity::Polynomial(i) => self.fixed.polynomial_references(i),
Identity::Connect(i) => self.fixed.polynomial_references(i),
Identity::PhantomBusInteraction(i) => self.fixed.polynomial_references(&i.tuple),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just double checking we only need to visit the tuple?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right, I should add the multiplicity! I thought it was handled elsewhere, but it is also added when processing lookups. Good catch!

@Schaeff Schaeff enabled auto-merge December 6, 2024 17:21
@Schaeff Schaeff added this pull request to the merge queue Dec 6, 2024
Merged via the queue into main with commit 3b45173 Dec 6, 2024
14 checks passed
@Schaeff Schaeff deleted the phantom-bus-interaction branch December 6, 2024 17:53
github-merge-queue bot pushed a commit that referenced this pull request Dec 9, 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.
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.

2 participants