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: swap polys to facilitate dynamic trace overflow #9976

Merged
merged 36 commits into from
Nov 27, 2024
Merged

Conversation

ledwards2225
Copy link
Contributor

@ledwards2225 ledwards2225 commented Nov 14, 2024

Update PG/ClientIvc so that during accumulation we can handle a circuit that overflows the nominal structured trace (and potentially increases the dyadic size of the accumulator) without knowing about the size of the overflow in advance. (A previous PR makes it possible to overflow arbitrarily as long as ClientIvc is initialized with the proper overflow capacity). Ensure the ExecutionTraceTracker is updated correctly when encountering a circuit that overflows and also ensure that the tracker is used appropriately in Protogalaxy.

@ledwards2225 ledwards2225 self-assigned this Nov 14, 2024
@ledwards2225 ledwards2225 marked this pull request as ready for review November 14, 2024 19:59
@maramihali maramihali self-assigned this Nov 21, 2024
@maramihali maramihali added the crypto cryptography label Nov 21, 2024
// need to determine the dyadic size for this. We call the size function on the current circuit which will have
// the same fixed block sizes but might also have an overflow block potentially influencing the dyadic circuit
// size.
size_t dyadic_circuit_size = circuit.blocks.get_structured_dyadic_size();
Copy link
Contributor

@maramihali maramihali Nov 26, 2024

Choose a reason for hiding this comment

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

This was the major issue: The fixed sizes are set using the trace settings so the overflow block was 0 and hence the dyadic_circuit_size was not computed correctly. This was leading us to not take into account the lookup contributions at the end of the current circuit trace in PG. Modifying the fixed_sizes to include the overflow block is not easily possible in the current design and it makes sense to compute the dyadic_circuit_size using the current circuit. It will have the same TraceSetting (hence the same sizes also contained in the fixed_sizes structure ) but also the correct size of the overflow block. I expect we might be able to get rid of the fixed_sizes structure as a follow up or do something a bit cleaner in a follow up

info("");
}

void print_previous_active_ranges()
Copy link
Contributor

Choose a reason for hiding this comment

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

when i was printing the active ranges it wasn't reflecting everything due to the lookup and databus caveat so I think it made sense to refine the labels


// The commitment key is initialised with the number of points determined by the trace_settings' dyadic size. If a
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the caveat with overflowing circuits and having a single CIVC commitment key, maybe this could be refined in a follow up PR but seemed the easiest solution as it is. In the ideal case when we never overflow we still can benefit from having a single commitment key

} else {
proving_key = std::make_shared<DeciderProvingKey>(circuit, trace_settings);
}
proving_key = std::make_shared<DeciderProvingKey>(circuit, trace_settings);
Copy link
Contributor

Choose a reason for hiding this comment

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

Also: please fuse this into the previous line if we're not conditionally defining (though I don't understand why we did that to begin with...)

Copy link
Contributor

Choose a reason for hiding this comment

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

because at first round of client ivc we were also initializing the tracker but i discovered this could be included in the constructor of civc

TEST_F(ClientIVCTests, DynamicOverflow)
{
// Define trace settings with zero overflow capacity
ClientIVC ivc{ { SMALL_TEST_STRUCTURE, /*overflow_capacity=*/0 } };
Copy link
Contributor

Choose a reason for hiding this comment

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

If small tests structure changes behind the scenes, this test could silently break (i.e., it may continue to pass but cease to test what it's supposed to). Will you please define a new trace structure in this file for use in these two tests only?

@@ -72,8 +72,11 @@ struct ExecutionTraceUsageTracker {
}

// The active ranges must also include the rows where the actual databus and lookup table data are stored.
// (Note: lookup tables are constructed at the end of the trace; databus data is constructed at the start).
size_t dyadic_circuit_size = fixed_sizes.get_structured_dyadic_size();
// (Note: lookup tables are constructed at the end of the trace; databus data is constructed at the start) so we
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment will break if the ordering in the trace structure ever changes--there's little chance that the person changing the structure remembers this comment exists, if they ever knew.

Copy link
Contributor

Choose a reason for hiding this comment

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

a way to make this more robust is to update the active ranges as we are constructing the DeciderProvingKey so if the position of the rows changes it is obvious that the tracker's active ranges also need to be updated, will add an issue.

*/
static void test_fold_with_virtual_size_expansion()
{
uint32_t overflow_capacity = 0; // consider the case where the overflow is not known until runtime
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above--if test correctness depends on a particular trace structure, we need to guard against that structure changing silently by putting the structure in the test (or test suite).

@@ -113,7 +113,8 @@ template <class DeciderProvingKeys_> class ProtogalaxyProverInternal {
*/
std::vector<FF> compute_row_evaluations(const ProverPolynomials& polynomials,
const RelationSeparator& alphas_,
const RelationParameters<FF>& relation_parameters)
const RelationParameters<FF>& relation_parameters,
const bool use_prev_accumulator_tracker = false)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this boolean needed here now?

Copy link
Contributor

Choose a reason for hiding this comment

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

This function is used in two situations, perturbator computation in which we use the active ranges from the previous accumulator and if we manually want to compute the evaluations for each row of an accumulator

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe it should be default true and optional false?

using Flavor = TypeParam;
using Builder = Flavor::CircuitBuilder;

TraceSettings trace_settings{ SMALL_TEST_STRUCTURE };
Copy link
Contributor

Choose a reason for hiding this comment

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

Again

Copy link
Contributor

github-actions bot commented Nov 27, 2024

Changes to public function bytecode sizes

Generated at commit: ad3a0cd0286d32d482e7930d177be8317db07345, compared to commit: 7d5c33d1f046e1b8b3f367ff1682b9fd6272e2fd

🧾 Summary (100% most significant diffs)

Program Bytecode size in bytes (+/-) %
AvmTest::bulk_testing +30 ❌ +0.13%
AvmTest::public_dispatch -9 ✅ -0.01%

Full diff report 👇
Program Bytecode size in bytes (+/-) %
AvmTest::bulk_testing 23,104 (+30) +0.13%
AvmTest::public_dispatch 60,762 (-9) -0.01%

Copy link
Contributor

github-actions bot commented Nov 27, 2024

Changes to circuit sizes

Generated at commit: ad3a0cd0286d32d482e7930d177be8317db07345, compared to commit: 7d5c33d1f046e1b8b3f367ff1682b9fd6272e2fd

🧾 Summary (100% most significant diffs)

Program ACIR opcodes (+/-) % Circuit size (+/-) %
private_kernel_empty -1 ✅ -0.16% -1 ✅ -0.00%
rollup_base_public -2 ✅ -0.00% -8 ✅ -0.00%
private_kernel_reset -2 ✅ -0.00% -2 ✅ -0.00%
rollup_block_root -1 ✅ -0.02% -13 ✅ -0.00%
rollup_merge -1 ✅ -0.03% -13 ✅ -0.00%
rollup_base_private -2 ✅ -0.00% -83 ✅ -0.00%
private_kernel_tail_to_public -2 ✅ -0.01% -1 ✅ -0.00%
private_kernel_reset_4_4_4_4_4_4_4_4_1 -2 ✅ -0.01% -3 ✅ -0.00%
private_kernel_inner -3 ✅ -0.01% -3 ✅ -0.01%
private_kernel_tail -2 ✅ -0.05% -1 ✅ -0.01%
private_kernel_init -2 ✅ -0.01% -3 ✅ -0.01%

Full diff report 👇
Program ACIR opcodes (+/-) % Circuit size (+/-) %
private_kernel_empty 612 (-1) -0.16% 901,639 (-1) -0.00%
rollup_base_public 447,125 (-2) -0.00% 3,997,443 (-8) -0.00%
private_kernel_reset 84,027 (-2) -0.00% 618,037 (-2) -0.00%
rollup_block_root 4,489 (-1) -0.02% 2,739,652 (-13) -0.00%
rollup_merge 3,419 (-1) -0.03% 1,827,046 (-13) -0.00%
rollup_base_private 197,673 (-2) -0.00% 2,658,579 (-83) -0.00%
private_kernel_tail_to_public 17,384 (-2) -0.01% 29,504 (-1) -0.00%
private_kernel_reset_4_4_4_4_4_4_4_4_1 32,385 (-2) -0.01% 86,491 (-3) -0.00%
private_kernel_inner 37,549 (-3) -0.01% 56,879 (-3) -0.01%
private_kernel_tail 4,131 (-2) -0.05% 12,514 (-1) -0.01%
private_kernel_init 21,407 (-2) -0.01% 34,503 (-3) -0.01%

Copy link
Contributor

@codygunton codygunton left a comment

Choose a reason for hiding this comment

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

Thanks!

@codygunton codygunton merged commit b7b282c into master Nov 27, 2024
71 checks passed
@codygunton codygunton deleted the lde/swap_polys branch November 27, 2024 20:22
ludamad pushed a commit that referenced this pull request Nov 28, 2024
🤖 I have created a release *beep* *boop*
---


<details><summary>aztec-package: 0.65.2</summary>

##
[0.65.2](aztec-package-v0.65.1...aztec-package-v0.65.2)
(2024-11-28)


### Features

* New proving broker
([#10174](#10174))
([6fd5fc1](6fd5fc1))
</details>

<details><summary>barretenberg.js: 0.65.2</summary>

##
[0.65.2](barretenberg.js-v0.65.1...barretenberg.js-v0.65.2)
(2024-11-28)


### Miscellaneous

* **barretenberg.js:** Synchronize aztec-packages versions
</details>

<details><summary>aztec-packages: 0.65.2</summary>

##
[0.65.2](aztec-packages-v0.65.1...aztec-packages-v0.65.2)
(2024-11-28)


### Features

* Fee foresight support
([#10262](#10262))
([9e19244](9e19244))
* New proving broker
([#10174](#10174))
([6fd5fc1](6fd5fc1))
* Sequential insertion in indexed trees
([#10111](#10111))
([bfd9fa6](bfd9fa6))
* Swap polys to facilitate dynamic trace overflow
([#9976](#9976))
([b7b282c](b7b282c))


### Bug Fixes

* Don't store indices of zero leaves.
([#10270](#10270))
([c22be8b](c22be8b))
* Expect proper duplicate nullifier error patterns in e2e tests
([#10256](#10256))
([4ee8344](4ee8344))


### Miscellaneous

* Check artifact consistency
([#10271](#10271))
([6a49405](6a49405))
* Dont import things that themselves import jest in imported functions
([#10260](#10260))
([9440c1c](9440c1c))
* Fix bad merge in integration l1 publisher
([#10272](#10272))
([b5a6aa4](b5a6aa4))
* Fixing sol warnings
([#10276](#10276))
([3d113b2](3d113b2))
* Pull out sync changes
([#10274](#10274))
([391a6b7](391a6b7))
* Pull value merger code from sync
([#10080](#10080))
([3392629](3392629))
* Remove default gas settings
([#10163](#10163))
([c9a4d88](c9a4d88))
* Replace relative paths to noir-protocol-circuits
([654d801](654d801))
* Teardown context in prover coordination test
([#10257](#10257))
([7ea3888](7ea3888))
</details>

<details><summary>barretenberg: 0.65.2</summary>

##
[0.65.2](barretenberg-v0.65.1...barretenberg-v0.65.2)
(2024-11-28)


### Features

* Sequential insertion in indexed trees
([#10111](#10111))
([bfd9fa6](bfd9fa6))
* Swap polys to facilitate dynamic trace overflow
([#9976](#9976))
([b7b282c](b7b282c))


### Bug Fixes

* Don't store indices of zero leaves.
([#10270](#10270))
([c22be8b](c22be8b))


### Miscellaneous

* Pull value merger code from sync
([#10080](#10080))
([3392629](3392629))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
AztecBot added a commit to AztecProtocol/barretenberg that referenced this pull request Nov 29, 2024
🤖 I have created a release *beep* *boop*
---


<details><summary>aztec-package: 0.65.2</summary>

##
[0.65.2](AztecProtocol/aztec-packages@aztec-package-v0.65.1...aztec-package-v0.65.2)
(2024-11-28)


### Features

* New proving broker
([#10174](AztecProtocol/aztec-packages#10174))
([6fd5fc1](AztecProtocol/aztec-packages@6fd5fc1))
</details>

<details><summary>barretenberg.js: 0.65.2</summary>

##
[0.65.2](AztecProtocol/aztec-packages@barretenberg.js-v0.65.1...barretenberg.js-v0.65.2)
(2024-11-28)


### Miscellaneous

* **barretenberg.js:** Synchronize aztec-packages versions
</details>

<details><summary>aztec-packages: 0.65.2</summary>

##
[0.65.2](AztecProtocol/aztec-packages@aztec-packages-v0.65.1...aztec-packages-v0.65.2)
(2024-11-28)


### Features

* Fee foresight support
([#10262](AztecProtocol/aztec-packages#10262))
([9e19244](AztecProtocol/aztec-packages@9e19244))
* New proving broker
([#10174](AztecProtocol/aztec-packages#10174))
([6fd5fc1](AztecProtocol/aztec-packages@6fd5fc1))
* Sequential insertion in indexed trees
([#10111](AztecProtocol/aztec-packages#10111))
([bfd9fa6](AztecProtocol/aztec-packages@bfd9fa6))
* Swap polys to facilitate dynamic trace overflow
([#9976](AztecProtocol/aztec-packages#9976))
([b7b282c](AztecProtocol/aztec-packages@b7b282c))


### Bug Fixes

* Don't store indices of zero leaves.
([#10270](AztecProtocol/aztec-packages#10270))
([c22be8b](AztecProtocol/aztec-packages@c22be8b))
* Expect proper duplicate nullifier error patterns in e2e tests
([#10256](AztecProtocol/aztec-packages#10256))
([4ee8344](AztecProtocol/aztec-packages@4ee8344))


### Miscellaneous

* Check artifact consistency
([#10271](AztecProtocol/aztec-packages#10271))
([6a49405](AztecProtocol/aztec-packages@6a49405))
* Dont import things that themselves import jest in imported functions
([#10260](AztecProtocol/aztec-packages#10260))
([9440c1c](AztecProtocol/aztec-packages@9440c1c))
* Fix bad merge in integration l1 publisher
([#10272](AztecProtocol/aztec-packages#10272))
([b5a6aa4](AztecProtocol/aztec-packages@b5a6aa4))
* Fixing sol warnings
([#10276](AztecProtocol/aztec-packages#10276))
([3d113b2](AztecProtocol/aztec-packages@3d113b2))
* Pull out sync changes
([#10274](AztecProtocol/aztec-packages#10274))
([391a6b7](AztecProtocol/aztec-packages@391a6b7))
* Pull value merger code from sync
([#10080](AztecProtocol/aztec-packages#10080))
([3392629](AztecProtocol/aztec-packages@3392629))
* Remove default gas settings
([#10163](AztecProtocol/aztec-packages#10163))
([c9a4d88](AztecProtocol/aztec-packages@c9a4d88))
* Replace relative paths to noir-protocol-circuits
([654d801](AztecProtocol/aztec-packages@654d801))
* Teardown context in prover coordination test
([#10257](AztecProtocol/aztec-packages#10257))
([7ea3888](AztecProtocol/aztec-packages@7ea3888))
</details>

<details><summary>barretenberg: 0.65.2</summary>

##
[0.65.2](AztecProtocol/aztec-packages@barretenberg-v0.65.1...barretenberg-v0.65.2)
(2024-11-28)


### Features

* Sequential insertion in indexed trees
([#10111](AztecProtocol/aztec-packages#10111))
([bfd9fa6](AztecProtocol/aztec-packages@bfd9fa6))
* Swap polys to facilitate dynamic trace overflow
([#9976](AztecProtocol/aztec-packages#9976))
([b7b282c](AztecProtocol/aztec-packages@b7b282c))


### Bug Fixes

* Don't store indices of zero leaves.
([#10270](AztecProtocol/aztec-packages#10270))
([c22be8b](AztecProtocol/aztec-packages@c22be8b))


### Miscellaneous

* Pull value merger code from sync
([#10080](AztecProtocol/aztec-packages#10080))
([3392629](AztecProtocol/aztec-packages@3392629))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crypto cryptography
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants