Skip to content

chore: delete IsFoldingFlavor concept#15427

Merged
iakovenkos merged 22 commits into
nextfrom
si/remove-is-folding-flavor
Jul 8, 2025
Merged

chore: delete IsFoldingFlavor concept#15427
iakovenkos merged 22 commits into
nextfrom
si/remove-is-folding-flavor

Conversation

@iakovenkos

@iakovenkos iakovenkos commented Jul 1, 2025

Copy link
Copy Markdown
Contributor

@iakovenkos iakovenkos self-assigned this Jul 1, 2025
// These concepts are relevant for Sumcheck, where the logic is different for BN254 and Grumpkin Flavors
// These concept is relevant for the Sumcheck Prover, where the logic is different for BN254 and Grumpkin Flavors
template <typename T> concept IsGrumpkinFlavor = IsAnyOf<T, ECCVMFlavor, ECCVMRecursiveFlavor_<UltraCircuitBuilder>>;
template <typename T> concept IsECCVMRecursiveFlavor = IsAnyOf<T, ECCVMRecursiveFlavor_<UltraCircuitBuilder>>;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

unused

template <typename T> concept IsECCVMRecursiveFlavor = IsAnyOf<T, ECCVMRecursiveFlavor_<UltraCircuitBuilder>>;

#ifdef STARKNET_GARAGA_FLAVORS
template <typename T> concept IsFoldingFlavor = IsAnyOf<T, UltraFlavor,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not needed anymore

const size_t polynomial_size = polynomials.get_polynomial_size();
Polynomial<FF> aggregated_relation_evaluations(polynomial_size);

const std::array<FF, NUM_SUBRELATIONS> alphas = [&alphas_]() {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

don't need to prepend 1 to the array of challenges, as it's done in Oink

static void scale_univariates(auto& tuple, const RelationSeparator& subrelation_separators)
{
size_t idx = 0;
std::array<FF, NUM_SUBRELATIONS> tmp{ current_scalar };

@iakovenkos iakovenkos Jul 3, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

cleaner this way + nano optimization: Prover avoids copying and re-computing the powers of alpha in every round of Sumcheck

static void scale_and_batch_elements(auto& tuple, const RelationSeparator& challenges, FF& result)
{
size_t idx = 0;
std::array<FF, NUM_SUBRELATIONS> tmp{ current_scalar };

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

same as above

class TranslatorVerifier {
public:
using Flavor = TranslatorFlavor;
using FF = typename Flavor::FF;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

TranslatorVerifier is not templated on Flavor

@iakovenkos iakovenkos requested a review from ledwards2225 July 3, 2025 22:53
* @param result Batched result
*/
static void scale_and_batch_elements(auto& tuple, const RelationSeparator& challenge, FF current_scalar, FF& result)
requires(!bb::IsFoldingFlavor<Flavor>)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@DanielKotov I removed this method

@iakovenkos iakovenkos marked this pull request as ready for review July 4, 2025 14:06
@@ -191,7 +201,6 @@ template <typename Flavor, const size_t virtual_log_n = CONST_PROOF_SIZE_LOG_N>
*/
SumcheckOutput<Flavor> prove(ProverPolynomials& full_polynomials,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think all arguments for prove and verify methods can be moved to the constructots, cause currently it looks somewhat random

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

agreed, I think its always been a bit arbitrary

@ledwards2225 ledwards2225 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LG! Nince cleanup. Just some minor comments

avm2::AvmRecursiveFlavor_<MegaCircuitBuilder>>;

// These concepts are relevant for Sumcheck, where the logic is different for BN254 and Grumpkin Flavors
// These concept is relevant for the Sumcheck Prover, where the logic is different for BN254 and Grumpkin Flavors

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// These concept is relevant for the Sumcheck Prover, where the logic is different for BN254 and Grumpkin Flavors
// This concept is relevant for the Sumcheck Prover, where the logic differs between BN254 and Grumpkin

Comment thread barretenberg/cpp/src/barretenberg/flavor/mega_flavor.hpp Outdated
*/
static void scale_univariates(auto& tuple, const RelationSeparator& challenges, FF& current_scalar)
requires bb::IsFoldingFlavor<Flavor>
static void scale_univariates(auto& tuple, const RelationSeparator& subrelation_separators)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah, I see you've come to the same naming :)

Comment thread barretenberg/cpp/src/barretenberg/sumcheck/partial_evaluation.test.cpp Outdated
Comment thread barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp Outdated
@@ -191,7 +201,6 @@ template <typename Flavor, const size_t virtual_log_n = CONST_PROOF_SIZE_LOG_N>
*/
SumcheckOutput<Flavor> prove(ProverPolynomials& full_polynomials,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

agreed, I think its always been a bit arbitrary

# - Upload the compressed results: aws s3 cp bb-civc-inputs.tar.gz s3://aztec-ci-artifacts/protocol/bb-civc-inputs-[hash(0:8)].tar.gz
# Note: In case of the "Test suite failed to run ... Unexpected token 'with' " error, need to run: docker pull aztecprotocol/build:3.0
pinned_civc_inputs_url="https://aztec-ci-artifacts.s3.us-east-2.amazonaws.com/protocol/bb-civc-inputs-95b3f0bb.tar.gz"
pinned_civc_inputs_url="https://aztec-ci-artifacts.s3.us-east-2.amazonaws.com/protocol/bb-civc-inputs-9a32575f.tar.gz"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I didnt catch why this is changing VKs?

@iakovenkos iakovenkos requested a review from just-mitch as a code owner July 7, 2025 12:03
@iakovenkos iakovenkos changed the base branch from merge-train/barretenberg to next July 7, 2025 12:34
public_inputs.emplace_back(FF::from_witness(builder, native_public_input));
}
for (size_t alpha_idx = 0; alpha_idx < alphas.size(); alpha_idx++) {
for (size_t alpha_idx = 1; alpha_idx < alphas.size(); alpha_idx++) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@ledwards2225 this was breaking the vk pinning test, turned the first element into a circuit constant - the test is fixed

@iakovenkos iakovenkos added this pull request to the merge queue Jul 7, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 7, 2025
[&]<size_t relation_idx, size_t subrelation_idx, typename Element>(Element& element) {
using Relation = typename std::tuple_element_t<relation_idx, Relations>;
const Element contribution = element * challenges[idx];
if (subrelation_is_linearly_independent<Relation, subrelation_idx>()) {

@iakovenkos iakovenkos Jul 7, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

missing constexpr - subrelation_is_linearly_independent is known at compile time, no need for runtime branching

// avoid Montgomery allocating 0 and doing a mul. This is about 60ns per row.
FF linearly_independent_contribution{ 0 };
// Initialize result with the contribution from the first subrelation
FF linearly_independent_contribution = std::get<0>(evals)[0];

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Initially I wanted to turn SubrelationSeparators into an array of size of NUM_SUBRELATIONS with the first entry = 1, but it made vk hashing inconsistent - so I removed the first entry of this array completely. Previously we were creating a bunch of temporary arrays of NUM_SUBRELATIONS size just to prepend 1 to the challenges.

As a nice side effect - closed another issue

@iakovenkos iakovenkos added this pull request to the merge queue Jul 8, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 8, 2025
@iakovenkos iakovenkos added the ci-full Run all master checks. label Jul 8, 2025
@iakovenkos iakovenkos added this pull request to the merge queue Jul 8, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 8, 2025
@iakovenkos iakovenkos added this pull request to the merge queue Jul 8, 2025
Merged via the queue into next with commit fad593a Jul 8, 2025
4 checks passed
@iakovenkos iakovenkos deleted the si/remove-is-folding-flavor branch July 8, 2025 21:18
iakovenkos added a commit that referenced this pull request Jul 9, 2025
conflict resolution cause my PR #15427 stopped the train

---------

Co-authored-by: Jean M <132435771+jeanmon@users.noreply.github.com>
Co-authored-by: Alex Gherghisan <alexghr@users.noreply.github.com>
Co-authored-by: Santiago Palladino <spalladino@users.noreply.github.com>
Co-authored-by: Santiago Palladino <santiago@aztec-labs.com>
iakovenkos added a commit that referenced this pull request Jul 15, 2025
In my [previous
PR](#15427), I moved
the `GateSeparatorPolynomial` into the SumcheckProver class as a member,
which extended its lifetime and increased memory usage in CIVC by the
size of this polynomial, e.g. by 21 MB in
`ecdsar1+transfer_0_recursions+sponsored_fpc` bench
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-full Run all master checks.

Projects

None yet

3 participants