-
Notifications
You must be signed in to change notification settings - Fork 0
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
example: Projected / Repeated columns usage #6
Conversation
fcf6615
to
6349989
Compare
6349989
to
5902adc
Compare
ee8d6d0
to
5449442
Compare
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 exercises!
// it creates column with some input bytes written and then creates one more 'Repeated' column | ||
// where the same bytes are copied multiple times. | ||
fn bytes_repeat_gadget(builder: &mut ConstraintSystemBuilder<U, F128>) { | ||
let bytes = unconstrained::<U, F128, F8>(builder, "input", LOG_SIZE).unwrap(); |
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.
These gadgets are missing the push/pop of a namespace
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.
Right, thanks! This is important, when multiple gadgets are combined into the circuit
5449442
to
c50195c
Compare
…rithExpr tower_level from its constants (#6) In contrast to TowerField::TOWER_LEVEL, TowerField::binary_tower_level(self) returns the smallest tower level that can fit the current value. This can be useful for shrinking field values to the smaller container that fits them, for the purpose of making arithmetic operations (in particular multiplication) cheaper.
* example: Add example of Projected column usage * example: Add example of Repeated column usage * example: Add example of ZeroPadded column usage
* example: Add example of Projected column usage * example: Add example of Repeated column usage * example: Add example of ZeroPadded column usage
* Support for Karatsuba "infinity" point in evaluation & interpolation domains * [sumcheck] Small field zerocheck and its HAL support removed * [ring_switch] Optimize RingSwitchEqInd::multilinear_extension * [clippy]: avoid needless pass by value * [math] Fix `fold_right` crash on big multilinears and make it single threaded * [math] Use specialized zero variable folding in the first sumcheck round. * [test]: add test coverage for eq_ind_partial_eval * [test]: add test coverage for inner_product_par * [test]: test coverage for MultilinearQuery update * [tracing] Display proof size in graph * [ci]: Setting Up GitHub Pipelines * [ci]: Setting Up Mirror to GitLab (#8) * Fix typos (#2) [nicetohave] fix typos * [ci]: Improvements (IrreducibleOSS#17) [ci]: Removing continue or error, and depricating Gitlab pipelines * Improve test compilation time (#10) Co-authored-by: Dmytro Gordon <[email protected]> This MR addresses tow issues that make cargo test slow: Thin LTO slows down compilation of all the crates a bit. It takes quite a time to compile and link all the examples with test profile which are not actually executed. So I've added an alias to compile and run tests only for fast local usage. * [serialization] Add canonical serialize/deserialize traits + derive macros Introduces the following traits: SerializeCanonical (which replaces most uses of SerializeBytes) DeserializeCanonical (which replaces most uses of DeserializeBytes) Conveniently, this also comes with proc-macros for deriving these traits for an arbitrary struct/enum (unions are not supported). * [security]: Add CODEOWNERS file for GitHub * [scripts] Added benchmarking script This adds the script to benchmark various of our examples, default sampling is set to 5 to reduce total time to benchmark. * [field] Implement PackedField::unzip * [cleanup]: Remove some useless checked_log_2 calls * [field] Add TowerField::min_tower_level(self), and use it to derive ArithExpr tower_level from its constants (#6) In contrast to TowerField::TOWER_LEVEL, TowerField::binary_tower_level(self) returns the smallest tower level that can fit the current value. This can be useful for shrinking field values to the smaller container that fits them, for the purpose of making arithmetic operations (in particular multiplication) cheaper. * [core]: simplify merkle tree `verify_opening` (IrreducibleOSS#14) * [ci] Adjusting nightly benchmark repository (IrreducibleOSS#23) * [ci]: Adjusting nightly benchmark repository * [ci]: Adjusting CODEOWNERS for .github/ subdir * [circuits] Simplify usage of ConstraintSystemBuilder by making it less generic (IrreducibleOSS#22) [circuits] Simplfy ConstraintSystemBuilder to only support BinaryField128b for the top field. * [field] Simplify usage of PackedExtension, RepackedExtension by making each trait imply its bounds (IrreducibleOSS#24) * [macros] Remove unused IterOracles, IterPolys derive proc macros (IrreducibleOSS#25) * [matrix]: simplify scale_row (IrreducibleOSS#31) * [field] Remove unnecessary `WithUnderlier` trait bound (IrreducibleOSS#32) * [field] Optimize SIMD element access for Zen4 architecture as well. (IrreducibleOSS#28) * refactor: Use binary_tower_level for base field detection (IrreducibleOSS#30) * [serialization] impl SerializeCanonical, DeserializeCanonical for ConstraintSystem (IrreducibleOSS#11) * [circuits] Optimize plain_lookup using selector flushing (IrreducibleOSS#29) * [scripts] Remove groestl run from benchmark script (IrreducibleOSS#26) * [arith_expr]: Statically compile exponentiation in ArithCircuitPoly (IrreducibleOSS#15) * [serialization] Introduce SerializationMode (IrreducibleOSS#36) Changes: Adds SerializaitonMode that specifies whether to use native (fast) or canonical (needed for transcript) serialization/deserializtion. You need to use the same mode for serialization and deserialization. SerializeCanonical is renamed to SerializeBytes, and takes an extra argument of type SerializationMode DeserializeCanonical is renamed to DeserializeBytes and takes an extra argument of type SerializationMode SerializeBytes and DeserializeBytes are now required bounds for the Field trait, rather than being generically implemented for TowerField. u16, u32, u64, u128 now serialize to/deserialize from little-endian rather than big-endian byte order, to be consistent with BinaryField*b serialization. The serialization traits are moved back to binius_utils Automatic implementations of SerializeBytes for Box<T: SerializeBytes> and &(T: SerializeBytes) Automatic implementation of DeserializeBytes for Box<T: DeserializeBytes> * [gkr_int_mul] Fix type bounds (IrreducibleOSS#34) * feat: Blake3 G function gadget (IrreducibleOSS#16) * [circuits] Add test_circuit helper (IrreducibleOSS#27) * Leave only the object-safe version of the `CompositionPoly` trait (IrreducibleOSS#43) * ]field] Byte-sliced fields changes (IrreducibleOSS#21) * Refactor a bit TowerLevels to remove packed field parameter from the TowerLevel to the Data associated type. This also makes generic bounds a bit more clean, since TowerLevel itself doesn't depend on a concrete packed field type. * Add support of byte-sliced fields with arbitrary register size, i.e. 128b, 256b, 512b. * Add shifts and unpack low/high within 128-bit lanes to UnderlierWithBitOps. This allows implementing transposition in an efficient way. * Add the transparent implementation of UnderlierWithBitOps for PackedScaledUnderlier as we need it to re-use PackedScaledField. * feat: Add example of LinearCombination column usage * ci: Add basic Rust CI (#2) * ci: Add basic Rust CI * Fix test flags * example: Linear combination with offset (#4) * example: Add linear-combination-with-offset usage example * chore: Add example for bit masking using LinearCombination * chore: Add byte decomposition constraint * example: Implement bit-shifting/rotating and packing (#5) * example: Add example of Shifted column usage * example: Add example of Packed column usage * chore: Add 'unconstrained gadgets' warning * example: Projected / Repeated columns usage (#6) * example: Add example of Projected column usage * example: Add example of Repeated column usage * example: Add example of ZeroPadded column usage * examples: Transparent columns usage (part 1) (#8) * feat: Add example of Transparent (Constant) column usage * example: Add example of Transparent (Powers) column usage * example: Add example of Transparent (DisjointProduct) column usage * example: Add example of Transparent (EqIndPartialEval) column usage * examples: Transparent columns usage (part 2) (#9) * example: Add example of Transparent (MultilinearExtensionTransparent) column usage * example: Add example of Transparent (SelectRow) column usage * example: Add example of Transparent (ShiftIndPartialEval) column usage * example: Add example of Transparent (StepDown) column usage * example: Add example of Transparent (StepUp) column usage * example: Add example of Transparent (TowerBasis) column usage * chore: Forward port * feat: Blake3 permutation using channels API * chore: Formatting --------- Co-authored-by: Nikita Lesnikov <[email protected]> Co-authored-by: Dmitry Gordon <[email protected]> Co-authored-by: Thomas Coratger <[email protected]> Co-authored-by: Aliaksei Dziadziuk <[email protected]> Co-authored-by: Milos Backonja <[email protected]> Co-authored-by: Milos Backonja <[email protected]> Co-authored-by: chloefeal <[email protected]> Co-authored-by: Dmytro Gordon <[email protected]> Co-authored-by: Tobias Bergkvist <[email protected]> Co-authored-by: Anex007 <[email protected]> Co-authored-by: Thomas Coratger <[email protected]> Co-authored-by: Nikita Lesnikov <[email protected]> Co-authored-by: Joseph Johnston <[email protected]> Co-authored-by: Samuel Burnham <[email protected]>
* example: Add example of Projected column usage * example: Add example of Repeated column usage * example: Add example of ZeroPadded column usage
* Support for Karatsuba "infinity" point in evaluation & interpolation domains * [sumcheck] Small field zerocheck and its HAL support removed * [ring_switch] Optimize RingSwitchEqInd::multilinear_extension * [clippy]: avoid needless pass by value * [math] Fix `fold_right` crash on big multilinears and make it single threaded * [math] Use specialized zero variable folding in the first sumcheck round. * [test]: add test coverage for eq_ind_partial_eval * [test]: add test coverage for inner_product_par * [test]: test coverage for MultilinearQuery update * [tracing] Display proof size in graph * [ci]: Setting Up GitHub Pipelines * [ci]: Setting Up Mirror to GitLab (#8) * Fix typos (#2) [nicetohave] fix typos * [ci]: Improvements (IrreducibleOSS#17) [ci]: Removing continue or error, and depricating Gitlab pipelines * Improve test compilation time (#10) Co-authored-by: Dmytro Gordon <[email protected]> This MR addresses tow issues that make cargo test slow: Thin LTO slows down compilation of all the crates a bit. It takes quite a time to compile and link all the examples with test profile which are not actually executed. So I've added an alias to compile and run tests only for fast local usage. * [serialization] Add canonical serialize/deserialize traits + derive macros Introduces the following traits: SerializeCanonical (which replaces most uses of SerializeBytes) DeserializeCanonical (which replaces most uses of DeserializeBytes) Conveniently, this also comes with proc-macros for deriving these traits for an arbitrary struct/enum (unions are not supported). * [security]: Add CODEOWNERS file for GitHub * [scripts] Added benchmarking script This adds the script to benchmark various of our examples, default sampling is set to 5 to reduce total time to benchmark. * [field] Implement PackedField::unzip * [cleanup]: Remove some useless checked_log_2 calls * [field] Add TowerField::min_tower_level(self), and use it to derive ArithExpr tower_level from its constants (#6) In contrast to TowerField::TOWER_LEVEL, TowerField::binary_tower_level(self) returns the smallest tower level that can fit the current value. This can be useful for shrinking field values to the smaller container that fits them, for the purpose of making arithmetic operations (in particular multiplication) cheaper. * [core]: simplify merkle tree `verify_opening` (IrreducibleOSS#14) * [ci] Adjusting nightly benchmark repository (IrreducibleOSS#23) * [ci]: Adjusting nightly benchmark repository * [ci]: Adjusting CODEOWNERS for .github/ subdir * [circuits] Simplify usage of ConstraintSystemBuilder by making it less generic (IrreducibleOSS#22) [circuits] Simplfy ConstraintSystemBuilder to only support BinaryField128b for the top field. * [field] Simplify usage of PackedExtension, RepackedExtension by making each trait imply its bounds (IrreducibleOSS#24) * [macros] Remove unused IterOracles, IterPolys derive proc macros (IrreducibleOSS#25) * [matrix]: simplify scale_row (IrreducibleOSS#31) * [field] Remove unnecessary `WithUnderlier` trait bound (IrreducibleOSS#32) * [field] Optimize SIMD element access for Zen4 architecture as well. (IrreducibleOSS#28) * refactor: Use binary_tower_level for base field detection (IrreducibleOSS#30) * [serialization] impl SerializeCanonical, DeserializeCanonical for ConstraintSystem (IrreducibleOSS#11) * [circuits] Optimize plain_lookup using selector flushing (IrreducibleOSS#29) * [scripts] Remove groestl run from benchmark script (IrreducibleOSS#26) * [arith_expr]: Statically compile exponentiation in ArithCircuitPoly (IrreducibleOSS#15) * [serialization] Introduce SerializationMode (IrreducibleOSS#36) Changes: Adds SerializaitonMode that specifies whether to use native (fast) or canonical (needed for transcript) serialization/deserializtion. You need to use the same mode for serialization and deserialization. SerializeCanonical is renamed to SerializeBytes, and takes an extra argument of type SerializationMode DeserializeCanonical is renamed to DeserializeBytes and takes an extra argument of type SerializationMode SerializeBytes and DeserializeBytes are now required bounds for the Field trait, rather than being generically implemented for TowerField. u16, u32, u64, u128 now serialize to/deserialize from little-endian rather than big-endian byte order, to be consistent with BinaryField*b serialization. The serialization traits are moved back to binius_utils Automatic implementations of SerializeBytes for Box<T: SerializeBytes> and &(T: SerializeBytes) Automatic implementation of DeserializeBytes for Box<T: DeserializeBytes> * [gkr_int_mul] Fix type bounds (IrreducibleOSS#34) * feat: Blake3 G function gadget (IrreducibleOSS#16) * [circuits] Add test_circuit helper (IrreducibleOSS#27) * Leave only the object-safe version of the `CompositionPoly` trait (IrreducibleOSS#43) * ]field] Byte-sliced fields changes (IrreducibleOSS#21) * Refactor a bit TowerLevels to remove packed field parameter from the TowerLevel to the Data associated type. This also makes generic bounds a bit more clean, since TowerLevel itself doesn't depend on a concrete packed field type. * Add support of byte-sliced fields with arbitrary register size, i.e. 128b, 256b, 512b. * Add shifts and unpack low/high within 128-bit lanes to UnderlierWithBitOps. This allows implementing transposition in an efficient way. * Add the transparent implementation of UnderlierWithBitOps for PackedScaledUnderlier as we need it to re-use PackedScaledField. * feat: Add example of LinearCombination column usage * ci: Add basic Rust CI (#2) * ci: Add basic Rust CI * Fix test flags * example: Linear combination with offset (#4) * example: Add linear-combination-with-offset usage example * chore: Add example for bit masking using LinearCombination * chore: Add byte decomposition constraint * example: Implement bit-shifting/rotating and packing (#5) * example: Add example of Shifted column usage * example: Add example of Packed column usage * chore: Add 'unconstrained gadgets' warning * example: Projected / Repeated columns usage (#6) * example: Add example of Projected column usage * example: Add example of Repeated column usage * example: Add example of ZeroPadded column usage * examples: Transparent columns usage (part 1) (#8) * feat: Add example of Transparent (Constant) column usage * example: Add example of Transparent (Powers) column usage * example: Add example of Transparent (DisjointProduct) column usage * example: Add example of Transparent (EqIndPartialEval) column usage * examples: Transparent columns usage (part 2) (#9) * example: Add example of Transparent (MultilinearExtensionTransparent) column usage * example: Add example of Transparent (SelectRow) column usage * example: Add example of Transparent (ShiftIndPartialEval) column usage * example: Add example of Transparent (StepDown) column usage * example: Add example of Transparent (StepUp) column usage * example: Add example of Transparent (TowerBasis) column usage * chore: Forward port * feat: Blake3 permutation using channels API * chore: Formatting --------- Co-authored-by: Nikita Lesnikov <[email protected]> Co-authored-by: Dmitry Gordon <[email protected]> Co-authored-by: Thomas Coratger <[email protected]> Co-authored-by: Aliaksei Dziadziuk <[email protected]> Co-authored-by: Milos Backonja <[email protected]> Co-authored-by: Milos Backonja <[email protected]> Co-authored-by: chloefeal <[email protected]> Co-authored-by: Dmytro Gordon <[email protected]> Co-authored-by: Tobias Bergkvist <[email protected]> Co-authored-by: Anex007 <[email protected]> Co-authored-by: Thomas Coratger <[email protected]> Co-authored-by: Nikita Lesnikov <[email protected]> Co-authored-by: Joseph Johnston <[email protected]> Co-authored-by: Samuel Burnham <[email protected]>
In this PR I tried to explore regularities of computing values from Projected columns given some arbitrary input. The idea behind projection is that one can interpret data from some input column with a given field as a data with a same or greater (but not smaller) field and applying some offset depending on ProjectionVariant::{ FirstVars / LastVars}.
TODO: there are examples for projecting to a greater field column (F8 -> F128), so need to add examples of projecting to the same field column (F8 -> F8). Projecting F1 -> F8 can also exist but it is hard to "catch the regularity" as observing bits in debugger is not too informative
Update: after some playing with F8 -> F8 projecting it looks that is has no sense, as bytes are just moved from input to projected column without any manipulations.
I decided to add examples of missing virtual columns usage (Repeated, ZeroPadded) which should finalise series of these examples