PennyLaneAI / PennyLaneAI/catalyst

Extend StableHLO constant propagation to DataFlowSolver

Open
#2,707 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
234
Forks
84
Avg merge
2d 15h
Merged PRs (30d)
66

Description

Context
ConstantResolve.cpp is a manual recursive constant folder used by ToPPR.cpp (rotation angles) and ResourceAnalysis.cpp (loop bounds). It handles StableHLO ops via string-name matching (stablehlo.constant, stablehlo.convert, stablehlo.broadcast_in_dim, stablehlo.add, stablehlo.subtract) but this approach is fragile, cannot reason across blocks or control flow, and must be extended manually for each new op. Meanwhile, MLIR's built-in SparseConstantPropagation (SCCP) cannot fold StableHLO ops.

Proposal
Write a custom StableHLOConstantPropagation analysis extending SparseForwardDataFlowAnalysis<Lattice<ConstantValue>>. It would match StableHLO ops by name and apply folding logic similar to StablehloAggressiveFolder.cpp. Callers would run a DataFlowSolver loaded with this analysis and query it for constant values instead of calling ConstantResolve.

Ops to cover: stablehlo.convert, stablehlo.broadcast_in_dim, stablehlo.add, stablehlo.subtract, stablehlo.multiply.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading ConstantResolve.cpp and StablehloAggressiveFolder.cpp, then inspect how ToPPR.cpp and ResourceAnalysis.cpp use constant values. Implement the analysis around DataFlowSolver and cover the five listed StableHLO operations, with callers querying the solver instead of ConstantResolve.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.