Skip to content

feat: Gaussian elimination optimization for R1CS witness reduction#338

Open
rose2221 wants to merge 10 commits intomainfrom
rs/ge_witness_reduction
Open

feat: Gaussian elimination optimization for R1CS witness reduction#338
rose2221 wants to merge 10 commits intomainfrom
rs/ge_witness_reduction

Conversation

@rose2221
Copy link
Copy Markdown
Collaborator

@rose2221 rose2221 commented Mar 17, 2026

Overview

This PR introduces virtual witnesses to handle dead columns that are still required for computation but not for the proof.

  • Columns that do not appear in any R1CS constraints but are still read by live builders are reclassified as virtual witnesses.
  • These are computed during proving but excluded from the WHIR polynomial commitment, reducing prover cost without breaking builder dependency chains.
  • Witness builders that produce only fully-dead columns (no live or virtual dependents) are pruned entirely.

Benchmarks

complete_age_check

  • Real witnesses (committed):
    1,248,358 → 1,054,324 (15.5% reduction)

noir_sha256

  • Real witnesses (committed):
    32,278 → 25,336 (21.5% reduction)

@rose2221 rose2221 marked this pull request as draft March 17, 2026 07:29
Rose Jethani added 5 commits March 24, 2026 17:48
- Added  to handle Gaussian elimination optimization for R1CS constraints.
- Introduced methods to identify linear constraints, select pivot variables, and substitute them into remaining constraints.
- Enhanced  struct with methods to check for linear constraints and extract linear expressions.
- Updated  with new utility methods for row manipulation and entry retrieval.
- Integrated optimization pass into the Noir proof scheme compilation process.
- Added display functions for optimization statistics in the CLI.
- Included tests for various linear elimination scenarios to ensure correctness of the optimization logic.
- Added  field to the R1CS struct to account for computation-only columns.
- Modified the DigitalDecompositionWitnesses struct to use output indices instead of first witness index and number of witnesses.
- Updated the WitnessBuilder enum to replace output_start with output_indices for ChunkDecompose and SpreadBitExtract.
- Enhanced the WitnessIndexRemapper to handle virtual witnesses and adjust remapping logic accordingly.
- Adjusted the NoirProver to allocate space for both real and virtual witnesses.
- Updated CompressedR1CS to include num_virtual and provide a method to retrieve it.
- Refactored witness solving logic in DigitalDecompositionWitnessesSolver to utilize output indices.
- Modified the CLI circuit stats display to include virtual witness counts.
@rose2221 rose2221 force-pushed the rs/ge_witness_reduction branch from 8661bcc to 028f7bb Compare March 24, 2026 12:22
@rose2221 rose2221 marked this pull request as ready for review March 24, 2026 12:23
@rose2221 rose2221 changed the title Rs/ge witness reduction feat: Gaussian elimination optimization for R1CS witness reduction Mar 24, 2026
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.

1 participant