Skip to content

[DAPHNE-#854] Add Passes for Matrix Result Property Recording and Insertion in IR#855

Merged
pdamme merged 79 commits intodaphne-project:mainfrom
StoeckOverflow:property-recording-pr-branch
May 23, 2025
Merged

[DAPHNE-#854] Add Passes for Matrix Result Property Recording and Insertion in IR#855
pdamme merged 79 commits intodaphne-project:mainfrom
StoeckOverflow:property-recording-pr-branch

Conversation

@StoeckOverflow
Copy link
Copy Markdown
Contributor

@StoeckOverflow StoeckOverflow commented Oct 14, 2024

This PR introduces two new passes: RecordPropertiesPass and InsertPropertiesPass. These passes enable the recording of runtime properties of matrix result objects and the reinsertion of these properties into the IR (Intermediate Representation) during subsequent runs. This process aims to improve optimization and analysis.

Changes:

  • Property Recording Pass:

    • Records runtime properties (until now only sparsity) of matrix results during IR transformations.
    • Leverages a new PropertyLogger to capture and save properties in a JSON file.
  • Property Insertion Pass:

    • Reads properties from the JSON file and reinserts them into IR operations, allowing reuse of runtime data.
    • Supports modifying matrix types in the IR based on the previously recorded properties.

Features:

  • New Configuration Options:
    • enable_property_recording: Enables the recording of matrix properties.
    • enable_property_insert: Enables reinserting properties from a previous run.
    • properties_file_path: Specifies the path to the JSON file for storing or retrieving matrix properties.

Documentation:

  • Updated RunningDaphneLocally.md to reflect the new configuration options and command-line flags.

Testing:

  • Added tests for recording matrix properties inside loops and conditional blocks (scf.for, scf.if, scf.while).
  • Verified property recording for both dense and sparse matrix types.

@StoeckOverflow StoeckOverflow marked this pull request as ready for review December 1, 2024 11:10
@pdamme pdamme self-requested a review May 22, 2025 19:53
- Undid unrelated changes (e.g., change of the sparsity threshold, change of DaphneLib tmp directory, unnecessarily added includes, change of top-k for --statistics).
- Removed WhileLoopInvariantCodeMotionPass; this PR reintroduced it (after it was removed from the codebase a while ago), but doesn't use it.
- Made the CLI args --enable-property-recording and --enable-property-insert mutually exclusive (using both at the same time doesn't make sense).
- Changed recordProperties-kernel to really count the number of non-zeros also in CSRMatrix, because even CSRMatrix could store some zeros explicitly.
- Added instantiations of recordProperties-kernel for CSRMatrix with all numeric value types currently supported.
- Moved test cases from test/codegen/ to test/util/, because this feature is not about codegen.
- Undid some formatting changes.
- Improved wording in some comments/docs.
- Added missing license headers.
- And some more minor things.
@pdamme pdamme force-pushed the property-recording-pr-branch branch from c97660b to b3d9d2a Compare May 23, 2025 11:12
pdamme added 6 commits May 23, 2025 13:20
- The recorded true data properties are stored to the file specified by --properties-file-path (not always to "properties.json").
- Slight polishing of the code for data property recording and insertion.
- The newly introduced CLI args are not documented in RunningDaphneLocally.md, because the new feature is experimental and not the first thing we want users to look at.
- Instead, added a minimal page in the developer docs.
Copy link
Copy Markdown
Collaborator

@pdamme pdamme left a comment

Choose a reason for hiding this comment

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

Thanks for this new feature, @StoeckOverflow! It is useful for research and development related to optimizations based on interesting data properties in DAPHNE. Overall, your code was already in a good shape. I still cleaned it up a bit (see my commits for details) and now it's ready to be merged.

@pdamme pdamme merged commit 5578ef5 into daphne-project:main May 23, 2025
3 checks passed
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