0xMiden / 0xMiden/air-script

[Plonky3 Codegen] Expression de-duplication in generated constraints

未关闭
#534 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Rust
星标
96
派生
39
PR 合并指标
30 天内没有已合并 PR

描述

When compiling the MidenVM constraints currently done towards the Plonky3 backend, the generated constraints represent ~70 individual constraints.
However, the RPO constraints are written in a way that makes it hard to load (one constraint being represented with 1 line of 80k+ caracters).

We should maybe better optimize some expressions. For instance, we could improve the Common SubExpression Elimination: currently, it deduplicates nodes in the algebraic graph, but the codegen duplicates the generated Rust code back.

Using Rust `let` statements when a node is duplicated (maybe with some stricter conditions such as "this node should be referenced more than 10 times in the graph to have a dedicated let statement") would certainly improve readability.

The main issue I think would be that the variable names would probably not be made easily readable.

贡献指南

打开贡献指南

调研方向

Look at the Plonky3 codegen in the MidenVM constraints generation, focusing on the algebraic graph and Common SubExpression Elimination (CSE). The goal is to deduplicate expressions in generated Rust code by introducing `let` statements for frequently referenced nodes. Start by examining the codegen module to understand how constraints are currently emitted and where CSE is applied. Check for conditions to decide when to create a `let` statement (e.g., node referenced more than 10 times). The outcome should improve readability by reducing duplication in the generated Rust code.

由索引模型根据 Issue 内容生成。

评估

技术栈
rust
领域
compilers
Issue 类型
重构
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。