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

Structural refactor of the compilation_pipelines module #529

Merged
merged 8 commits into from
Feb 21, 2024

Conversation

dime10
Copy link
Contributor

@dime10 dime10 commented Feb 21, 2024

This is part 1 of a QJIT refactor which reorganizes some of the classes and methods in the compilation_pipelines.py module. The second part will refactor the QJIT class itself.

Benefits:

  • a new tracing sub-module is created that will over time contain all functionality pertaining to program capture from
    Python
  • reusable functions are grouped together by their purpose, such as signature handling and debugging
  • classes and modules are slimmed down and more focused
  • improved docstrings

Linting is not done yet, and I will also add changelog.

[sc-57014]

A newly created `tracing` sub-module (technically sub-package) will
over time contain all functionality pertaining to program capture from
Python. In this commit, the utils/contexts.py module is moved over
without code changes.
To reduce the size of classes, certain functions, especially static
methods, are factored out into a reusable module.

The module is part of the new tracing sub-module in Catalyst.
To reduce class bloat and organize all debug functionality into a single
interface, some functions are moved to the existing debug module.
Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/changelog.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 Feb 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b009321) 99.55% compared to head (2ce0add) 99.52%.
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #529      +/-   ##
==========================================
- Coverage   99.55%   99.52%   -0.04%     
==========================================
  Files          43       45       +2     
  Lines        7866     7941      +75     
  Branches      537      537              
==========================================
+ Hits         7831     7903      +72     
- Misses         18       20       +2     
- Partials       17       18       +1     

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

Copy link
Contributor

@erick-xanadu erick-xanadu 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/jax_primitives.py Outdated Show resolved Hide resolved
frontend/catalyst/compilation_pipelines.py Outdated Show resolved Hide resolved
frontend/test/pytest/test_jit_behaviour.py Outdated Show resolved Hide resolved
frontend/catalyst/debug.py Show resolved Hide resolved
frontend/catalyst/debug.py Outdated Show resolved Hide resolved
dime10 and others added 2 commits February 21, 2024 15:18
Co-authored-by: erick-xanadu <110487834+erick-xanadu@users.noreply.github.com>
Copy link
Contributor

@rmoyard rmoyard left a comment

Choose a reason for hiding this comment

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

Very clean, great separation of modules 💯

frontend/catalyst/compilation_pipelines.py Show resolved Hide resolved
frontend/catalyst/debug.py Show resolved Hide resolved
@dime10 dime10 force-pushed the frontend-refactor-1 branch from de6fe29 to 2ce0add Compare February 21, 2024 22:00
@dime10 dime10 merged commit 96fef3b into main Feb 21, 2024
33 of 34 checks passed
@dime10 dime10 deleted the frontend-refactor-1 branch February 21, 2024 22:32
dime10 added a commit that referenced this pull request Feb 23, 2024
This is part 2 of a refactor started in #529. 

The QJIT class is reworked into 5 distinct compilation stages:
- pre-compilation (like autograph)
- capture (jaxpr generation)
- ir-generation (mlir generation)
- compilation (llvm and binary code generation - cannot be split up
since this happens in the compiler driver)
- execution

The class is also streamlined by using a new compilation cache to handle
previously compiled functions and signature lookups.

One point of contention might be the results produced by the split of
the `trace_to_mlir` function, which have been simplified and need to be
double checked against #520. EDIT:
c71c322
should address this concern

[sc-57014]

closes #268 
closes #520
rauletorresc pushed a commit that referenced this pull request Feb 26, 2024
This is part 1 of a QJIT refactor which reorganizes some of the classes
and methods in the `compilation_pipelines.py` module. The second part
will refactor the `QJIT` class itself.

Benefits:
- a new `tracing` sub-module is created that will over time contain all
functionality pertaining to program capture from
Python
- reusable functions are grouped together by their purpose, such as
signature handling and debugging
- classes and modules are slimmed down and more focused
- improved docstrings

Linting is not done yet, and I will also add changelog.

[sc-57014]

---------

Co-authored-by: erick-xanadu <110487834+erick-xanadu@users.noreply.github.com>
rauletorresc pushed a commit that referenced this pull request Feb 26, 2024
This is part 2 of a refactor started in #529. 

The QJIT class is reworked into 5 distinct compilation stages:
- pre-compilation (like autograph)
- capture (jaxpr generation)
- ir-generation (mlir generation)
- compilation (llvm and binary code generation - cannot be split up
since this happens in the compiler driver)
- execution

The class is also streamlined by using a new compilation cache to handle
previously compiled functions and signature lookups.

One point of contention might be the results produced by the split of
the `trace_to_mlir` function, which have been simplified and need to be
double checked against #520. EDIT:
c71c322
should address this concern

[sc-57014]

closes #268 
closes #520
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.

3 participants