-
Notifications
You must be signed in to change notification settings - Fork 143
Prover/vertical splitting for limitless prover #547
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
Merged
Soleimani193
merged 5 commits into
prover/limitless-top-level
from
prover/vertical-splitting-for-limitless-prover
Jan 16, 2025
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
24fd9b1
splitting a moule to segments
Soleimani193 b74e7ea
adjusting the expressions size for zcatalog
Soleimani193 0796b43
Merge branch 'prover/limitless-top-level' of github.com:Consensys/lin…
AlexandreBelling 78f45e6
supporting the verifiercol in distributed inclusion
Soleimani193 a470cdf
fixed the complains for verifieraction in logderiv and grandsum
Soleimani193 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| package distributed | ||
|
|
||
| import ( | ||
| "github.com/consensys/linea-monorepo/prover/protocol/ifaces" | ||
| "github.com/consensys/linea-monorepo/prover/protocol/wizard" | ||
| "github.com/consensys/linea-monorepo/prover/utils" | ||
| ) | ||
|
|
||
| // SegmentModuleInputs stores the inputs for both | ||
| // vertical and horizontal splitting of a [wizard.CompiledIOP] object. | ||
| type SegmentModuleInputs struct { | ||
| // InitialComp subject to the splitting | ||
| InitialComp *wizard.CompiledIOP | ||
| // inputs for horizontal splitting | ||
| Disc ModuleDiscoverer | ||
| ModuleName ModuleName | ||
| // inputs for vertical splitting | ||
| NumSegmentsInModule int | ||
| } | ||
|
|
||
| // GetFreshSegmentModuleComp returns a [wizard.DefineFunc] that creates | ||
| // a [wizard.CompiledIOP] object including only the columns relevant to the module. | ||
| // It splits the columns to the segments and assign them to the relevant CompiledIOP. | ||
| // It also contains the prover steps for assigning the module column. | ||
| // For all the segments from the same module, compiledIOP object is the same. | ||
| func GetFreshSegmentModuleComp(in SegmentModuleInputs) *wizard.CompiledIOP { | ||
|
|
||
| var ( | ||
| // initialize the moduleComp | ||
| segModComp = wizard.NewCompiledIOP() | ||
| initialComp = in.InitialComp | ||
| ) | ||
|
|
||
| for round := 0; round < initialComp.NumRounds(); round++ { | ||
| var columnsInRound []ifaces.Column | ||
| // get the columns per round | ||
| for _, colName := range initialComp.Columns.AllKeysAt(round) { | ||
|
|
||
| col := initialComp.Columns.GetHandle(colName) | ||
| if !in.Disc.ColumnIsInModule(col, in.ModuleName) { | ||
| continue | ||
| } | ||
|
|
||
| segModComp.InsertCommit(col.Round(), col.GetColID(), col.Size()/in.NumSegmentsInModule) | ||
| columnsInRound = append(columnsInRound, col) | ||
| } | ||
|
|
||
| // create a new moduleProver | ||
| segModuleProver := segmentModuleProver{ | ||
| cols: columnsInRound, | ||
| round: round, | ||
| numSegments: in.NumSegmentsInModule, | ||
| } | ||
|
|
||
| // register Prover action for the segment-module to assign columns per round | ||
| segModComp.RegisterProverAction(round, segModuleProver) | ||
| } | ||
|
|
||
| return segModComp | ||
| } | ||
|
|
||
| // it stores the input for the module prover | ||
| type segmentModuleProver struct { | ||
| round int | ||
| // columns for a specific round | ||
| cols []ifaces.Column | ||
| numSegments int | ||
| } | ||
|
|
||
| // It implements [wizard.ProverAction] for the module prover. | ||
| func (p segmentModuleProver) Run(run *wizard.ProverRuntime) { | ||
|
|
||
| if run.ParentRuntime == nil { | ||
| utils.Panic("invalid call: the runtime does not have a [ParentRuntime]") | ||
| } | ||
| if run.ProverID > p.numSegments { | ||
| panic("proverID can not be larger than number of segments") | ||
| } | ||
|
|
||
| for _, col := range p.cols { | ||
| // get the witness from the initialProver | ||
| colWitness := run.ParentRuntime.GetColumn(col.GetColID()) | ||
| colSegWitness := getSegmentFromWitness(colWitness, p.numSegments, run.ProverID) | ||
| // assign it in the module in the round col was declared | ||
| run.AssignColumn(col.GetColID(), colSegWitness, col.Round()) | ||
| } | ||
| } | ||
|
|
||
| func getSegmentFromWitness(wit ifaces.ColAssignment, numSegs, segID int) ifaces.ColAssignment { | ||
| segSize := wit.Len() / numSegs | ||
| return wit.SubVector(segSize*segID, segSize*segID+segSize) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,21 +52,27 @@ Compile an IOP from a protocol definition | |
| func Compile(define DefineFunc, compilers ...func(*CompiledIOP)) *CompiledIOP { | ||
| builder := newBuilder() | ||
| define(&builder) | ||
| comp := builder.CompiledIOP | ||
| return ContinueCompilation(comp, compilers...) | ||
| } | ||
|
|
||
| // ContinueCompilation continues a set of compilation steps over a initial CompiledIOP object. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a good idea to add that IMO |
||
| func ContinueCompilation(rootComp *CompiledIOP, compilers ...func(*CompiledIOP)) *CompiledIOP { | ||
| /* | ||
| For sanity, we need to ensure the protocol is well formed. All | ||
| registers should have the same number of rounds. The simplest to | ||
| iron this out after the define function. We still make sure than | ||
| no more rounds are allocated anywhere. | ||
| */ | ||
| comp := builder.CompiledIOP | ||
| comp := rootComp | ||
| numRounds := comp.NumRounds() | ||
|
|
||
| builder.equalizeRounds(numRounds) | ||
| comp.equalizeRounds(numRounds) | ||
|
|
||
| for _, compiler := range compilers { | ||
| compiler(comp) | ||
| numRounds := comp.NumRounds() | ||
| builder.equalizeRounds(numRounds) | ||
| comp.equalizeRounds(numRounds) | ||
| } | ||
|
|
||
| if comp.SubProvers.Len() < comp.NumRounds() { | ||
|
|
@@ -75,7 +81,7 @@ func Compile(define DefineFunc, compilers ...func(*CompiledIOP)) *CompiledIOP { | |
| ) | ||
| } | ||
|
|
||
| return builder.CompiledIOP | ||
| return comp | ||
| } | ||
|
|
||
| // NewCompiledIOP initializes a CompiledIOP object. | ||
|
|
@@ -258,8 +264,7 @@ func (b *Builder) LocalOpening(name ifaces.QueryID, pol ifaces.Column) query.Loc | |
| Equalizes the length of all the structure so that they all have the same | ||
| numbers of rounds | ||
| */ | ||
| func (b *Builder) equalizeRounds(numRounds int) { | ||
| comp := b.CompiledIOP | ||
| func (comp *CompiledIOP) equalizeRounds(numRounds int) { | ||
|
|
||
| helpMsg := "If you are seeing this message it's probably because you insert queries one round too late." | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
You should make ProverID a field of
segmentModuleProverand notProverRuntimeThere 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.
ModulCop for all segments should remain the same and proverID should only affect the prover.
On the other hand the run time already has the parent run time and is natural to say what is the position of the prover among its siblings.