-
Notifications
You must be signed in to change notification settings - Fork 133
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
improve: apply tachyon optimizations(1) #342
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #342 +/- ##
==========================================
- Coverage 81.90% 81.89% -0.01%
==========================================
Files 82 82
Lines 17017 17019 +2
==========================================
Hits 13937 13937
- Misses 3080 3082 +2 ☔ View full report in Codecov by Sentry. |
@@ -447,12 +454,13 @@ impl<C: CurveAffine> Evaluator<C> { | |||
// - z_i(X) \prod_j (p(X) + \delta^j \beta X + \gamma) | |||
// ) | |||
let mut current_delta = delta_start * beta_term; | |||
for ((set, columns), cosets) in sets | |||
for (((set_idx, _), columns), cosets) in sets |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about iterating over permutation_product_cosets
so that we don't need to manually index at each iteration? Something like this:
let mut current_delta = delta_start * beta_term;
for ((permutation_product_coset, columns), cosets) in permutation_product_cosets
.iter()
.zip(p.columns.chunks(chunk_len))
.zip(pk.permutation.cosets.chunks(chunk_len))
{
let mut left = permutation_product_coset[r_next];
I think the code looks slightly more clear this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job!
Left a comment/question about a couple of permutation related structs that may be now obsolete.
@@ -25,7 +25,6 @@ use halo2_middleware::poly::Rotation; | |||
|
|||
pub(crate) struct CommittedSet<C: CurveAffine> { | |||
pub(crate) permutation_product_poly: Polynomial<C::Scalar, Coeff>, | |||
pub(crate) permutation_product_coset: Polynomial<C::Scalar, ExtendedLagrangeCoeff>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After removing this, how is CommittedSet
different from ConstructedSet
?
This part of the code is quite poorly documented so it's a bit hard to follow the function of each struct...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function construct()
for Committed
may be simplified now to a simple clone()
(not sure, some types may need to be fixed).
In fact, after this change I think we should re-evaluate the need of Commited
and Constructed
, as these may be redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree with you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this update? 4628c24
I am sure that we don't need Constructed
struct any more.
It also removes unnecessary conversion, which needs .clone()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The optimization looks good!
I still don't understand 100% the logic and purpose behind all the structs surrounding the permutation. I'll try to understand and document that part of the code so it is more understandable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some nitpicks, I do not see any wrong here.
I also tried to check with #345 and it's ok.
Thanks for porting it!
pub(crate) struct Evaluated<C: CurveAffine> { | ||
constructed: Constructed<C>, | ||
constructed: Committed<C>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constructed: Committed<C>, | |
commited: Committed<C>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for suggestion!
Here, I believe it is better to use constructed
.
One reason is that it is also the constructed
in lookup::prover::Evaluated
& shuffle::prover::Evaluated
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
* Remove book and halo2. Move everything to parent repo. * Remove Shuffle * Remove IPA * Remove SHPLONK * Remove compressed selectors * Temporarily remove examples and benches * Working version of new polynomial commitment scheme interface. * Plonk working parametrised only by F and PCS. * Bring examples and benches back * Update to halo2curves 0.7.0 * Apply tachyon optimizations privacy-scaling-explorations#342 * Cost model update * * Implement PartialEq, Eq, Hash for Cell and AssignedCell * Add table, compressed and normal rows count. * Add rows and table rows to cost model. * Ignore unassigned cells if they are multiplied by zero * Some format values are written as "Scalar(0x..)" The hotfix was to change the stripping rules, but this is probably an incorrect implementation of certain traits for one of the curves. * Review comments * Just moving things around! Used the same style as we have in midnight-circuits. Modules are defined with a `mod.rs` file inside the folder, instead of with a file at root level with the same name. I've also created a module for utils and one for the transcript. * Remove issue template * Review comments * Bring back using the SerdeFormat for keys * Address review comments * Leftover docs
Description
Analyze and apply the tachyon optimizations - 1(Lazy IFFT)
Related issues
Changes
permutation_product_coset
from(permutation::)Committed
(permutation::)Constructed
& useCommitted
directly