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

feat(example): cli #275

Merged
merged 1 commit into from
May 28, 2024
Merged

feat(example): cli #275

merged 1 commit into from
May 28, 2024

Conversation

cyphersnake
Copy link
Collaborator

@cyphersnake cyphersnake commented May 24, 2024

Motivation
Now we have a default path for time-profling & mem-profiling, but it is not very convenient to vary the runtime parameters by hand. That's why I put all runtime parameters in a separate cli example. This allows us to do time-profiling & mem-profiling on different parameters directly on the command line
Part of #272

Overview
Fairly simple code that parses parameters with clap and runs circuit. Covers all our examples

Once mem-profiling is in main, I'll add its description to the README along with this example

Usage: cli [OPTIONS] [PRIMARY_CIRCUIT] [SECONDARY_CIRCUIT]

Arguments:
  [PRIMARY_CIRCUIT]    [default: poseidon] [possible values: poseidon, trivial]
  [SECONDARY_CIRCUIT]  [default: trivial] [possible values: poseidon, trivial]

Options:
      --primary-circuit-k-table-size <PRIMARY_CIRCUIT_K_TABLE_SIZE>      [default: 17]
      --primary-commitment-key-size <PRIMARY_COMMITMENT_KEY_SIZE>        [default: 21]
      --primary-repeat-count <PRIMARY_REPEAT_COUNT>                      [default: 1]
      --primary-r-f <PRIMARY_R_F>                                        [default: 10]
      --primary-r-p <PRIMARY_R_P>                                        [default: 10]
      --secondary-circuit-k-table-size <SECONDARY_CIRCUIT_K_TABLE_SIZE>  [default: 17]
      --secondary-commitment-key-size <SECONDARY_COMMITMENT_KEY_SIZE>    [default: 21]
      --secondary-repeat-count <SECONDARY_REPEAT_COUNT>                  [default: 1]
      --secondary-r-f <SECONDARY_R_F>                                    [default: 10]
      --secondary-r-p <SECONDARY_R_P>                                    [default: 10]
      --limb-width <LIMB_WIDTH>                                          [default: 32]
      --limbs-count <LIMBS_COUNT>                                        [default: 10]
      --debug-mode
      --fold-step-count <FOLD_STEP_COUNT>                                [default: 1]
      --json-logs
  -h, --help                                                             Print help
  -V, --version                                                          Print version

**Motivation**
Now we have a default path for time-profling & mem-profiling, but it is
not very convenient to vary the runtime parameters by hand. That's why I
put all runtime parameters in a separate cli example. This allows us to
do time-profiling & mem-profiling on different parameters directly on
the command line

**Overview**
Fairly simple code that parses parameters with clap and runs circuit. Covers all our examples

Once mem-profiling is in main, I'll add its description to the README
along with this example
@cyphersnake cyphersnake requested a review from chaosma May 24, 2024 11:16
@cyphersnake cyphersnake self-assigned this May 24, 2024
Copy link
Collaborator

@chaosma chaosma left a comment

Choose a reason for hiding this comment

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

IIUC, this cli example is to profile one specific combination of parameters (i.e. specify one table size, one commitment key size etc) while the bench folder will profile different combinations of parameters(i.e. specify various table sizes and key sizes combinations)?

bincode = "1.3"
clap = { version = "4.5.4", features = ["derive"] }
criterion = "0.5.1"
halo2_gadgets = { git = "https://github.com/snarkify/halo2", branch = "snarkify/dev", features = ["unstable"] }
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you remind me where is halo2_gadgets 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.

I didn't add it as a dependency now, it's just that the add dependency utility lexicographically sorted out all the crates.

And so it is probably not needed, because only BLOCK_SIZE is imported from it. We should add a cargo-udeps utility to our pipeline to check dependencies for necessity automatically

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah, I saw it is reordered, but I didn't find where it used. Probably just outdated.

@cyphersnake
Copy link
Collaborator Author

cyphersnake commented May 25, 2024

IIUC, this cli example is to profile one specific combination of parameters (i.e. specify one table size, one commitment key size etc) while the bench folder will profile different combinations of parameters(i.e. specify various table sizes and key sizes combinations)?

Memory profiling with dhat works on the whole process, so you have to run one process many times and there is no convenient benchmark option. If it were not for this limitation, we would just do the same as in the benchs folder

@cyphersnake cyphersnake merged commit e9ec84b into main May 28, 2024
1 check passed
@cyphersnake cyphersnake deleted the example-cli branch May 28, 2024 09:09
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