-
Notifications
You must be signed in to change notification settings - Fork 26
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
[perf] Optimize FriReducedOpeningChip #1248
Conversation
This comment has been minimized.
This comment has been minimized.
edc6db6
to
259a25f
Compare
This comment has been minimized.
This comment has been minimized.
6258838
to
ffff287
Compare
This comment has been minimized.
This comment has been minimized.
ffff287
to
b1e410c
Compare
b1e410c
to
82f0e94
Compare
This comment has been minimized.
This comment has been minimized.
Can you also update the ISA documentation? |
82f0e94
to
ae71e73
Compare
This comment has been minimized.
This comment has been minimized.
Commit: 0ff18c5 |
) { | ||
let local: &Instruction2Cols<AB::Var> = local_slice[..INS_2_WIDTH].borrow(); | ||
let next: &WorkloadCols<AB::Var> = next_slice[..WL_WIDTH].borrow(); | ||
{ |
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.
Not sure why this is necessary, shouldn't it already be covered by lines 302-303?
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.
For example, the last row is a WorkloadCols
with idx = -1
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.
Maybe this case will be avoided by other constraints. But this sets an explicit boundary condition just for more safety
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.
I think the case that the last row is a workload row with index -1 is prevented by the fact that an instruction1 row is always followed by an instruction2 row (lines 302-303), an instruction2 row is always followed by a workload row with index 0 (line 403), and a disabled row other than the last is always followed by another disabled row (line 193), so a workload row with index -1 can only be preceded by a workload row with index -2, and so on.
The condition you have here is anyway not preventing workload rows with index -1 that appear in places other than the last row. I guess we can keep it just in case but if you can verify that it's not needed I think it's better to remove to make it less confusing later
) | ||
.eval(builder, multiplicity); | ||
{ | ||
let mut when_transition = builder.when_transition(); |
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.
Not sure why it's necessary to restrict to when_transition
here -- didn't we already restrict that first row has to be the first workload row of a FriReducedOpening, so last row necessary cannot be?
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.
Ah you are right
a: &[F], | ||
b: &[[F; EXT_DEG]], | ||
) -> ([F; EXT_DEG], [F; EXT_DEG]) { | ||
) -> [F; EXT_DEG] { | ||
let mut alpha_pow: [F; EXT_DEG] = elem_to_ext(F::ONE); |
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.
nit: Shouldn't we be using EF
in general here rather than [F; EXT_DEG]
?
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.
What is EF
?
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.
Generic for field extension
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.
Hmm how should I change? [F; EXT_DEG]
is not a generic
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.
We don't need to change it in this PR. But we would make FriReducedOpeningChip
also generic over EF
, which would have the trait bound EF: ExtensionField<F>
. Anyway, I'm not sure we want to do it; I suppose the AIR stills needs to constrain field extension multiplication for a very specific field extension, not a generic one.
I looked through the AIR constraints and it seems to be sound -- I noted two places above where I think there are unnecessary constraints but they are not harmful. |
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.
Will merge, above comments can be addressed in future
closes INT-3055
Reduced # of columns of
FriReducedOpeningChip
from 64 to 26. A side effect is that we use a more efficient way to computealpha_pow
.Notes for reviewers:
extensions/native/circuit/src/fri/mod.rs
. I rewrite everything so diff view is not helpful.WorkloadCols
/Instruction1Cols
/Instruction2Cols
. I use lots of static assertions in order to guarantee that some columns in these variants are aligned.WorkloadCols
:length
rows ofWorkloadCols
.a
/b
from memory and writelocal.result * local.alpha + b - a
intonext.result
Instruction1Cols
:Instruction1Cols
after allWorkloadCols
.a_ptr
/b_ptr
/length
/alpha
and writelocal.result
intolocal.result_ptr
.a_ptr
/b_ptr
/alpha
inWorkloadCols
above are from this row.Instruction2Cols
:Instruction2Cols
afterInstruction1Cols
.fib_e2e before this PR(ref):
fib_e2e after this PR(ref):
Proof time of some verifier drops ~30% but others keep same. I'm surprised
halo2_outer
proof time increases because the number column decreases.