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

chore: Avoid creating witness for simple multiplications #5100

Merged
merged 2 commits into from
May 24, 2024

Conversation

guipublic
Copy link
Contributor

Description

Problem*

Related to #4629

Summary*

Do not create a witness when multiplying a witness (or an affine transformation of a witness) with an expression of degree 1.

Additional Context

This PR does NOT fix the issue #4629, but it should help reducing the overall gates number.
The arithmetic expressions resulting from the multiplication should not explode in width since I only consider multiplication with a witness (or 'affine witness').

Documentation*

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [For Experimental Features] Documentation to be submitted in a separate PR.

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

@guipublic guipublic changed the title Avoid creating witness for simple multiplications chore: Avoid creating witness for simple multiplications May 24, 2024
Copy link
Contributor

Changes to circuit sizes

Generated at commit: f9da41612effa881be411a00fda780b7895f4dfe, compared to commit: 86fd0ac4e6dd168227de6b8c97ed08da89e58a89

🧾 Summary (10% most significant diffs)

Program ACIR opcodes (+/-) % Circuit size (+/-) %
debug_logs -1 ✅ -2.13% -1 ✅ -1.33%
hashmap -5,898 ✅ -2.73% -5,898 ✅ -1.40%
slice_dynamic_index -148 ✅ -10.37% -148 ✅ -2.05%
slices -79 ✅ -20.26% -104 ✅ -2.90%
references -2 ✅ -25.00% -2 ✅ -8.70%

Full diff report 👇
Program ACIR opcodes (+/-) % Circuit size (+/-) %
regression 350 (+33) +10.41% 3,360 (+33) +0.99%
arithmetic_binary_operations 19 (+1) +5.56% 2,791 (+1) +0.04%
conditional_1 8,550 (+88) +1.04% 38,809 (0) 0.00%
conditional_regression_short_circuit 98 (-1) -1.01% 38,809 (0) 0.00%
merkle_insert 1,779 (-18) -1.00% 29,042 (0) 0.00%
operator_overloading 563 (-7) -1.23% 8,224 (0) 0.00%
simple_shield 30 (-9) -23.08% 29,042 (0) 0.00%
bigint 682 (-1) -0.15% 8,724 (-1) -0.01%
regression_3607 43 (-1) -2.27% 2,804 (-1) -0.04%
conditional_2 22 (-1) -4.35% 2,782 (-1) -0.04%
eddsa 73,144 (-33) -0.05% 74,517 (-33) -0.04%
regression_mem_op_predicate 58 (-2) -3.33% 3,587 (-2) -0.06%
array_if_cond_simple 116 (-2) -1.69% 3,146 (-2) -0.06%
u16_support 263 (-2) -0.75% 3,076 (-2) -0.06%
conditional_regression_421 32 (-2) -5.88% 2,793 (-2) -0.07%
regression_capacity_tracker 115 (-5) -4.17% 3,966 (-5) -0.13%
tuple_inputs 44 (-5) -10.20% 3,699 (-5) -0.13%
if_else_chain 47 (-4) -7.84% 2,809 (-4) -0.14%
conditional_regression_661 32 (-4) -11.11% 2,800 (-4) -0.14%
regression_struct_array_conditional 70 (-5) -6.67% 3,253 (-5) -0.15%
regression_4709 72 (-6) -7.69% 2,920 (-6) -0.21%
bit_shifts_runtime 2,611 (-12) -0.46% 5,706 (-12) -0.21%
array_dynamic 111 (-8) -6.72% 3,764 (-8) -0.21%
array_sort 55 (-8) -12.70% 2,927 (-8) -0.27%
signed_division 167 (-16) -8.74% 3,646 (-16) -0.44%
nested_array_in_slice 1,094 (-32) -2.84% 6,789 (-34) -0.50%
signed_arithmetic 179 (-22) -10.95% 2,929 (-22) -0.75%
signed_comparison 143 (-3) -2.05% 298 (-3) -1.00%
7_function 234 (-31) -11.70% 3,007 (-31) -1.02%
u128 782 (-50) -6.01% 4,783 (-50) -1.03%
nested_array_dynamic 4,406 (-189) -4.11% 15,943 (-189) -1.17%
debug_logs 46 (-1) -2.13% 74 (-1) -1.33%
hashmap 209,999 (-5,898) -2.73% 415,302 (-5,898) -1.40%
slice_dynamic_index 1,279 (-148) -10.37% 7,088 (-148) -2.05%
slices 311 (-79) -20.26% 3,487 (-104) -2.90%
references 6 (-2) -25.00% 21 (-2) -8.70%

@guipublic guipublic requested a review from TomAFrench May 24, 2024 12:19
@TomAFrench TomAFrench added this pull request to the merge queue May 24, 2024
Merged via the queue into master with commit 9db206e May 24, 2024
44 checks passed
@TomAFrench TomAFrench deleted the gd/issue_4629 branch May 24, 2024 16:14
AztecBot added a commit to AztecProtocol/aztec-packages that referenced this pull request May 27, 2024
…r-lang/noir#5097)

chore(docs): Link to evmdiff for supported EVM chains (noir-lang/noir#5107)
chore: Avoid creating witness for simple multiplications (noir-lang/noir#5100)
feat: Add intrinsic to get if running inside an unconstrained context (noir-lang/noir#5098)
chore: Move turbofish changes to the elaborator (noir-lang/noir#5094)
fix: Apply self type from generic trait constraint before instantiating identifiers (noir-lang/noir#5087)
chore: reactivate gates report (noir-lang/noir#5084)
chore: automatically clear any unwanted directories in `test_programs` (noir-lang/noir#5081)
chore: update `nargo info` table to remove circuit size column
feat: Activate return_data in ACIR opcodes (noir-lang/noir#5080)
fix: Use plain integer addresses for opcodes in DAP disassembly view (noir-lang/noir#4941)
chore(experimental): Elaborate globals (noir-lang/noir#5069)
chore(experimental): Add types and traits to the elaborator (noir-lang/noir#5066)
feat: remove conditional compilation of `bn254_blackbox_solver` (noir-lang/noir#5058)
chore: use `bbup` to install `bb` (noir-lang/noir#5073)
feat: Sync from aztec-packages (noir-lang/noir#5070)
chore: update docs to represent zksync supporting necessary precompiles (noir-lang/noir#5071)
feat(stdlib)!: eddsa function using turbofish (noir-lang/noir#5050)
fix(frontend): Correctly monomorphize turbofish functions (noir-lang/noir#5049)
AztecBot added a commit to AztecProtocol/aztec-packages that referenced this pull request May 27, 2024
…5097)

chore(docs): Link to evmdiff for supported EVM chains (noir-lang/noir#5107)
chore: Avoid creating witness for simple multiplications (noir-lang/noir#5100)
feat: Add intrinsic to get if running inside an unconstrained context (noir-lang/noir#5098)
chore: Move turbofish changes to the elaborator (noir-lang/noir#5094)
fix: Apply self type from generic trait constraint before instantiating identifiers (noir-lang/noir#5087)
chore: reactivate gates report (noir-lang/noir#5084)
chore: automatically clear any unwanted directories in `test_programs` (noir-lang/noir#5081)
chore: update `nargo info` table to remove circuit size column
feat: Activate return_data in ACIR opcodes (noir-lang/noir#5080)
fix: Use plain integer addresses for opcodes in DAP disassembly view (noir-lang/noir#4941)
chore(experimental): Elaborate globals (noir-lang/noir#5069)
chore(experimental): Add types and traits to the elaborator (noir-lang/noir#5066)
feat: remove conditional compilation of `bn254_blackbox_solver` (noir-lang/noir#5058)
chore: use `bbup` to install `bb` (noir-lang/noir#5073)
feat: Sync from aztec-packages (noir-lang/noir#5070)
chore: update docs to represent zksync supporting necessary precompiles (noir-lang/noir#5071)
feat(stdlib)!: eddsa function using turbofish (noir-lang/noir#5050)
fix(frontend): Correctly monomorphize turbofish functions (noir-lang/noir#5049)
sirasistant added a commit to AztecProtocol/aztec-packages that referenced this pull request May 27, 2024
Automated pull of development from the
[noir](https://github.com/noir-lang/noir) programming language, a
dependency of Aztec.
BEGIN_COMMIT_OVERRIDE
feat: Consider block parameters in variable liveness
(noir-lang/noir#5097)
chore(docs): Link to evmdiff for supported EVM chains
(noir-lang/noir#5107)
chore: Avoid creating witness for simple multiplications
(noir-lang/noir#5100)
feat: Add intrinsic to get if running inside an unconstrained context
(noir-lang/noir#5098)
chore: Move turbofish changes to the elaborator
(noir-lang/noir#5094)
fix: Apply self type from generic trait constraint before instantiating
identifiers (noir-lang/noir#5087)
chore: reactivate gates report
(noir-lang/noir#5084)
chore: automatically clear any unwanted directories in `test_programs`
(noir-lang/noir#5081)
chore: update `nargo info` table to remove circuit size column
feat: Activate return_data in ACIR opcodes
(noir-lang/noir#5080)
fix: Use plain integer addresses for opcodes in DAP disassembly view
(noir-lang/noir#4941)
chore(experimental): Elaborate globals
(noir-lang/noir#5069)
chore(experimental): Add types and traits to the elaborator
(noir-lang/noir#5066)
feat: remove conditional compilation of `bn254_blackbox_solver`
(noir-lang/noir#5058)
chore: use `bbup` to install `bb`
(noir-lang/noir#5073)
feat: Sync from aztec-packages
(noir-lang/noir#5070)
chore: update docs to represent zksync supporting necessary precompiles
(noir-lang/noir#5071)
feat(stdlib)!: eddsa function using turbofish
(noir-lang/noir#5050)
fix(frontend): Correctly monomorphize turbofish functions
(noir-lang/noir#5049)
END_COMMIT_OVERRIDE

---------

Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com>
Co-authored-by: sirasistant <sirasistant@gmail.com>
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.

2 participants