Skip to content

[Formal][Property Annotation] Annotate Reconvergent-paths using flow variables#716

Draft
Basmet0 wants to merge 33 commits intoEPFL-LAP:mainfrom
Basmet0:invariant-flow
Draft

[Formal][Property Annotation] Annotate Reconvergent-paths using flow variables#716
Basmet0 wants to merge 33 commits intoEPFL-LAP:mainfrom
Basmet0:invariant-flow

Conversation

@Basmet0
Copy link
Collaborator

@Basmet0 Basmet0 commented Jan 27, 2026

Each operation has local properties on how tokens are distributed between inputs and outputs. For example, a join operation expects the same number of tokens coming from each input, and sends them to its output. By extracting all of these local equations from a circuit, and then performing Gaussian elimination, one gets equations that describe properties of paths using only the internal states of the operations, rather than having to keep track of how many tokens are sent across each channel.

Comment on lines +328 to +332
// channel metadata
CPVar i1 = CPVar(llvm::formatv("#x1{0}", getUniqueName(&op)).str(),
VarType::INTEGER);
CPVar i2 = CPVar(llvm::formatv("#x2{0}", getUniqueName(&op)).str(),
VarType::INTEGER);
Copy link
Member

Choose a reason for hiding this comment

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

Here we should describe the model that we assume:

every unit is a cascade of: merge/join/mux -(internal_channel1)-> [slot]* -(internal_channel2)-> fork

Rename i1 -> lambda_internal_channel1

}

LogicalResult
HandshakeAnnotatePropertiesPass::annotateReconvergentPathFlow(ModuleOp modOp) {
Copy link
Member

Choose a reason for hiding this comment

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

Split this function into multiple smaller ones:

  • createFlowVariables
  • addEquations
  • solveGaussian
  • ...

@Jiahui17
Copy link
Member

Jiahui17 commented Feb 4, 2026

We could do a separate PR for class HandshakeOpInternalState

- <forkOp> fork1 -> { fork1.sent1, fork1.sent2, ... }
- fork1.sent2 -> { "it is a sent", "the second one" }
- parse
- print
- write smv

struct HandshakeOpInternalState {
  StringRef writeSmv() virtual = 0;
  /// This is the same as the "handshake.name" of the operation
  std::string name;
  static std::optional<HandshakeOpInternalState> parse() virtual = 0;
  Operation * getOperation(NameAnalysis& namer) {
    namer.findOepration(this->name)
  }
};


struct EagerForkSent : public HandshakeOpInternalState {
  Operation * op;
  unsigned outputId;
  StringRef writeSmv() override {

  }

  // Validate that there is an op with a matching name
  std::optional<HandshakeOpInternalState> parse(NameAnalysis& namer) override {
    

  }
};

if (auto state = EagerForkSent::parse(name)) {
  ...
} else if (auto state = BufferFull::parse(name)) {
  ...
} 

...

@Jiahui17 Jiahui17 marked this pull request as draft February 10, 2026 13:09
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.

2 participants