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

Patch plonky3 to use Powdr accelerated Poseidon2 #2077

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

lvella
Copy link
Member

@lvella lvella commented Nov 12, 2024

No description provided.

@lvella lvella changed the base branch from main to p3-recursion-leo November 12, 2024 22:59
@leonardoalt
Copy link
Member

we should to extract some stuff from p3-recursion-leo into another PR to get it merged, and also write separate tests for the patched P3

@lvella lvella changed the base branch from p3-recursion-leo to main November 21, 2024 13:28
@lvella lvella marked this pull request as ready for review November 21, 2024 13:28

#[cfg(all(target_os = "zkvm", target_arch = "riscv32"))]
mod powdr_accel_impl;
#[cfg(all(target_os = "zkvm", target_arch = "riscv32"))]
Copy link
Member

Choose a reason for hiding this comment

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

I think we should also add a feature powdr to the crate and these checks, in case we want to run inside powdr but with software impl. Wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

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

I prefer with a powdr feature, but I did the way you told me to do.

Copy link
Member

Choose a reason for hiding this comment

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

maybe we should just use the 3? I mean, the Cargo.toml powdr-riscv-runtime dep needs the target anyway, we could be restrictive here too

Copy link
Member Author

Choose a reason for hiding this comment

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

3 what? 3 conditions in the all?

Copy link
Member

Choose a reason for hiding this comment

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

yea, the current 2 in the PR plus the feature

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't see it would be better than just using the feature.

If compiling to powdr, both with and without the feature would be valid.

But if not, the feature should not be used and the user should get an error if attempted.

Copy link
Member

Choose a reason for hiding this comment

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

Exactly. I'm fine with only using the feature, but then we allow the user to try to compile to native using the feature, which will fail ofc but will be ugly. If we use the target as well the user actively needs to be using powdr to go that path

Copy link
Member Author

Choose a reason for hiding this comment

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

Imagine the user builds for x86-64 and sets the feature. What do you want to happen?

I want a compilation error, and that is what will happen if we only the use the feature.

If we use the 3 conditions, the path is not taken and the feature is silently ignored.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, this is not possible unless we accept to break --all-features, which I think we don't. The fact that the feature could not be enabled at x86-64 broke our CI, because we build powdr with --all-features. I changed for the feature to be silently ignored.

plonky3/Cargo.toml Show resolved Hide resolved
@lvella
Copy link
Member Author

lvella commented Nov 21, 2024

Something between p2-recursion-leo and main broke this build.

@lvella lvella marked this pull request as draft November 21, 2024 20:21
@lvella
Copy link
Member Author

lvella commented Nov 21, 2024

Ah, it is the powdr-executor-utils split. Maybe it is best to not merge this into main, because the changes don't even compile.

@lvella lvella marked this pull request as ready for review November 22, 2024 14:24
@leonardoalt
Copy link
Member

lint fails

@@ -22,6 +22,8 @@ nightly-features = [
"p3-mersenne-31/nightly-features",
"p3-poseidon2/nightly-features",
]
# As a guest in powdr, use accelerated machines.
powdr-accel = []
Copy link
Member

Choose a reason for hiding this comment

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

powdr-accel sounds a bit weird, why not just powdr?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because the thing is accelerated with powdr.

I think a feature named just powdr in a library of the powdr project, in a repo named powdr, is confusing.

If not powdr-accel, maybe guest-in-powdr or something like it?

Copy link
Member

Choose a reason for hiding this comment

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

ok, then powdr-accel it is

@@ -67,3 +69,12 @@ serde = { version = "1.0", default-features = false, features = [
"alloc",
] }

[target.'cfg(all(target_os = "zkvm", target_arch = "riscv32"))'.dependencies]
powdr-riscv-runtime = { path = "../riscv-runtime", features = [
Copy link
Member

Choose a reason for hiding this comment

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

it would be good if these were also optional and a dependency of the feature

Copy link
Member Author

Choose a reason for hiding this comment

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

Then the feature would be required to build for powdr target.

This way, the feature is just about the accelerated operations, and the target itself "just works".

Copy link
Member

Choose a reason for hiding this comment

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

ah yea true, this is still imported by the guest's main or something closer to it which will have the import itself

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