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

Poseidon with logup #712

Merged
merged 1 commit into from
Jul 30, 2024
Merged

Conversation

spapinistarkware
Copy link
Contributor

@spapinistarkware spapinistarkware commented Jul 8, 2024

This change is Reviewable

@codecov-commenter
Copy link

codecov-commenter commented Jul 8, 2024

Codecov Report

Attention: Patch coverage is 98.59155% with 1 line in your changes missing coverage. Please review.

Project coverage is 93.25%. Comparing base (68ec132) to head (2150ceb).

Files Patch % Lines
crates/prover/src/constraint_framework/logup.rs 98.59% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #712      +/-   ##
==========================================
+ Coverage   92.80%   93.25%   +0.45%     
==========================================
  Files          89       89              
  Lines       11725    11795      +70     
  Branches    11725    11795      +70     
==========================================
+ Hits        10881    11000     +119     
+ Misses        744      694      -50     
- Partials      100      101       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@spapinistarkware spapinistarkware force-pushed the spapini/07-08-logup_trace_generation branch from 68f340e to 764aadd Compare July 8, 2024 11:46
@spapinistarkware spapinistarkware force-pushed the spapini/07-08-poseidon_with_logup branch from 1ad23f7 to 26d7f53 Compare July 8, 2024 11:47
@spapinistarkware spapinistarkware force-pushed the spapini/07-08-logup_trace_generation branch from 764aadd to 56e7a66 Compare July 8, 2024 11:52
@spapinistarkware spapinistarkware force-pushed the spapini/07-08-poseidon_with_logup branch from 26d7f53 to cac4ec9 Compare July 8, 2024 11:52
@spapinistarkware spapinistarkware force-pushed the spapini/07-08-logup_trace_generation branch from 56e7a66 to f7c8f7a Compare July 9, 2024 05:51
@spapinistarkware spapinistarkware force-pushed the spapini/07-08-poseidon_with_logup branch from cac4ec9 to c1084d8 Compare July 9, 2024 05:51
@spapinistarkware spapinistarkware force-pushed the spapini/07-08-logup_trace_generation branch from f7c8f7a to 37b50ef Compare July 10, 2024 06:39
@spapinistarkware spapinistarkware force-pushed the spapini/07-08-poseidon_with_logup branch from c1084d8 to 112979a Compare July 10, 2024 06:39
@spapinistarkware spapinistarkware force-pushed the spapini/07-08-logup_trace_generation branch from 37b50ef to 02fa82a Compare July 14, 2024 12:30
@spapinistarkware spapinistarkware force-pushed the spapini/07-08-poseidon_with_logup branch from 112979a to 0dd7c6d Compare July 14, 2024 12:30
@spapinistarkware spapinistarkware force-pushed the spapini/07-08-logup_trace_generation branch from 02fa82a to 3b5d1cd Compare July 15, 2024 08:50
@spapinistarkware spapinistarkware force-pushed the spapini/07-08-poseidon_with_logup branch from 0dd7c6d to a812a8f Compare July 15, 2024 08:50
@spapinistarkware spapinistarkware force-pushed the spapini/07-08-logup_trace_generation branch 2 times, most recently from 5506349 to cd56fad Compare July 17, 2024 10:01
@spapinistarkware spapinistarkware force-pushed the spapini/07-08-poseidon_with_logup branch from a812a8f to 9bae9fa Compare July 17, 2024 10:01
@spapinistarkware spapinistarkware force-pushed the spapini/07-08-logup_trace_generation branch from e62fdb8 to 5e4f90b Compare July 28, 2024 07:28
@spapinistarkware spapinistarkware force-pushed the spapini/07-08-poseidon_with_logup branch from 9bae9fa to b40bca7 Compare July 28, 2024 07:28
@spapinistarkware spapinistarkware force-pushed the spapini/07-08-logup_trace_generation branch from 5e4f90b to 613e32c Compare July 28, 2024 12:18
@spapinistarkware spapinistarkware force-pushed the spapini/07-08-poseidon_with_logup branch from b40bca7 to 247a5f1 Compare July 28, 2024 12:18
@spapinistarkware spapinistarkware mentioned this pull request Jul 28, 2024
@spapinistarkware spapinistarkware force-pushed the spapini/07-08-logup_trace_generation branch from 613e32c to e21b020 Compare July 28, 2024 12:25
@spapinistarkware spapinistarkware force-pushed the spapini/07-08-poseidon_with_logup branch from 247a5f1 to 05ef795 Compare July 28, 2024 12:47
@spapinistarkware spapinistarkware force-pushed the spapini/07-08-logup_trace_generation branch from e21b020 to 216cbf5 Compare July 28, 2024 12:49
@spapinistarkware spapinistarkware force-pushed the spapini/07-08-poseidon_with_logup branch from 05ef795 to 9ae92ce Compare July 28, 2024 12:49
Copy link
Contributor

@alonh5 alonh5 left a comment

Choose a reason for hiding this comment

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

Reviewed 4 of 4 files at r4.
Reviewable status: 2 of 4 files reviewed, 9 unresolved discussions (waiting on @spapinistarkware)


crates/prover/src/constraint_framework/logup.rs line 30 at r4 (raw file):

    pub prev_mask: E::EF,
    pub is_first: E::F,
}

Please document. Specifically what is queue and BATCH_SIZE.

Code quote:

pub struct LogupAtRow<const BATCH_SIZE: usize, E: EvalAtRow> {
    pub interaction: usize,
    pub queue: [(E::EF, E::EF); BATCH_SIZE],
    pub queue_size: usize,
    pub claimed_sum: SecureField,
    pub prev_mask: E::EF,
    pub is_first: E::F,
}

crates/prover/src/constraint_framework/logup.rs line 52 at r4 (raw file):

            values,
            E::EF::zero() + lookup_elements.alpha,
            E::EF::zero() + lookup_elements.z,

Add From<SecureField> to EF?

Suggestion:

            lookup_elements.alpha.into(),
            lookup_elements.z.into(),

crates/prover/src/constraint_framework/logup.rs line 57 at r4 (raw file):

    }

    pub fn push_frac(&mut self, eval: &mut E, p: E::EF, q: E::EF) {

Suggestion:

pub fn push_frac(&mut self, eval: &mut E, numerator: E::EF, denom: E::EF) {

crates/prover/src/constraint_framework/logup.rs line 96 at r4 (raw file):

            std::array::from_fn(|_| eval.next_interaction_mask(self.interaction, [0, -1]));
        let cur = E::combine_ef(cumulative_mask_values.map(|[cur, _prev]| cur));
        let up = E::combine_ef(cumulative_mask_values.map(|[_cur, prev]| prev));

Suggestion:

        let cur = E::combine_ef(cumulative_mask_values.map(|[cur, _up]| cur));
        let up = E::combine_ef(cumulative_mask_values.map(|[_cur, up]| up));

crates/prover/src/examples/poseidon/mod.rs line 118 at r4 (raw file):

        logup: LogupAtRow::new(1, SecureField::zero(), BaseField::zero()),
    };
    counter.eval.next_interaction_mask(2, [0]);

Doesn't one of the columns have an offset -1 also? How does this work?

Code quote:

counter.eval.next_interaction_mask(2, [0]);

crates/prover/src/examples/poseidon/mod.rs line 131 at r4 (raw file):

    }

    fn trace_log_degree_bounds(&self) -> TreeVec<ColumnVec<u32>> {

Can you move these two implementations below to InfoEvaluator?


crates/prover/src/examples/poseidon/mod.rs line 255 at r4 (raw file):

struct PoseidonEval<E: EvalAtRow> {
    eval: E,
    logup: LogupAtRow<2, E>,

Does LogupAtRow have to be separate from EvalAtRow? Can it be internal?

Code quote:

LogupAtRow

crates/prover/src/examples/poseidon/mod.rs line 308 at r4 (raw file):

            // Provide state lookup.
            self.logup
                .push_lookup(&mut self.eval, -E::EF::one(), &state, self.lookup_elements);

Why is this -1 while the initial state's numerator is 1? Wouldn't the -1 be in the callers column?

Code quote:

-E::EF::one()

crates/prover/src/examples/poseidon/mod.rs line 362 at r4 (raw file):

                .iter_mut()
                .zip(state)
                .for_each(|(res, si)| res.data[vec_index] = si);

Accident?

Code quote:

si

Copy link
Contributor

@alonh5 alonh5 left a comment

Choose a reason for hiding this comment

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

Reviewable status: 2 of 4 files reviewed, 9 unresolved discussions (waiting on @spapinistarkware)


crates/prover/src/constraint_framework/logup.rs line 96 at r4 (raw file):

            std::array::from_fn(|_| eval.next_interaction_mask(self.interaction, [0, -1]));
        let cur = E::combine_ef(cumulative_mask_values.map(|[cur, _prev]| cur));
        let up = E::combine_ef(cumulative_mask_values.map(|[_cur, prev]| prev));

Or actually maybe lets use row_prev and col_prev?

@spapinistarkware spapinistarkware force-pushed the spapini/07-08-poseidon_with_logup branch from 9ae92ce to 86eb8cb Compare July 29, 2024 13:42
@spapinistarkware spapinistarkware changed the base branch from spapini/07-08-logup_trace_generation to dev July 29, 2024 13:42
Copy link
Contributor Author

@spapinistarkware spapinistarkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 of 7 files reviewed, 7 unresolved discussions (waiting on @alonh5)


crates/prover/src/constraint_framework/logup.rs line 30 at r4 (raw file):

Previously, alonh5 (Alon Haramati) wrote…

Please document. Specifically what is queue and BATCH_SIZE.

Done.


crates/prover/src/constraint_framework/logup.rs line 57 at r4 (raw file):

    }

    pub fn push_frac(&mut self, eval: &mut E, p: E::EF, q: E::EF) {

Done.


crates/prover/src/examples/poseidon/mod.rs line 118 at r4 (raw file):

Previously, alonh5 (Alon Haramati) wrote…

Doesn't one of the columns have an offset -1 also? How does this work?

It's is_first


crates/prover/src/examples/poseidon/mod.rs line 131 at r4 (raw file):

Previously, alonh5 (Alon Haramati) wrote…

Can you move these two implementations below to InfoEvaluator?

I don't understand. Also, note that in 2 PRs, these will be auto implemented for any framework component.


crates/prover/src/examples/poseidon/mod.rs line 255 at r4 (raw file):

Previously, alonh5 (Alon Haramati) wrote…

Does LogupAtRow have to be separate from EvalAtRow? Can it be internal?

2 different things. EvalAtRow is a trait that we imoplemented with either point, domain, info or assert ops. LogupAtRow is a specific struct that does the constraints of logup. It also is generic over EvalAtRow, like the component constriants.


crates/prover/src/examples/poseidon/mod.rs line 308 at r4 (raw file):

Previously, alonh5 (Alon Haramati) wrote…

Why is this -1 while the initial state's numerator is 1? Wouldn't the -1 be in the callers column?

I decided to reverse this, since the callers will be called a lot more times than the callees (which have multiplicity). So, I thought it makes sense to not have negations in the common case. Also, the multiplicity could incorporate the negatives themeselves, so in most cases, no negations at all.


crates/prover/src/examples/poseidon/mod.rs line 362 at r4 (raw file):

Previously, alonh5 (Alon Haramati) wrote…

Accident?

I wanted to distinguish this from state, since it's just a single elements of the state (state_i)

@spapinistarkware spapinistarkware mentioned this pull request Jul 29, 2024
@spapinistarkware spapinistarkware force-pushed the spapini/07-08-poseidon_with_logup branch from 86eb8cb to 051d90a Compare July 30, 2024 11:11
Copy link
Contributor

@alonh5 alonh5 left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 6 files at r6, 3 of 3 files at r7, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @spapinistarkware)


crates/prover/src/constraint_framework/logup.rs line 75 at r7 (raw file):

        }

        // Compute sum_i pi/qi over batch, as a fraction, p/q.

Fix to match name change.

Code quote:

// Compute sum_i pi/qi over batch, as a fraction, p/q.

crates/prover/src/constraint_framework/logup.rs line 87 at r7 (raw file):

        self.queue_size = 1;

        // Add a constraint that p / q = diff.

Here also.

Code quote:

// Add a constraint that p / q = diff.

crates/prover/src/constraint_framework/logup.rs line 89 at r7 (raw file):

        // Add a constraint that p / q = diff.
        let cur_cumsum = E::combine_ef(std::array::from_fn(|_| {
            eval.next_interaction_mask(1, [0])[0]

Suggestion:

self.interaction

crates/prover/src/constraint_framework/logup.rs line 107 at r7 (raw file):

            std::array::from_fn(|_| eval.next_interaction_mask(self.interaction, [0, -1]));
        let cur_cumsum = E::combine_ef(cumsum_mask.map(|[cur_row, _prev_row]| cur_row));
        let prev_row_cumsum = E::combine_ef(cumsum_mask.map(|[_cur_row, prev_row]| prev_row));

I thought row_prev could refer to the previous value in the row (left) and col_prev to the previous value in the column (up).
Alternatively you can say prev_row is the previous row value (up) and prev_col the previous columns value (left).
Now it's a mix of both and is more confusing IMO.

Code quote:

        let cur_cumsum = E::combine_ef(cumsum_mask.map(|[cur_row, _prev_row]| cur_row));
        let prev_row_cumsum = E::combine_ef(cumsum_mask.map(|[_cur_row, prev_row]| prev_row));

crates/prover/src/examples/poseidon/mod.rs line 362 at r4 (raw file):

Previously, spapinistarkware (Shahar Papini) wrote…

I wanted to distinguish this from state, since it's just a single elements of the state (state_i)

So how about state_i?

Copy link
Contributor

@alonh5 alonh5 left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @spapinistarkware)

@spapinistarkware spapinistarkware force-pushed the spapini/07-08-poseidon_with_logup branch from 051d90a to 19c7760 Compare July 30, 2024 12:55
Copy link
Contributor

@alonh5 alonh5 left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r8, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @spapinistarkware)


crates/prover/src/constraint_framework/logup.rs line 87 at r8 (raw file):

        self.queue_size = 1;

        // Add a constraint that p / q = diff.

Suggestion:

num / denom = diff

@spapinistarkware spapinistarkware force-pushed the spapini/07-08-poseidon_with_logup branch from 19c7760 to 2150ceb Compare July 30, 2024 12:59
Copy link
Contributor

@alonh5 alonh5 left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r9, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @spapinistarkware)

Copy link
Contributor Author

spapinistarkware commented Jul 30, 2024

Merge activity

@spapinistarkware spapinistarkware merged commit b06f87e into dev Jul 30, 2024
14 checks passed
This was referenced Jul 30, 2024
@spapinistarkware spapinistarkware mentioned this pull request Aug 7, 2024
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