Skip to content

Conversation

@Leo-Besancon
Copy link
Collaborator

@Leo-Besancon Leo-Besancon commented Sep 17, 2025

Describe your changes

This PR aims to close #450.

It became the tracking branch for Plonky3 Codegen related features.

Tasklist:

  • Setup main codegen pipeline
  • Add E2E test pipeline (for binary test)
  • Test the generated code (by proving / verifying the program with a provided trace)
  • Handle all AirScript features relative to main trace
    • Main Boundary constraints
    • Main Transition constraints
    • Public inputs (fixed-lengths)
    • Periodic columns
      • Traits AirBuilderWithPeriodicColumns and BaseAirWithPeriodicColumns
      • implement it on a wrapper struct DebugConstraintBuilderWithPeriodicColumns
      • implement helper check_constraints_with_periodic_columns to check the constraints are valid for a given trace
      • implement the traits for upstream structs needed for prove and verify moved to a followup: feat: prove/verify and sync plonky3 #523
  • Add all other E2E tests (note: for E2E relying on buses, I generated the main constraints)
  • Aux trace handling

Copy link
Contributor

@adr1anh adr1anh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a quick sneak peek, but this is great already! Left two small comments about the codegen.

@Leo-Besancon Leo-Besancon marked this pull request as ready for review September 26, 2025 07:35
Copy link
Contributor

@adr1anh adr1anh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good! Just left some minor comments which can be addressed in a follow-up PR.

pub trait AirBuilderWithPeriodicColumns: AirBuilder {
type PeriodicColumnsVar: Field + Into<Self::Expr>;

fn periodic_columns(&self) -> Vec<Self::PeriodicColumnsVar> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also return a slice here which we can cast to an array.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is more complicated issue though, since I see below that we're using this to make testing easier.

{
type PeriodicColumnsVar = F;

fn periodic_columns(&self) -> Vec<Self::PeriodicColumnsVar> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While maybe not for this PR, I think we can represent periodic_columns in the DebugConstraintBuilderWithPeriodicColumns struct a bit differently

  • Pad all periodic columns to the maximum length by periodic repetition
  • Transpose the columns so that we have a vector of rows.
  • We just return &self.periodic_columns[self.row_index % col.len()]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! I've created an issue to do this in a followup: #492

Copy link
Contributor

@adr1anh adr1anh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@bobbinth bobbinth requested a review from Al-Kindi-0 October 17, 2025 15:15
Copy link
Collaborator

@Al-Kindi-0 Al-Kindi-0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!
Support and testing for periodic columns and buses will come in a follow up PR once we agree on how our version of P3 backend will look like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Plonky3 AirBuilder main trace constraints code generation

4 participants