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

Further enhance LEM's witness generation speed #783

Merged
merged 1 commit into from
Oct 27, 2023

Conversation

arthurpaulino
Copy link
Contributor

This PR is the result of a long iterative process of improvements on LEM's witness generation algorithm.

  • The witnesses for all slots from all frames are now generated in parallel, with cached-on-demand values for slots fed with dummy data;
  • No more parallel chunks of frames to generate the rest of the witness. It's better to just tell rayon to generate the witnesses for all frames in parallel and it can make a better use of the CPUs than if we try to teach it how to do it

💅🏼

  • Renamed Globals to RecursiveContext because it better represents its role

@arthurpaulino arthurpaulino requested a review from a team as a code owner October 23, 2023 18:59
@porcuquine
Copy link
Contributor

Note: it would be easier to review this if many of the changes weren't cosmetic/renaming. If those are important and need to happen here, it would be simpler if the substantial changes were in isolated commits. This is just an informational note about the reviewer experience.

Comment on lines +254 to +260
let preallocated_preimg: Vec<_> = (0..slot_type.preimg_size())
.map(|component_idx| {
AllocatedNum::alloc_infallible(
cs.namespace(|| format!("component {component_idx} slot {slot}")),
|| F::ZERO,
)
})
.collect();
Copy link
Contributor

Choose a reason for hiding this comment

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

Although I don't think it's introduced in this PR, it seems that the handling of preimage values is smudging the bellpepper API. When we are synthesizing shapes without data, we should not be specifying concrete values. Even if we get away with it here, this is sloppy and may end up biting us.

Copy link
Contributor

Choose a reason for hiding this comment

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

My point is not that the above code will always run in a context where no real value exist — only that I think it sometimes will.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe I'm missing the point, but this is not to synthesize the shape without data. It's to synthesize slots that weren't visited during interpretation with dummy data

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, which is what I mentioned in my second comment. But the point is that when synthesizing without data, one of the two branches of this conditional will have to be taken, and they both allocate infallibly, as far as I can tell. Is there some third code path that is used to synthesize when creating a shape? If so, that's also not the standard usage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this is the only code that's used to create the shape. But I think this is getting into territory @gabriel-barrett understands better

Copy link
Contributor

Choose a reason for hiding this comment

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

It has come up elsewhere, and I'm reiterating the point here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you create an issue for it please? I don't think I understand the problem well enough yet.

porcuquine
porcuquine previously approved these changes Oct 27, 2023
@arthurpaulino arthurpaulino added this pull request to the merge queue Oct 27, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 27, 2023
Copy link
Contributor

@huitseeker huitseeker left a comment

Choose a reason for hiding this comment

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

Stamping to unblock.

@arthurpaulino arthurpaulino added this pull request to the merge queue Oct 27, 2023
Merged via the queue into master with commit 22100da Oct 27, 2023
11 of 12 checks passed
@arthurpaulino arthurpaulino deleted the lem-perf-attempt-5 branch October 27, 2023 13:16
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