Commit Graph

443 Commits

Author SHA1 Message Date
ShuangWu121
2e978667b2 Update stwo dependency to the latest version (#2264)
### PR: Update Powdr's `stwo` Dependency and Align Toolchain

This PR updates Powdr's `stwo` dependency to the latest version, which
now uses the `nightly-2024-12-17` Rust toolchain. To ensure
compatibility, Powdr's toolchain has also been aligned with this new
nightly version.

As part of this update:
- Several modifications were made to address stricter rules and lints
introduced by the newer version of Clippy.
- System dependencies, including `uuid-dev` and `libgrpc++-dev`, were
added to resolve build and runtime issues brought about by updated
dependencies and toolchain requirements.
2024-12-23 11:48:52 +00:00
Georg Wiese
6151081063 Fixes in Goldilocks field implementation (#2277)
Pulled out of #2276. Needed to make the code generated for the Binary
machine compile.
2024-12-20 21:08:29 +00:00
chriseth
c1b776312a use can_process (#2256)
Co-authored-by: Georg Wiese <georgwiese@gmail.com>
2024-12-20 13:31:41 +00:00
Georg Wiese
550a1e680a Log JIT statistics (#2273)
Currently, it is hard to know for which machines the WitJITGen worked.
With this PR, we can see it in the debug log:

```
$ POWDR_JIT_OPT_LEVEL=1 RUST_LOG=debug cargo run pil test_data/std/poseidon_gl_test.asm -o output -f
...
[00:00:10 (ETA: 00:00:00)] ████████████████████ 100% - Starting...                                          Finalizing VM: Main machine (Dynamic)
Secondary machine 0: main_poseidon (BlockMachine): 5 / 5 blocks computed via JIT.
155 of 256 rows are used in machine 'Secondary machine 0: main_poseidon (BlockMachine)'.

 == Witgen profile (532 events)
   96.9% (   10.4s): JIT-compilation
    2.5% ( 268.6ms): Secondary machine 0: main_poseidon (BlockMachine)
    0.5% (  56.3ms): witgen (outer code)
    0.1% (   8.7ms): Main machine (Dynamic)
    0.0% (   3.2ms): FixedLookup
    0.0% (   2.1µs): range constraint multiplicity witgen
  ---------------------------
    ==> Total: 10.75908525s

$ cargo run -r --features plonky3 --bin powdr-rs compile riscv/tests/riscv_data/keccak -o output --max-degree-log 18 --field gl --coprocessors arith
...
$ cargo run -r --features plonky3 pil output/keccak.asm -o output -f --field gl --prove-with mock --linker-mode bus
...
[00:00:15 (ETA: 00:00:00)] ████████████████████ 100% - 94652 rows/s, 12304k identities/s, 100% progress     Finalizing VM: Main machine (Dynamic)
Machine Secondary machine 0: main_arith (BlockMachine) is never used at runtime, so we remove it.
Secondary machine 1: main_binary (BlockMachine): 0 / 50462 blocks computed via JIT.
201848 of 262144 rows are used in machine 'Secondary machine 1: main_binary (BlockMachine)'.
40180 of 65536 rows are used in machine 'Secondary machine 2: main_memory (DoubleSortedWitnesses32)'.
Secondary machine 3: main_poseidon_gl (BlockMachine): 0 / 1 blocks computed via JIT.
31 of 32 rows are used in machine 'Secondary machine 3: main_poseidon_gl (BlockMachine)'.
362234 of 524288 rows are used in machine 'Secondary machine 5: main_regs (DoubleSortedWitnesses32)'.
Secondary machine 6: main_shift (BlockMachine): 0 / 11734 blocks computed via JIT.
46936 of 65536 rows are used in machine 'Secondary machine 6: main_shift (BlockMachine)'.
Secondary machine 7: main_split_gl (BlockMachine): 0 / 7 blocks computed via JIT.
56 of 64 rows are used in machine 'Secondary machine 7: main_split_gl (BlockMachine)'.

 == Witgen profile (2554854 events)
   48.7% (    8.0s): Secondary machine 1: main_binary (BlockMachine)
   18.4% (    3.0s): Main machine (Dynamic)
   12.4% (    2.0s): Secondary machine 6: main_shift (BlockMachine)
   10.5% (    1.7s): FixedLookup
    6.1% ( 999.6ms): Secondary machine 5: main_regs (DoubleSortedWitnesses32)
    2.5% ( 404.6ms): witgen (outer code)
    0.7% ( 114.5ms): Secondary machine 7: main_split_gl (BlockMachine)
    0.5% (  78.8ms): Secondary machine 3: main_poseidon_gl (BlockMachine)
    0.3% (  54.9ms): Secondary machine 2: main_memory (DoubleSortedWitnesses32)
    0.0% (   5.0ms): range constraint multiplicity witgen
    0.0% (   9.4µs): Secondary machine 4: main_publics (WriteOnceMemory)
  ---------------------------
    ==> Total: 16.446211875s
```
2024-12-20 12:20:20 +00:00
chriseth
6549bd2f49 Bisect range constraints. (#2270)
This adds a function to range constraints that splits a range constraint
into two disjoint range constraints of roughly the same size that equal
the initial range constraint when combined.

This function is planned to be used for branching in autowitjitgen.
2024-12-20 10:48:18 +00:00
chriseth
d5c8a1ef87 Not-concrete-is-unknown eval (#2261) 2024-12-19 16:38:20 +00:00
chriseth
a2a67a6264 Support machine calls. (#2241)
Depends on #2244
2024-12-19 16:35:19 +00:00
chriseth
309279ac8a Extract effect and sub-types into its own module. (#2266) 2024-12-19 14:27:25 +00:00
Georg Wiese
a737ed851f Call JIT (#2242)
This PR puts together the pieces to run compile-time witgen for block
machines. There are still many cases where it doesn't work yet, in which
case it falls back to run-time solving. These cases should be fixed in
future PRs.

It also fixes two bugs:
- When multiplying two affine expression, the case where one of them is
zero is now handled properly.
- `WitgenInference` now handles intermediate columns.

Note that this PR could slow down witgen by attempting to compile code
once per incoming connection and input / output combination, in block
machines. I think this should be negligible though and it gives us that
much of the new pipeline is already running in the tests and elsewhere.

# Benchmark results

I tested the code with different opt levels on a benchmark that computes
ca. $2^{16}$ Poseidon hashes.

## Baseline

```
 == Witgen profile (393220 events)
   93.0% (   30.8s): Secondary machine 0: main_poseidon (BlockMachine)
    4.1% (    1.4s): witgen (outer code)
    2.3% ( 750.8ms): Main machine (Dynamic)
    0.6% ( 204.4ms): FixedLookup
    0.0% (   3.2µs): range constraint multiplicity witgen
  ---------------------------
    ==> Total: 33.109672458s
```

## JIT (opt level 1)

```
 == Witgen profile (393222 events)
   52.3% (    7.7s): JIT-compilation
   32.0% (    4.7s): Secondary machine 0: main_poseidon (BlockMachine)
    9.2% (    1.3s): witgen (outer code)
    5.1% ( 748.3ms): Main machine (Dynamic)
    1.4% ( 213.5ms): FixedLookup
    0.0% ( 417.0ns): range constraint multiplicity witgen
  ---------------------------
    ==> Total: 14.729149333s
```

## JIT (opt level 3)

```
== Witgen profile (393222 events)
   94.6% (  107.9s): JIT-compilation
    3.4% (    3.9s): Secondary machine 0: main_poseidon (BlockMachine)
    1.1% (    1.3s): witgen (outer code)
    0.7% ( 746.5ms): Main machine (Dynamic)
    0.2% ( 204.1ms): FixedLookup
    0.0% ( 542.0ns): range constraint multiplicity witgen
  ---------------------------
    ==> Total: 114.036571291s
```
2024-12-18 20:27:49 +00:00
chriseth
89a01a4e8b "can process fully" (#2255)
Add a function to the Machine trait that can be used to determine if a
submachine call with certain known inputs and certain range constraints
can be fully processed by the called machine.

---------

Co-authored-by: Georg Wiese <georgwiese@gmail.com>
2024-12-18 19:33:37 +00:00
chriseth
1b58d1e18a Introduce concept of assignment. (#2244) 2024-12-18 19:21:48 +00:00
chriseth
18f6da0c47 Specialized code for goldilocks. (#2253)
This is mostly a reduced copy of the goldilocks implementation we
already have with the main difference that the division tries to perform
integer division first if it can be done without remainder.
2024-12-18 19:09:51 +00:00
chriseth
d98b7ebb58 Fix bit operations. (#2249)
This fixes a bug in witjitgen where the bit operations used for masking
in bit-decomposition would use field elements as types for the masks.
The problem is that we sometimes mask using masks outside the field and
the proper type for masks is FieldElement::Integer.
2024-12-18 13:56:29 +00:00
chriseth
bdfa4e1102 Use truncate instead of pop. (#2247) 2024-12-18 13:07:28 +00:00
chriseth
3889799528 Profile jit compilation separately. (#2248) 2024-12-18 13:06:27 +00:00
chriseth
a3d9f38682 Implement Neg for FieldElement. (#2252) 2024-12-18 12:44:18 +00:00
taikoon
1a9c99d232 chore: remove duplicate words (#2227) 2024-12-18 12:14:36 +00:00
Georg Wiese
e2131f501f Block machine processor (#2226)
This PR adds a basic block machine processor. Currently, we assume a
rectangular block shape and just iterate over all rows and identities of
the block until no more progress is made. This is sufficient to generate
code for Poseidon.
2024-12-17 13:31:03 +00:00
chriseth
a68a20c9a4 Effects to rust (#2229)
Formats a vector of "effects" coming from the witgen solver into rust
code, compiles and loads it.

Submachine calls and receiving arguments will be done in another PR.

This code assumes `known` to be a padded bit vector ( #2230 ).

---------

Co-authored-by: Georg Wiese <georgwiese@gmail.com>
2024-12-17 10:41:04 +00:00
Georg Wiese
d007b8f145 Prepare block machine processor (#2231)
A few preparations for #2226:
- Extracted a `test_utils` module
- Introduced a new `Variable` type, which can refer to either a cell or
a "parameter" (either input or output of a machine call). I think in the
future, we could have more variants (e.g. scalar publics). `Variable` is
now used instead of `Cell` in `WitgenInference`.
- `WitgenInference::process_identity` now also returns whether any
progress has been made.
- Renamed `lookup` -> `machine_call` when rendering `Effect`s
2024-12-16 13:53:10 +00:00
chriseth
e5f9392010 Use padded bitvec. (#2230) 2024-12-16 10:49:30 +00:00
chriseth
12aca0e136 Various preparatory changes. (#2228) 2024-12-12 17:56:54 +00:00
chriseth
e3c4c858f0 Witgen inference. (#2219)
This PR adds a component that can derive assignments and other code on
identities and multiple rows. It keeps track of which cells in the trace
are already known and which not. The way to access fixed rows is
abstracted because it does not have a concept of an absolute row. While
this might work for block machines with cyclic fixed columns, it does
not work in the general case.

What it does not do:
- have a sequence of which identities to consider on which rows
- a mechanism that determines when it is finished

---------

Co-authored-by: Georg Wiese <georgwiese@gmail.com>
2024-12-12 16:12:30 +00:00
chriseth
2aa7f8388c Prepare to call jit from block machine. (#2098)
This PR performs preliminary preparations in the block machine so that
it will be able to JIT-compile and evaluate lookups into this machine
given a certain combination of "known inputs".

---------

Co-authored-by: Georg Wiese <georgwiese@gmail.com>
2024-12-12 11:58:23 +00:00
chriseth
598352a23d Expressions and solving routines. (#2212)
This module is an equivalent of the existing affine_expression.rs, but
for compile-time execution on symbolic values instead of run-time
execution on concrete values.

Using the operators defined on that that type, you can build a
SymbolicAffineExpression from a polynomial identity and then use
`.solve()` to try to solve for one unknown variable. The result (instead
of a concrete assignment as in affine_expression.rs) is a
SymbolicExpression, i.e. a complex expression involving variables
(assumed to have a concrete value known at run time), constants and
certain operators on them.

The idea is that SymbolicAffineExpression is used on polynomial
identities in turn and solving for one cell after the other in the
trace. The resulting SymbolicExpression can be translated to rust or
pil.
2024-12-11 17:06:18 +00:00
Georg Wiese
0180542559 Refactorings around process_lookup_direct (#2209)
This PR refactors a few things:
- `process_lookup_direct` no longer has a default implementation.
Eventually, we want all machines to implement it, so I figured it would
be better to explicitly panic in each machine.
- Refactored the implementation of
`FixedLookupMachine::process_plookup`, pulling some stuff out into a new
`CallerData` struct. This is similar to what @chriseth has done on
[`call_jit_from_block`](https://github.com/powdr-labs/powdr/compare/main...call_jit_from_block),
see the comment below.
- As a first test, I implemented `process_lookup_direct` for the
"large"-field memory machine (and `process_plookup` by wrapping
`process_lookup_direct`)
2024-12-10 16:44:15 +00:00
Georg Wiese
e286da46f7 Bus: Remove acc_next + materialize folded tuple (#2201)
This PR:
- Removes the `acc_next` columns, which were only needed because of a
limitation of prover functions. The prover function that existed is now
removed entirely, because we use the hand written witgen anyway, see
#2191.
- Also this PR materializes the folded tuple. This lowers the degree of
the constraints if the tuples being sent have a degree > 1. It also
enables next references in the tuple being sent.

As a result, we can now generate Plonky3 proofs with a bus!

```bash
cargo run -r --features plonky3 --bin powdr-rs compile riscv/tests/riscv_data/keccak -o output --max-degree-log 18 --field gl
cargo run -r --features plonky3 pil output/keccak.asm -o output -f --field gl --prove-with plonky3 --linker-mode bus
```

The proof generation takes 8.32s (of which 394ms are spent on generating
the second-stage witness). This compares to 2.07s proof time without a
bus.
2024-12-09 18:12:33 +00:00
Thibaut Schaeffer
576bdd714d Disallow iteration over hash types (#2167)
Iterating over hash types introduces non-determinism.
Ban generally and require turning off the lint locally when it's fine to
do so.
This
[lint](https://rust-lang.github.io/rust-clippy/master/index.html#/iter_over_hash_type)
only applies to loops.
2024-12-09 15:47:54 +00:00
Georg Wiese
ee7cf29c8e Implement process_lookup_direct for KnownMachine & change interface slightly (#2206)
Extracted out of #2071
2024-12-09 13:58:02 +00:00
Georg Wiese
dbc53c76a6 Hand-written bus witness generation (#2191)
Builds on #2194 and #2183.

This PR gives us (relatively) fast witness generation for the bus, by
writing custom code instead of relying on the generic solver + prover
functions:
```
$ cargo run -r --features plonky3 --bin powdr-rs compile riscv/tests/riscv_data/keccak-o output --max-degree-log 18 --field gl
$ cargo run -r --features plonky3 pil output/$TEST.asm -o output -f --field gl --prove-with mock --linker-mode bus
...
Running main machine for 262144 rows
[00:00:05 (ETA: 00:00:05)] █████████░░░░░░░░░░░ 48% - 24283 rows/s, 3169k identities/s, 92% progress                                    
Found loop with period 1 starting at row 127900
[00:00:05 (ETA: 00:00:00)] ████████████████████ 100% - 151125 rows/s, 16170k identities/s, 100% progress                                
Witness generation took 5.748081s
Writing output/commits.bin.
Backend setup for mock...
Setup took 0.54769236s
Generating later-stage witnesses took 0.29s
Proof generation took 2.0383847s
```

On `main`, second-stage witgen for the main machine alone takes about 5
minutes.
2024-12-09 13:35:23 +00:00
Georg Wiese
8a3e33e07c Add a simpler ExpressionEvaluator (#2194)
This PR:
- Renames the current `executor::witgen::ExpressionEvaluator` to
`executor::witgen::evaluators::partial_expression_evaluator::PartialExpressionEvaluator`
- It is used when solving and evaluates to a
`AffineResult<AlgebraicVariable<'a>, T>`, which might still contain
unknown variables.
- Adds a new `ExpressionEvaluator` that simply evaluates to `T`
- Changes `MockBackend` to use the new `ExpressionEvaluator` (previously
wrapped what is now called the `PartialExpressionEvaluator`)

As a result, the code in `MockBackend` can be simplified. Also, I'm
building on this in #2191 for fast witness generation for the bus.
2024-12-09 11:33:42 +00:00
chriseth
f1a0c1feed Paged memory (#2205)
Change memory machine to use pages instead of a "flat" map.
2024-12-09 10:51:42 +00:00
Georg Wiese
3b45173c4b Add PhantomBusInteraction (#2183)
This PR adds a `Constr:: PhantomBusInteraction` variant. For now, it is
ignored - if users want to use a bus, they need to express this in terms
of phantom lookups / permutations as before this PR.

I added a few `TODO(bus_interaction)` and opened #2184 to track support
for phantom bus interactions.

One use-case this could have before though is to trigger a
"hand-written" witness generation for the bus, as discussed in the chat.
2024-12-06 17:21:42 +00:00
Georg Wiese
4c5caae8f6 Better error message if things go wrong in machine extraction (#2142)
I tried to debug why the RISC-V machine doesn't work with `--linker-mode
bus` yet, and this adds helpful error messages.
2024-12-04 11:24:10 +00:00
Leo
f11cf21a11 Revert "Parallelize calls to prover functions (#2176)" (#2188)
This reverts commit d980c68f89 from
https://github.com/powdr-labs/powdr/pull/2176
2024-12-03 10:17:54 +00:00
Georg Wiese
2832ff108b Fix second stage witgen (#2173)
Builds on #2169

With this PR, second-stage witness generation works for the bus used in
the RISC-V machine 🎉

This is an end-to-end test:
```bash
cargo run -r --bin powdr-rs compile riscv/tests/riscv_data/sum-o output --max-degree-log 15 --field gl
cargo run -r pil output/sum.asm -o output -f --field gl --prove-with mock --linker-mode bus -i 1,1,1
```

What's needed is two small changes to `VmProcessor`:
- The degree is now passed by the caller (`DynamicMachine` or
`SecondStageMachine`). That way, `SecondStageMachine` can set it to the
actual final size, instead of the maximum allowed degree.
- I disabled loop detection for second-stage witness generation for now.
2024-11-29 18:16:02 +00:00
Georg Wiese
d980c68f89 Parallelize calls to prover functions (#2176)
Cherry-picked from #2174

With this PR, we run all prover functions in parallel when solving for
the witness in `VmProcessor`. Interestingly, this didn't require any
changes to the order in which things are done: We already ran the
functions independently and applied the combined updates. So, this is a
classic map-reduce.

I think this change always makes sense, but is especially useful for the
prover functions we have to set bus accumulator values. For example, in
our RISC-V machine, the main machine has ~30 bus interactions, with a
fairly expensive prover function for each.

When used on top of #2173 and #2175, this accelerates second-stage
witness generation for the main machine from ~10s to ~6s for the example
mentioned in #2173.
2024-11-29 17:14:33 +00:00
Georg Wiese
6530820ae8 Introduce SecondStageMachine (#2169)
This introduces a new machine which is always used for the second-stage
witness generation. Currently it is a copy of DynamicMachine, but in the
end it will be optimized for second-stage witness generation.
2024-11-29 16:42:19 +00:00
Thibaut Schaeffer
c0fefae3e7 Introduce workspace-level lints (#2166)
Reduce the cost of adding a lint from O(#workspace_crates) to 1.
2024-11-29 14:02:53 +00:00
Georg Wiese
0d67ef1d21 Improve error messages for connection errors in MockBackend (#2153)
With this PR, we get much better error messages for connection errors.

This is an example of an issue we're currently debugging:
```
$ cargo run -r pil test_data/std/keccakf16_memory_test.asm -o output -f --prove-with mock --export-witness-csv
...
Errors in 50 / 213 connections:
Connection failed between main_keccakf16_memory and main_memory:
    main_keccakf16_memory::sel[0] * main_keccakf16_memory::step_flags[0] $ [0, main_keccakf16_memory::input_addr_h, main_keccakf16_memory::input_addr_l, main_keccakf16_memory::time_step, main_keccakf16_memory::preimage[3], main_keccakf16_memory::preimage[2]] is main_memory::selectors[2] $ [main_memory::m_is_write, main_memory::m_addr_high, main_memory::m_addr_low, main_memory::m_step_high * 65536 + main_memory::m_step_low, main_memory::m_value1, main_memory::m_value2];
  The following tuples appear in main_memory, but not in main_keccakf16_memory:
    Row 24: (0, 0, 0, 32, 0, 0)

Connection failed between main_keccakf16_memory and main_memory:
    main_keccakf16_memory::sel[0] * main_keccakf16_memory::step_flags[0] $ [0, main_keccakf16_memory::addr_h[0], main_keccakf16_memory::addr_l[0], main_keccakf16_memory::time_step, main_keccakf16_memory::preimage[1], main_keccakf16_memory::preimage[0]] is main_memory::selectors[3] $ [main_memory::m_is_write, main_memory::m_addr_high, main_memory::m_addr_low, main_memory::m_step_high * 65536 + main_memory::m_step_low, main_memory::m_value1, main_memory::m_value2];
  The following tuples appear in main_memory, but not in main_keccakf16_memory:
    Row 24: (0, 0, 4, 32, 0, 0)

Connection failed between main_keccakf16_memory and main_memory:
    main_keccakf16_memory::sel[0] * main_keccakf16_memory::step_flags[0] $ [0, main_keccakf16_memory::addr_h[1], main_keccakf16_memory::addr_l[1], main_keccakf16_memory::time_step, main_keccakf16_memory::preimage[7], main_keccakf16_memory::preimage[6]] is main_memory::selectors[4] $ [main_memory::m_is_write, main_memory::m_addr_high, main_memory::m_addr_low, main_memory::m_step_high * 65536 + main_memory::m_step_low, main_memory::m_value1, main_memory::m_value2];
  The following tuples appear in main_memory, but not in main_keccakf16_memory:
    Row 24: (0, 0, 8, 32, 0, 0)

Connection failed between main_keccakf16_memory and main_memory:
    main_keccakf16_memory::sel[0] * main_keccakf16_memory::step_flags[0] $ [0, main_keccakf16_memory::addr_h[2], main_keccakf16_memory::addr_l[2], main_keccakf16_memory::time_step, main_keccakf16_memory::preimage[5], main_keccakf16_memory::preimage[4]] is main_memory::selectors[5] $ [main_memory::m_is_write, main_memory::m_addr_high, main_memory::m_addr_low, main_memory::m_step_high * 65536 + main_memory::m_step_low, main_memory::m_value1, main_memory::m_value2];
  The following tuples appear in main_memory, but not in main_keccakf16_memory:
    Row 24: (0, 0, 12, 32, 0, 1)

Connection failed between main_keccakf16_memory and main_memory:
    main_keccakf16_memory::sel[0] * main_keccakf16_memory::step_flags[0] $ [0, main_keccakf16_memory::addr_h[3], main_keccakf16_memory::addr_l[3], main_keccakf16_memory::time_step, main_keccakf16_memory::preimage[11], main_keccakf16_memory::preimage[10]] is main_memory::selectors[6] $ [main_memory::m_is_write, main_memory::m_addr_high, main_memory::m_addr_low, main_memory::m_step_high * 65536 + main_memory::m_step_low, main_memory::m_value1, main_memory::m_value2];
  The following tuples appear in main_memory, but not in main_keccakf16_memory:
    Row 24: (0, 0, 16, 32, 0, 0)

... and 45 more errors

thread 'main' panicked at cli/src/main.rs:727:14:
called `Result::unwrap()` on an `Err` value: ["Constraint check failed"]
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
2024-11-27 10:33:24 +00:00
Georg Wiese
51a7349fc1 Fail hard for invalid memory accesses (#2158)
This would have caught #2157.
2024-11-27 08:42:30 +00:00
Georg Wiese
43061cf17b Bug fix: Fix intermediates cache for next references (#2151)
Fixes a bug in witgen & the Plonky3 backend regarding caching of values
of intermediate columns: We ignored the next operator.
2024-11-26 14:40:12 +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
Georg Wiese
132dc100b8 FixedData::polynomial_references: Cache results for intermediate columns (#2149)
Fixes a performance issue with intermediate polynomials.
2024-11-26 10:39:57 +00:00
Georg Wiese
99d9dd0fc4 WriteOnceMemory: Generate multiplicity column (#2148)
Instances of `WriteOnceMemory` did not yet generate the multiplicity
column when connected via a phantom lookup.
2024-11-26 08:52:11 +00:00
Georg Wiese
34f765d9e8 Remove range constraint multiplicity columns from main machine (#2147)
Multiplicity columns of *global* range constraints used to end up in the
main machine, which is a problem if it has a length different from the
range check machine.
2024-11-26 08:51:54 +00:00
chriseth
2a3f989c12 Move vm processor (#2136)
Co-authored-by: Georg Wiese <georgwiese@gmail.com>
2024-11-26 07:07:51 +00:00
Georg Wiese
cd07dfb660 Filter later-stage witnesses and identities (#2129)
Prepares #2129

With this PR, later-stage witness columns & identities referencing them
(or later-stage challenges) are completely ignored. The columns are not
assigned to any machine. Previously, they would end up in the main
machine and never receive any updates. That doesn't work if machines
have different sized though.

---------

Co-authored-by: Thibaut Schaeffer <schaeffer.thibaut@gmail.com>
2024-11-25 15:20:42 +00:00
chriseth
81517d0294 Remove 'b lifetime. (#2135) 2024-11-23 13:20:25 +00:00
chriseth
81196aea3e Improve MutableState / Machines (#2130)
MutableState is the main way to get access to sub-machines during
witness generation. We used to create copies of MutableState for each
lookup, extracting the "current machine" where we need mutable access
and creating copies of references to the other machines. This causes an
allocation for each lookup (including fixed lookups, I think) which is
bad for performance.

This PR changes the approach to use RefCell instead: MutableState now
owns the machines and for each call to a machine, we mutably borrow that
machine. The RefCell mechanism ensures that there are no recursive calls
to machines and also avoids allocations.

I also changed the query callback to use non-mut references.

The first and third commits only move code around.
2024-11-22 17:28:03 +00:00