Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] New compiler driver interface #1208

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

[WIP] New compiler driver interface #1208

wants to merge 17 commits into from

Conversation

mehrdad2m
Copy link
Contributor

@mehrdad2m mehrdad2m commented Oct 16, 2024

Context:

The compiler driver previously had limited flexibility regarding compiler passes, pipelines, and option management. There was also a need for a standalone command-line compiler tool to facilitate easier compilation and testing of MLIR files without python dependancy. Additionally, the handling of intermediate compiler outputs in the Python frontend was complex and needed simplification.

Description of the Change:

  1. Refactored Compiler Driver:
  • Updated CompilerOptions and related functions to accommodate new options and pipeline configurations.
  • Enhanced the handling of compiler pipelines to allow for custom pipelines and better integration with MLIR’s pass management.
  1. New Standalone Compiler Tool (qcc):
  • qcc enables users to compile MLIR files from the command line.
  • Ability to isolate different tools that are used in the compilation process (quantum-opt, mlir-translate, llc)
  1. Improved Intermediate File Handling
  • Changed the keepIntermediate option, allowing users to save intermediate IR after each pass or pipeline. Currently, this is only available via qcc and the python frontend is still unchanged, which can updated later.
  1. Pipeline Configuration:
  • Defined catalyst pipelines explicitly in Pipelines.h and Pipelines.cpp and also registered them as individual passes. Therefore, user can easily run an specific pipeline on an mlir file.
  1. Removed self.last_compiler_output
  • Modified the compiler to search the workspace directory for outputs which is inline with the keep_intermediate option.

Benefits:

  1. Standalone executable to run the catalyst compilation pipeline without dependancy to python frontend
  2. Easier Debugging capabilities
  3. mlir options are directly accessible from qcc e.g.
    -mlir-print-ir-after-failure
    -mlir-print-ir-before-all
    -mlir-print-op-generic
    -mlir-timing
    -pass-pipeline
  4. New options added for catalyst compiler e.g.
    -tool=[opt|translate|llc]
    -keep-intermediate=[true|false]
    -save-ir-after-each=[pass|pipeline]
    -catalyst-pipeline=pipeline1(pass1;pass2),pipeline2(pass3)

Possible Drawbacks:

Related GitHub Issues:

[sc-73536], [sc-73353]

@mehrdad2m mehrdad2m marked this pull request as ready for review October 17, 2024 02:54
Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md on your branch with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

Copy link

codecov bot commented Oct 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.96%. Comparing base (ea55348) to head (9663843).
Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1208      +/-   ##
==========================================
+ Coverage   97.90%   97.96%   +0.06%     
==========================================
  Files          77       77              
  Lines       10932    11259     +327     
  Branches      967      971       +4     
==========================================
+ Hits        10703    11030     +327     
  Misses        180      180              
  Partials       49       49              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

1 participant