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

Adding telescope benchmarks #55

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

Adding telescope benchmarks #55

wants to merge 12 commits into from

Conversation

rrtoledo
Copy link
Collaborator

@rrtoledo rrtoledo commented Nov 6, 2024

Content

Relates to #54

Depends on #105

@rrtoledo rrtoledo added the enhancement New feature or request label Nov 6, 2024
@rrtoledo rrtoledo self-assigned this Nov 6, 2024
@rrtoledo rrtoledo marked this pull request as draft November 6, 2024 13:13
@rrtoledo rrtoledo linked an issue Nov 6, 2024 that may be closed by this pull request
@rrtoledo rrtoledo force-pushed the raph@bench-centralized branch 2 times, most recently from de0fb2a to 88d69ab Compare November 11, 2024 12:47
@rrtoledo rrtoledo marked this pull request as ready for review November 11, 2024 13:22
@rrtoledo
Copy link
Collaborator Author

@tolikzinovyev @curiecrypt @djetchev

Should we remove the benchmarks checking the variance of the number of repetitions (the dfs_bound is so high that we never repeat, which makes criterion fails when generating the plot), or should we lower dfs_bound to observe some variances in retry_counter?
-> Do we want the retry_counter to increase?

Some local tests showed me that we would need to reduce dfs_bound by a factor 100. Choosing this number would feel a bit arbitrary (Is this the right number for all lambdas...?) so I am not sure it is the best option.

@tolikzinovyev
Copy link
Member

@tolikzinovyev @curiecrypt @djetchev

Should we remove the benchmarks checking the variance of the number of repetitions (the dfs_bound is so high that we never repeat, which makes criterion fails when generating the plot), or should we lower dfs_bound to observe some variances in retry_counter? -> Do we want the retry_counter to increase?

Some local tests showed me that we would need to reduce dfs_bound by a factor 100. Choosing this number would feel a bit arbitrary (Is this the right number for all lambdas...?) so I am not sure it is the best option.

Removing the benchmark sounds reasonable!

@rrtoledo
Copy link
Collaborator Author

I find @tolikzinovyev idea the best. What do you think @curiecrypt @djetchev ?

@tolikzinovyev
Copy link
Member

I will not have time to review this PR before Monday, unfortunately, since it is a pretty large.

Copy link
Member

@tolikzinovyev tolikzinovyev left a comment

Choose a reason for hiding this comment

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

Nice usage of advanced criterion features. Left high-level comments.

benches/centralized_telescope.rs Outdated Show resolved Hide resolved
benches/centralized_telescope.rs Outdated Show resolved Hide resolved
benches/centralized_telescope.rs Outdated Show resolved Hide resolved
benches/centralized_telescope.rs Outdated Show resolved Hide resolved
benches/centralized_telescope.rs Outdated Show resolved Hide resolved
benches/criterion_helpers.rs Outdated Show resolved Hide resolved
src/centralized_telescope/algorithm.rs Outdated Show resolved Hide resolved
src/centralized_telescope/algorithm.rs Outdated Show resolved Hide resolved
benches/centralized_telescope.rs Outdated Show resolved Hide resolved
benches/centralized_telescope.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@curiecrypt curiecrypt left a comment

Choose a reason for hiding this comment

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

I think it seems pretty good and mature. I left a few comments and could go for another round after the conversations are resolved.

Cargo.toml Outdated Show resolved Hide resolved
benches/centralized_telescope.rs Outdated Show resolved Hide resolved
benches/centralized_telescope.rs Outdated Show resolved Hide resolved
benches/centralized_telescope.rs Outdated Show resolved Hide resolved
benches/centralized_telescope.rs Outdated Show resolved Hide resolved
benches/centralized_telescope.rs Outdated Show resolved Hide resolved
benches/centralized_telescope.rs Outdated Show resolved Hide resolved
benches/criterion_helpers.rs Outdated Show resolved Hide resolved
benches/criterion_helpers.rs Outdated Show resolved Hide resolved
src/centralized_telescope/algorithm.rs Outdated Show resolved Hide resolved
@rrtoledo rrtoledo force-pushed the raph@bench-centralized branch from 14f4fb0 to 3fdfe36 Compare December 5, 2024 20:08
@rrtoledo rrtoledo marked this pull request as draft December 5, 2024 20:08
@rrtoledo rrtoledo force-pushed the raph@bench-centralized branch 2 times, most recently from 9f13518 to e27b0d4 Compare December 10, 2024 19:16
@rrtoledo rrtoledo marked this pull request as ready for review December 12, 2024 12:01
@rrtoledo rrtoledo force-pushed the raph@bench-centralized branch 4 times, most recently from b540e25 to a54996e Compare December 12, 2024 16:15
@rrtoledo rrtoledo changed the title Adding benchmarks Centralized Telescope - Adding benchmarks Dec 13, 2024
@rrtoledo rrtoledo force-pushed the raph@bench-centralized branch from 63a4cef to 07fc567 Compare December 13, 2024 11:09
@rrtoledo rrtoledo changed the title Adding telescope & lottery benchmarks Adding telescope benchmarks Dec 13, 2024
@rrtoledo rrtoledo mentioned this pull request Dec 13, 2024
@rrtoledo rrtoledo force-pushed the raph@bench-centralized branch from 350cc03 to f422cdb Compare December 16, 2024 11:06
Copy link
Collaborator

@curiecrypt curiecrypt left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Member

@tolikzinovyev tolikzinovyev left a comment

Choose a reason for hiding this comment

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

The code structure, benchmarks duration and variable names have definitely improved, thank you!

src/centralized_telescope/algorithm.rs Outdated Show resolved Hide resolved
src/centralized_telescope/algorithm.rs Outdated Show resolved Hide resolved
@@ -8,7 +8,8 @@ use crate::utils::types::Element;
/// The main centralized Telescope struct with prove and verify functions.
#[derive(Debug, Clone, Copy)]
pub struct Wrapper {
setup: Setup,
/// Centralized telescope internal parameters
pub setup: Setup,
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 this shouldn't be public. Instead of calling CentralizedTelescope::create(), we can run parameter derivation and use CentralizedTelescope::create_unsafe().

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The problem is accessing setup from the wrapper and not creating an unsafe wrapper from some user parameters.

I removed the pub access and added a getter function in the wrapper

Copy link
Member

Choose a reason for hiding this comment

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

I don't understand. Why not use CentralizedTelescope::create_unsafe() instead of modifying Wrapper? I would prefer to leave the public interface unchanged.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just to be clear, I changed back the setup to private which now is unchanged.

The benches/centralized_telescope/utils.rs file comprises the setup function that calls the setup and returns both the dataset to bench on and a wrapper instance.
This function is used directly, with no changes in benches\...\proving_time.rs, and we call prove on the wrapper.
In the step_bench however, we need to call the bench function. As the function bench is defined in algorithm (outside the wrapper), it takes a setup as input. The setup was already done beforehand, and it seems more natural to extract the setup from the wrapper than compute it another time.

Copy link
Member

Choose a reason for hiding this comment

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

You could return Setup in benches/centralized_telescope/utils.rs setup() instead of CentralizedTelescope?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The getters have already been merged in another PR as @curiecrypt needed them for the examples.
As such, the two ways are equivalent.

benches/centralized_telescope/verifying_time.rs Outdated Show resolved Hide resolved
benches/centralized_telescope/proof_size.rs Show resolved Hide resolved
benches/common/criterion_helpers.rs Outdated Show resolved Hide resolved
benches/common/criterion_helpers.rs Outdated Show resolved Hide resolved
src/centralized_telescope/algorithm.rs Outdated Show resolved Hide resolved
benches/centralized_telescope/number_steps.rs Outdated Show resolved Hide resolved
benches/common/test_vectors.rs Show resolved Hide resolved
curiecrypt
curiecrypt previously approved these changes Jan 9, 2025
Copy link
Collaborator

@curiecrypt curiecrypt left a comment

Choose a reason for hiding this comment

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

It looks quite mature. I just added a few minor comments.
I suggest merging it asap and dealing with the minor issues later.

benches/common/criterion_helpers.rs Outdated Show resolved Hide resolved
benches/common/criterion_helpers.rs Outdated Show resolved Hide resolved
src/centralized_telescope/algorithm.rs Outdated Show resolved Hide resolved
benches/common/criterion_helpers.rs Outdated Show resolved Hide resolved
benches/centralized_telescope/utils.rs Outdated Show resolved Hide resolved
benches/centralized_telescope/number_steps.rs Outdated Show resolved Hide resolved
src/centralized_telescope/algorithm.rs Outdated Show resolved Hide resolved
@rrtoledo rrtoledo force-pushed the raph@bench-centralized branch 2 times, most recently from 55ace81 to 13fcb6c Compare January 21, 2025 15:47
@rrtoledo rrtoledo force-pushed the raph@bench-centralized branch from 13fcb6c to 2c0111d Compare January 21, 2025 15:48
curiecrypt
curiecrypt previously approved these changes Jan 21, 2025
Copy link
Collaborator

@curiecrypt curiecrypt left a comment

Choose a reason for hiding this comment

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

LGTM 👍

/// }
/// let (setps, proof_opt) = Proof::bench(set_size, &params, &prover_set);
/// ```
pub fn bench(set_size: u64, params: &Params, prover_set: &[Element]) -> (u64, Option<Proof>) {
Copy link
Member

Choose a reason for hiding this comment

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

Something happened to the internal module. I think the long documentation above is not necessary since this function is not supposed to be used.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We cannot have internal modules in a impl unfortunately. As the function needs to be accessed, it is public hence I added the doc for public functions.

Copy link
Member

Choose a reason for hiding this comment

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

I see. Then suggest replace the long function doc with "Alba's proving algorithm used for benchmarking, returning a proof if found as well as the number of steps done when generating it. Only for internal usage. Do not use." since it's not meant to be used publicly.

@rrtoledo rrtoledo force-pushed the raph@bench-centralized branch from aa596ec to e4a3b75 Compare January 21, 2025 17:17
@rrtoledo rrtoledo force-pushed the raph@bench-centralized branch from e4a3b75 to f91b110 Compare January 23, 2025 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding centralized benchmarks
4 participants