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

[Frontend] Refactor compiler #38

Merged
merged 55 commits into from Apr 17, 2023

Conversation

erick-xanadu
Copy link
Contributor

@erick-xanadu erick-xanadu commented Mar 7, 2023

Context: Prepares changes for allowing easier debugging. The idea to improve debugging is to allow easy prototypes of new compilation pipelines which may circumvent some of the default behaviour. For example, instead of generating the MLIR module from python, load it from a string. Instead of generating LLVM-IR, load it from a file. These debugging changes are not yet implemented, but these will be implemented on top of this refactoring.

Description of the Change:

  1. Passes are now classes. This allow developers/users looking to change flags to inherit from these passes and change the flags.
  2. Passes are now passed as arguments to the compiler. Custom passes can just be passed to the compiler as an argument as long as they implement a run method which takes an input and the output of this method can be fed to the next pass.

Benefits: Treats the compiler as a library and allows prototyping alternative compilation flows.

[sc-36252]

@erick-xanadu erick-xanadu force-pushed the eochoa/2023-03-07/compiler-refactor-2 branch from 2f99792 to 45af322 Compare March 14, 2023 15:52
@erick-xanadu erick-xanadu force-pushed the eochoa/2023-03-07/compiler-refactor-2 branch from e62d0d6 to 92735d2 Compare April 4, 2023 18:18
@codecov
Copy link

codecov bot commented Apr 4, 2023

Codecov Report

Merging #38 (c0a0d7c) into main (c9032f5) will increase coverage by 0.46%.
The diff coverage is 100.00%.

❗ Current head c0a0d7c differs from pull request most recent head f17b0a1. Consider uploading reports for the commit f17b0a1 to get more accurate results

@@            Coverage Diff             @@
##             main      #38      +/-   ##
==========================================
+ Coverage   98.24%   98.71%   +0.46%     
==========================================
  Files          34       34              
  Lines        5532     5531       -1     
  Branches      261      265       +4     
==========================================
+ Hits         5435     5460      +25     
+ Misses         55       40      -15     
+ Partials       42       31      -11     
Impacted Files Coverage Δ
frontend/catalyst/compilation_pipelines.py 100.00% <100.00%> (+8.72%) ⬆️
frontend/catalyst/compiler.py 100.00% <100.00%> (+1.06%) ⬆️
frontend/catalyst/jax_tracer.py 90.71% <100.00%> (ø)
frontend/catalyst/utils/gen_mlir.py 100.00% <100.00%> (ø)

... and 9 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@erick-xanadu erick-xanadu force-pushed the eochoa/2023-03-07/compiler-refactor-2 branch from 4ca4d0f to 8316174 Compare April 5, 2023 19:10
@erick-xanadu erick-xanadu force-pushed the eochoa/2023-03-07/compiler-refactor-2 branch from 8316174 to fd6c3dc Compare April 5, 2023 20:54
@erick-xanadu erick-xanadu marked this pull request as ready for review April 5, 2023 21:07
Copy link
Collaborator

@dime10 dime10 left a comment

Choose a reason for hiding this comment

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

Awesome work, really like the redesign of the compiler script into something more structured 💯

frontend/catalyst/utils/utils.py Outdated Show resolved Hide resolved
frontend/catalyst/compiler.py Outdated Show resolved Hide resolved
frontend/catalyst/compiler.py Outdated Show resolved Hide resolved
frontend/catalyst/compiler.py Outdated Show resolved Hide resolved
frontend/catalyst/compiler.py Outdated Show resolved Hide resolved
frontend/catalyst/compilation_pipelines.py Outdated Show resolved Hide resolved
frontend/catalyst/compilation_pipelines.py Show resolved Hide resolved
frontend/catalyst/compiler.py Outdated Show resolved Hide resolved
frontend/catalyst/compiler.py Outdated Show resolved Hide resolved
frontend/catalyst/compiler.py Outdated Show resolved Hide resolved
@erick-xanadu erick-xanadu force-pushed the eochoa/2023-03-07/compiler-refactor-2 branch from 96f53eb to f46294e Compare April 13, 2023 20:06
Copy link
Member

@maliasadi maliasadi left a comment

Choose a reason for hiding this comment

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

Thanks @erick-xanadu! I really like our brand new classified compiler 😄 Just re-reviewed my earlier review and there isn't much more to add. A few minor suggestions but it should be good to be merged from my side.

frontend/catalyst/compilation_pipelines.py Outdated Show resolved Hide resolved
frontend/catalyst/compiler.py Show resolved Hide resolved
frontend/catalyst/compiler.py Show resolved Hide resolved
frontend/catalyst/compiler.py Show resolved Hide resolved
frontend/catalyst/compiler.py Show resolved Hide resolved
Copy link
Collaborator

@dime10 dime10 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 💯

frontend/catalyst/compilation_pipelines.py Outdated Show resolved Hide resolved
frontend/catalyst/compilation_pipelines.py Outdated Show resolved Hide resolved
frontend/catalyst/compilation_pipelines.py Outdated Show resolved Hide resolved
frontend/catalyst/compiler.py Outdated Show resolved Hide resolved
frontend/catalyst/compiler.py Show resolved Hide resolved
frontend/catalyst/compiler.py Outdated Show resolved Hide resolved
frontend/catalyst/compiler.py Outdated Show resolved Hide resolved
@erick-xanadu erick-xanadu merged commit 09fd0be into main Apr 17, 2023
14 checks passed
@erick-xanadu erick-xanadu deleted the eochoa/2023-03-07/compiler-refactor-2 branch April 17, 2023 13:25
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.

None yet

3 participants