9 Commits

Author SHA1 Message Date
Steve Wang
8090b3a9d5 Stage 1 public reference (#2567)
Depends on #2556. Pass stage 1 publics to the backend but not using them
yet (TODO for future PR).
2025-03-26 11:00:07 +00:00
Georg Wiese
f1406998bd Fix evaluator for Minus operator (#2360) 2025-01-18 23:48:13 +00:00
chriseth
95dcf385c6 Evaluaton of fixed columns that are constant outside the first and last row. (#2346)
Allows fixed columns to be evaluated in the "single step jit processor"
by pre-computing if a fixed column has a constant value apart from the
first and last row.
2025-01-16 11:43:02 +00:00
Georg Wiese
e328eb90da Do multiplicity witgen in separate stage (#2319)
While working on #2306, @Schaeff came across several bugs in
multiplicity witness generation. These were undetected, because we
ignored multiplicities in the mock prover, which will be fixed by #2310.
With this PR, #2310 will be green.

The issue was that counting multiplicities inside
`Machine::process_plookup()` fails if the caller actually discards the
result. This happens in a few places, for example during our loop
optimization in the "dynamic machine".

With this PR, we instead have a centralized
`MultiplicityColumnGenerator` that counts multiplicities after the fact,
by going over each lookup, evaluating the two selected tuples on all
rows, and counting how often each element in the LHS appears in the RHS.

To measure the runtime of this, I ran:
```sh
export TEST=keccak
export POWDR_JIT_OPT_LEVEL=0

cargo run -r --bin powdr-rs compile riscv/tests/riscv_data/$TEST -o output --max-degree-log 18
cargo run -r --features plonky3,halo2 pil output/$TEST.asm -o output -f --field gl --linker-mode bus
```

I get the following profile on the server:
```
 == Witgen profile (2554126 events)
   32.4% (    2.6s): Secondary machine 0: main_binary (BlockMachine)
   23.1% (    1.9s): Main machine (Dynamic)
   12.7% (    1.0s): Secondary machine 4: main_regs (DoubleSortedWitnesses32)
   10.0% ( 809.9ms): FixedLookup
    7.7% ( 621.1ms): Secondary machine 5: main_shift (BlockMachine)
    5.6% ( 454.6ms): Secondary machine 2: main_poseidon_gl (BlockMachine)
    3.8% ( 312.3ms): multiplicity witgen
    3.8% ( 308.2ms): witgen (outer code)
    0.6% (  45.3ms): Secondary machine 1: main_memory (DoubleSortedWitnesses32)
    0.4% (  33.4ms): Secondary machine 6: main_split_gl (BlockMachine)
    0.0% (   8.0µs): Secondary machine 3: main_publics (WriteOnceMemory)
  ---------------------------
    ==> Total: 8.114630092s
```

So the cost is ~4%. I'm sure it can be optimized further but I would
like to leave this to a future PR.
2025-01-09 14:50:48 +00:00
Georg Wiese
04de307993 Refactor ExpressionEvaluator (#2309)
This is a first step to generalize the expression evaluator. Currently
just merging the `TraceValues` and `GlobalValues` traits, as it seemed a
bit unnecessary to have two of them.

Eventually, I want to have a more generic `ExpressionWalker`, of which
`ExpressionEvaluator` would be a special case. That walker could also be
used to do things like:
- Degree computation
- check if the expression (or any referenced intermediate) has a next
reference

While still preserving the caching behavior, so that we don't run
exponentially long on these operations either!
2025-01-08 09:43:05 +00:00
Georg Wiese
51561798dd Use ExpressionEvaluator more (#2284)
This PR move the `ExpressionEvaluator` to `executor-utils` and
generalizes it such that it can evaluate an `AlgebraicExpression<T>` to
any type, not just `T`. This makes it possible to use the evaluator in
the backends. I used it in Plonky3 and Stwo, which leads to significant
code deletion.

The main feature of `ExpressionEvaluator` is that it handles
intermediate polynomials by caching during evaluation. This is cheaper
than using `Analyzed::identities_with_inlined_intermediate_polynomials`,
which might build exponentially large expressions. The Plonky3
implementation already did the same; The stwo implementation still used
`identities_with_inlined_intermediate_polynomials()` and now handles
intermediates properly.
2024-12-29 20:15:22 +00:00
Thibaut Schaeffer
ad858a1d7d Run cargo bench in PR CI tests and report result to PR and Github Pages (#2198)
Run benchmarks in PRs, fail and warn on the PR if we got more than 20%
slower, add benchmark results to https://docs.powdr.org/dev/bench/
2024-12-09 14:51:20 +00:00
Georg Wiese
99532a6105 Compute later-stage witness by machine (#2122)
With this PR, we compute the later-stage witnesses per machine instead
of globally. This has two advantages:
- We're able to handle machines of different sizes
- We can parallelize later-stage witness generation

This affects the two backend that can deal with multiple machines in the
first place: `Plonky3Backend` and `CompositeBackend`
2024-11-26 14:29:51 +00:00
Leo
51cff4c758 remove powdr-executor dependency from backend-utils and plonky3 (#2124)
To make the plonky3 verifier module simpler for recursion
2024-11-21 13:57:13 +00:00