Skip to content
Draft
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
82d7aea
Conversion.
chriseth Nov 13, 2025
7cd68ef
Simple solve constraint.
chriseth Nov 13, 2025
828c687
Simplify variable type.
chriseth Nov 13, 2025
a432b7c
Use indexed system.
chriseth Nov 13, 2025
8e796e7
Use info for timing.
chriseth Nov 13, 2025
cdb5036
Add bus interactions and range constraints
chriseth Nov 14, 2025
f1958e1
Discover boolean range constraints.
chriseth Nov 14, 2025
337415f
Add all expressions that are lacking a single variable.
chriseth Nov 14, 2025
419f9d5
Try to split out single variables.
chriseth Nov 14, 2025
55aa610
Extract single variable.
chriseth Nov 14, 2025
d171dc8
Compute quadratic equivalences.
chriseth Nov 18, 2025
d78c3eb
Derive quadratic equivalences.
chriseth Nov 18, 2025
2567cfb
Disable quadratic equivalences.
chriseth Nov 18, 2025
c95b6a7
Use real range constraints.
chriseth Nov 18, 2025
062a668
Apply substitutions.
chriseth Nov 18, 2025
6cd680f
Some performance fixes.
chriseth Nov 18, 2025
2e787b4
Cleanup.
chriseth Nov 19, 2025
868dbda
Make range constraints copy.
chriseth Nov 19, 2025
bd0930f
Cleanup.
chriseth Nov 19, 2025
1dca1dc
Improve var diff check.
chriseth Nov 19, 2025
6321c41
Add some tests.
chriseth Nov 19, 2025
671fda3
Fix warnings.
chriseth Nov 19, 2025
45b71e6
Test.
chriseth Nov 19, 2025
25f270d
Provide range constraints from the start.
chriseth Nov 19, 2025
a2d765a
fix compile.
chriseth Nov 19, 2025
15b0ee7
Fix performance problem and re-enable quadratic equiv.
chriseth Nov 19, 2025
3f82d4c
Fix performance issue.
chriseth Nov 19, 2025
78b2842
Do not actually substitute assignments.
chriseth Nov 20, 2025
db29380
Update expectations.
chriseth Nov 20, 2025
32c1e1d
Merge remote-tracking branch 'origin/main' into explore_crepe
chriseth Nov 20, 2025
58f8e69
Combine free variables, WIP.
chriseth Nov 20, 2025
73a21ae
Iterate and cleanup.
chriseth Nov 24, 2025
4c7c2cd
Make deterministic and cleanup.
chriseth Nov 24, 2025
306adb3
Add size limit and update expectations.
chriseth Nov 24, 2025
80c10f8
Update expectations.
chriseth Nov 24, 2025
9c15698
Give access to column allocator.
chriseth Nov 25, 2025
44dbb40
Remove clone.
chriseth Nov 25, 2025
90e5163
Replace computation method "InverseOrZero" by "QuotientOrZero".
chriseth Nov 25, 2025
fdc6a33
Merge remote-tracking branch 'origin/quotient_or_zero' into explore_c…
chriseth Nov 26, 2025
3859127
Merge remote-tracking branch 'origin/column_allocator_for_constraint_…
chriseth Nov 26, 2025
533948e
Update comment.
chriseth Nov 26, 2025
a72e4f9
Trying to make it work.
chriseth Nov 26, 2025
b44a4b0
Fix clippy.
chriseth Nov 26, 2025
e1c1af5
Merge remote-tracking branch 'origin/main' into explore_crepe
chriseth Nov 26, 2025
fc42bfa
Move rules to a later point and update expectations.
chriseth Nov 27, 2025
4bebcb6
Use generic crepe.
chriseth Nov 27, 2025
4fdfde4
Simplify generic parameter of ExpressionDB.
chriseth Nov 27, 2025
dc32b16
Rename system to environment.
chriseth Nov 27, 2025
546482c
Update expectations.
chriseth Nov 27, 2025
aed745e
Combine non-negative factors.
chriseth Nov 28, 2025
bc3e6b7
Add comment.
chriseth Nov 28, 2025
8e3aef9
Update expectations.
chriseth Nov 28, 2025
391e983
Unify expression and variable db.
chriseth Nov 28, 2025
81a4ead
remove accidentally added file.
chriseth Nov 28, 2025
81d4f18
Clippy.
chriseth Nov 28, 2025
ac056c3
Cleanup
chriseth Nov 28, 2025
805010d
Simplify.
chriseth Dec 1, 2025
fc24975
Allow quadratic substitution below degree bound.
chriseth Dec 1, 2025
707366d
Implement degree bound properly and update expectations.
chriseth Dec 1, 2025
b63bc22
Update expectations.
chriseth Dec 1, 2025
a5c1ac3
Inform solver about equivalences and disable equivalence search in th…
chriseth Dec 1, 2025
1a99323
Optimize rules.
chriseth Dec 2, 2025
eda63eb
Optimize rules.
chriseth Dec 2, 2025
35f54c8
Range constraints from bus interactions.
chriseth Dec 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions autoprecompiles/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ rayon = "1.10.0"
strum = { version = "0.27.0", features = ["derive"] }

metrics = "0.23.0"
crepe = { git = "https://github.com/chriseth/crepe", branch = "generics", version = "0.1.8" }

[dev-dependencies]
expect-test = "1.5.1"

[package.metadata.cargo-udeps.ignore]
development = ["env_logger"]
Expand Down
10 changes: 10 additions & 0 deletions autoprecompiles/src/constraint_optimizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use crate::{
low_degree_bus_interaction_optimizer::LowDegreeBusInteractionOptimizer,
memory_optimizer::{optimize_memory, MemoryBusInteraction},
range_constraint_optimizer::RangeConstraintHandler,
rule_based_optimizer::rule_based_optimization,
stats_logger::StatsLogger,
};

Expand Down Expand Up @@ -57,6 +58,7 @@ pub fn optimize_constraints<
stats_logger: &mut StatsLogger,
memory_bus_id: Option<u64>,
degree_bound: DegreeBound,
new_var: &mut impl FnMut(&str) -> V,
) -> Result<ConstraintSystem<P, V>, Error> {
// Index the constraint system for the first time
let constraint_system = IndexedConstraintSystem::from(constraint_system);
Expand All @@ -81,6 +83,14 @@ pub fn optimize_constraints<
stats_logger,
);

let constraint_system = rule_based_optimization(
constraint_system,
&*solver,
bus_interaction_handler.clone(),
new_var,
);
stats_logger.log("rule-based optimization", &constraint_system);

// At this point, we throw away the index and only keep the constraint system, since the rest of the optimisations are defined on the system alone
let constraint_system: ConstraintSystem<P, V> = constraint_system.into();

Expand Down
1 change: 1 addition & 0 deletions autoprecompiles/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ mod stats_logger;
pub mod symbolic_machine_generator;
pub use pgo::{PgoConfig, PgoType};
pub use powdr_constraint_solver::inliner::DegreeBound;
pub mod rule_based_optimizer;
pub mod trace_handler;

#[derive(Clone)]
Expand Down
13 changes: 12 additions & 1 deletion autoprecompiles/src/optimizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub fn optimize<A: Adapter>(
bus_interaction_handler: A::BusInteractionHandler,
degree_bound: DegreeBound,
bus_map: &BusMap<A::CustomBusTypes>,
column_allocator: ColumnAllocator,
mut column_allocator: ColumnAllocator,
) -> Result<(SymbolicMachine<A::PowdrField>, ColumnAllocator), crate::constraint_optimizer::Error> {
let mut stats_logger = StatsLogger::start(&machine);

Expand All @@ -44,7 +44,17 @@ pub fn optimize<A: Adapter>(
stats_logger.log("exec bus optimization", &machine);
}

let mut new_var = |name: &str| {
let id = column_allocator.issue_next_poly_id();
AlgebraicReference {
// TODO is it a problem that we do not check the name to be unique?
name: format!("{name}_{id}").into(),
id,
}
};

let mut constraint_system = symbolic_machine_to_constraint_system(machine);

let mut solver = new_solver(constraint_system.clone(), bus_interaction_handler.clone());
loop {
let stats = stats_logger::Stats::from(&constraint_system);
Expand All @@ -55,6 +65,7 @@ pub fn optimize<A: Adapter>(
&mut stats_logger,
bus_map.get_bus_id(&BusType::Memory),
degree_bound,
&mut new_var,
)?
.clone();
if stats == stats_logger::Stats::from(&constraint_system) {
Expand Down
Loading
Loading